conf/82314: /etc/rc.d/netif does not build the list of interfaces correctly.

Darren Pilgrim dmp at bitfreak.org
Thu Jun 16 09:20:16 GMT 2005


>Number:         82314
>Category:       conf
>Synopsis:       /etc/rc.d/netif does not build the list of interfaces correctly.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 16 09:20:16 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Darren Pilgrim
>Release:        6.0-current
>Organization:
n/a
>Environment:
FreeBSD Smiley.Blackthornes.LAN 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Sat Jun 11 20:04:30 PDT 2005     root at Smiley.Blackthornes.LAN:/usr/obj/usr/src/sys/Smiley  i386

>Description:
/etc/rc.d/netif is called for two different purposes, each with its own calling method and requirements.  The first is at boot to set up the network interfaces configured in /etc/rc.conf.  To perform this task netif is run without any parameters.  The intention is for netif to realize its lack of parameters and configure all interfaces.

The second purpose of netif is to perform the interface configuration legwork for pccard_ether and possibly others.  In this mode, an interface name and the start/stop command are given as the parameters.  The intention is for netif to realize that it will be working with just the one interface.

The error occurs when netif goes to set _ifn_list to the list of valid interfaces for these modes.  The existing code works correctly for the first mode: network_common() calls list_net_interfaces(), which returns a list comprised of the contents of network_interfaces and cloned_interfaces.  However, this is not correct for the second mode and network_common() fails: in a configuration where some interfaces are handled through pccard_ether, the interface list needs to include not just list_net_interfaces(), but removable_interfaces as well.  If netif is being called from something other than pccard_ether, then the interface could be anything.  To make netif work in this scenario, _ifn_list should be set to those interfaces ifconfig knows about.

The attached patch changes the behavior of network_common() to set _ifn_list to list_net_interfaces() for the first mode and the output of `ifconfig -l` for the second mode.  This resulted in correct setup of interfaces when netif is run either directly or by pccard_ether.
>How-To-Repeat:
1: Configure your system to exclude an interface by setting network_interfaces in /etc/rc.conf.

2: Add the excluded interface to removable_interfaces, source /etc/rc.conf and run /etc/pccard_ether <interface> start.   Note the error stating the interface doesn't exist.

Alternate for 2: Run /etc/rc.d/netif start <interface>.  Note the error stating the interface doesn't exist.
>Fix:
      --- netif.orig  Thu Jun 16 00:26:36 2005
+++ netif       Thu Jun 16 01:32:14 2005
@@ -102,13 +102,11 @@
        fi
        [ -n "$2" ] && _verbose=yes

-       # Get a list of network interfaces.
-       _ifn_list="`list_net_interfaces`"
-
        # Set the scope of the command (all interfaces or just one).
        #
        _cooked_list=
        if [ -n "$_cmdifn" ]; then
+               _ifn_list="`ifconfig -l`"
                for i in $_cmdifn ; do
                        eval _if=\"`expr "$_ifn_list" : ".*\(${i}\).*"`\"
                        if [ -z "$_if" ]; then
@@ -117,7 +115,7 @@
                        _cooked_list="$_cooked_list $_if"
                done
        else
-               _cooked_list="$_ifn_list"
+               _cooked_list="`list_net_interfaces`"
        fi

        for ifn in ${_cooked_list}; do

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list