You are not logged in.

#1 2005-12-16 10:15:16

Nazdravi
Member
Registered: 2003-03-20
Posts: 12

network bridging and start script (solved)

The existing configuration stub for bridging is not supported by the actual version of the network start script (/etc/rc.d/network). Here the modifications to include bridged networking into the network management:

# in /etc/conf.d/bridges: modified format for bridge member interfaces
bridge_br0=(eth0 eth1)
# in /etc/rc.d/network: included support for bridge interfaces (see #BRIDGE-marks)
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

# BRIDGE
# look for bridge settings
[ -f /etc/conf.d/bridges ] && . /etc/conf.d/bridges

# look for wireless settings
[ -f /etc/conf.d/wireless ] && . /etc/conf.d/wireless

# look for ethernet bonding settings
[ -f /etc/conf.d/bonding ] && . /etc/conf.d/bonding

# look for dhcpcd settings
[ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd

# Special wrapper for hotplug ifup calls
#  (make sure hotplug doesn't bring up disabled interfaces)
hotplug_ifup()
{
        [ "$1" != "" ] || return 1
        for ifline in ${INTERFACES[@]}; do
                # if the interface is disabled then this will be skipped
                if [ "$ifline" = "$1" ]; then
                        ifup $ifline
                fi
        done
}

ifup()
{
        if [ "$1" = "" ]; then
                echo "usage: $0 ifup <interface_name>"
                return 1
        fi
# BRIDGE
        for brif in ${BRIDGE_INTERFACES[@]}; do
                if [ "$brif" = "${1}" ]; then
                        /usr/sbin/brctl addbr $brif
                        brvarname="$bridge_${1}"
                        eval brif_line=$brvarname
                        for brif_ in ${brif_line[@]}; do
                            /usr/sbin/brctl addif $brif $brif_
                        done
                        /bin/sleep 2
                fi
        done
        for wif in ${WLAN_INTERFACES[@]}; do
                if [ "$wif" = "${1}" ]; then
                        wvarname="$wlan_${1}"
                        eval wif_line=$wvarname
                        /usr/sbin/iwconfig $wif_line
                        /bin/sleep 2
                fi
        done
        varname="$${1}"
        eval new_ifline=$varname
        if [ "$new_ifline" = "dhcp" ]; then
                # remove the .pid file if it exists
                rm -f /etc/dhcpc/dhcpcd-${1}.{pid,cache} >/dev/null 2>&1
                /usr/sbin/dhcpcd $DHCPCD_ARGS $1
        else
                /sbin/ifconfig $new_ifline
        fi
        return $?
}

ifdown()
{
        if [ "$1" = "" ]; then
                echo "usage: $0 ifdown <interface_name>"
                return 1
        fi
        varname="$${1}"
        eval new_ifline=$varname
        if [ "$new_ifline" = "dhcp" ]; then
                if [ -f /etc/dhcpc/dhcpcd-${1}.pid ]; then
                        /bin/kill `cat /etc/dhcpc/dhcpcd-${1}.pid`
                else
                        # No .pid file, just bring the interface itself down
                        /sbin/ifconfig $1 down
                fi
        else
                /sbin/ifconfig $new_ifline down
        fi
# BRIDGE
        for brif in ${BRIDGE_INTERFACES[@]}; do
                if [ "$brif" = "${1}" ]; then
                        /usr/sbin/brctl delbr $brif
                fi
        done
        return $?
}

# from here unmodified /etc/rc.d/network

Hope this helps anybody.

Offline

#2 2005-12-16 10:22:58

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: network bridging and start script (solved)

Nice one, Nazdravi. You should post a bug report on this - the devs don't always read the forum.

Offline

Board footer

Powered by FluxBB