openrc-discuss

removing device from bridge when stopped

nivwiz@xxxxxxxxx

Thu Mar 11 22:26:32 2010

Hi all, here is some more bridge fun:

/etc/init.d/net.eth1 --verbose start
 * Caching service dependencies ...                                       [
ok ]
 * Bringing up interface eth1
 *   Loaded modules: apipa arping bonding tuntap bridge ccwgroup macchanger
macnet wpa_supplicant ssidnet iproute2 autoipd system dhcpcd ip6to4
 *   Running preup ...
 *   Adding ports to br0
 *     eth1 ...                                                           [
ok ]
 *   Configuring eth1 for MAC address 00:02:B3:12:34:56 ...               [
ok ]
 *   null ...                                                             [
ok ]
 *   Waiting for IPv6 addresses ...                                       [
ok ]
 *   Running postup ...
# /etc/init.d/net.eth1 --verbose stop
 * Bringing down interface eth1
 *   Loaded modules: ip6to4 dhcpcd udhcpc dhclient system br2684ctl autoipd
iproute2 ifconfig ssidnet wpa_supplicant iwconfig ipppd ifplugd netplugd
macnet macchanger ccwgroup bridge tuntap bonding arping apipa
# brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.0002b3123456    yes        eth1

here is my /etc/conf.d/net :
config_eth0=( "dhcp" )
config_eth1=( "null" )
config_tap0=( "null" )
config_ra0=( "null" )
channel_ra0="5"
essid_ra0=( "test" )
mode_ra0="master"
bridge_add_eth1="br0"
bridge_add_tap0="br0"
config_br0="192.168.14.2/24"
brctl_br0="stp on"
depend_br0() {
        use net.eth1 hostapd
}
tuntap_tap0="tap"
preup() {
        if [ "${IFACE}" == "ra0" ] ; then
                einfo "adding ${IFACE} to bridge"
                /sbin/brctl addbr br0
                /sbin/brctl show >>/tmp/debug.br0.ra0.log
                /sbin/brctl addif br0 ${IFACE}
                /sbin/brctl show >>/tmp/debug.br0.ra0.log
        fi
        return 0
}

To fix this I want to use functions that are in /lib/rc/net/bridge.sh as :

predown() {
       if [ _is_bridge -a "${IFACE}" == "eth1" ]; then
               einfo "removing ${IFACE} from bridge"
               /sbin/brctl delif br0 ${IFACE} || return 1
       fi
       return 0
}

so eth1 is only removed if bridge exist. later I will check if eth1 is part
of the bridge.

Follow-Ups:
Re: removing device from bridge when stoppednivwiz@xxxxxxxxx
Re: removing device from bridge when stoppednivwiz@xxxxxxxxx
Archive administrator: postmaster@marples.name