[PATCH] ctdb-scripts: Strip out virtual NIC information from iface name.

José A. Rivera jarrpa at samba.org
Fri Sep 25 06:20:03 UTC 2015


Hey Martin,

I would think that the following line would have taken care of it as 
well...
but it somehow didn't. :( That's the thing, I can't figure out why it
wouldn't. A brief CLI test in bash shows that the logic SHOULD work in 
awk,
but for some reason I wasn't getting the names trimmed properly... hence 
why
I wanted a bit more scrutiny on this.

Thanks!
--Jose

On 2015-09-24 16:05, Martin Schwenke wrote:
> Hi José,
> 
> On Thu, 24 Sep 2015 15:08:02 -0700, José A. Rivera <jarrpa at samba.org>
> wrote:
> 
>> A tiny fix to some scripting regex. It already has a +1 from gd, and
>> I've
>> already run a private autobuild against it, but we'd both like to have
>> at
>> least another pair of eyes on this to make sure it doesn't explode the
>> planet. :)
> 
> Isn't this already done by the line after the one you're changing?
> 
> -	    'NR == 1 { iface = $2; sub(":$", "", iface) ; \
> +	    'NR == 1 { iface = $2; sub("(@.*)?:$", "", iface) ; \
>  		       sub("@.*", "", iface) } \
> 
> I'm guessing that you're looking at this because you've seen a problem,
> so I would like to understand why the existing code isn't working.
> 
> Using a single sub() to do the overall substitution (and dropping
> the following line) would be more compact (though not really
> necessary!) but I would want to check the portability of the regexp
> "(foo)?" syntax, since we've been bitten by awk portability issues
> before.  I think that it is part of the Extended Regular Expression
> syntax, which POSIX says is used by awk, so I think it is fine.
> 
> ... and, yeah, the ip command is hardly portable, so this requires
> Linux, but I want to make sure it is portable across awk versions
> (Debian tends to install mawk by default).  :-)
> 
> We have unit testcases
> (ctdb/tests/eventscripts/10.interface.monitor.01[78].sh) for this but
> they only use the stub ip implementation to try and test the VLAN
> case.  I'm not sure if the "ip add show to ..." output looks a bit
> different under lxc.
> 
> Thanks for any more info...  :-)
> 
> peace & happiness,
> martin



More information about the samba-technical mailing list