[PATCH] ctdb-scripts: Strip out virtual NIC information from iface name.
Martin Schwenke
martin at meltin.net
Thu Sep 24 23:05:57 UTC 2015
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