Nasty bug in startup scripts with interface renaming.

Alfred Perlstein alfred at freebsd.org
Sat Feb 7 20:58:52 UTC 2015


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





More information about the freebsd-net mailing list