Date: Sat, 7 Feb 2015 13:02:51 -0800 From: Alfred Perlstein <alfred@freebsd.org> To: net@freebsd.org Subject: Nasty bug in startup scripts with interface renaming. Message-ID: <CC945B9D-7BDA-46AD-8362-E82C1FD72873@freebsd.org>
next in thread | raw e-mail | index | archive | help
If you happen to use interface renaming there is a nasty bug lurking in the startup scripts, it seems newly introduced, but I am unsure.
Specifically the following happens at boot time:
/etc/rc.d/netif is run without args.
It gets the list of interfaces and for each interface it calls network_start().
however in network start we have this:
# Create cloned interfaces
clone_up $cmdifn
# Rename interfaces.
ifnet_rename $cmdifn
# Configure the interface(s).
network_common ifn_start $cmdifn
Now it doesn't take that much to realize that if 'ifnet_rename' renames 'cmdifn' then the subsequent call to 'network_common ifn_start $cmdifn' will be passing a stale interface in as a parameter and causes a bunch of errors to happen.
Example:
cmdifn="vtnet0"
Therefor:
# Rename interfaces.
ifnet_rename vtnet0 # <- gets renamed here to derp0
# Configure the interface(s).
network_common ifn_start vtnet0 # <- this seems to cause an error since we're using old name.
I looked at fixing ifnet_rename() to take a variable to assign to, so for instance the call could turn into something like:
ifnet_rename cmdifn vtnet0
This way cmdifn would be set to 'derp0' and subsequent stuff would work, however…. then I realized that ifnet_rename can take 0 args, or MULTIPLE args and will act on either all interfaces or the ones passed in. So passing another var becomes a problem.
I then realized that if I threw together a patch to fix it "the alfred way" people would probably be upset.
So I'm asking, any suggestions before I go about just fixing this?
-Alfred
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CC945B9D-7BDA-46AD-8362-E82C1FD72873>
