aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmac <mitr@volny.cz>2006-03-27 02:12:15 +0000
committerMiloslav Trmac <mitr@volny.cz>2006-03-27 02:12:15 +0000
commit9b2bf404ff0594fc96c4b230a7b8d384afb14e65 (patch)
treea6bd69d4ebd3b276d0de403a7e3c8de9cd53bcc0
parent2a11a3e64d43ef85e91de1051fad9d63d568ff07 (diff)
downloadinitscripts-9b2bf404ff0594fc96c4b230a7b8d384afb14e65.tar
initscripts-9b2bf404ff0594fc96c4b230a7b8d384afb14e65.tar.gz
initscripts-9b2bf404ff0594fc96c4b230a7b8d384afb14e65.tar.bz2
initscripts-9b2bf404ff0594fc96c4b230a7b8d384afb14e65.tar.xz
initscripts-9b2bf404ff0594fc96c4b230a7b8d384afb14e65.zip
Add support for DHCP on bridges (#125259, original patch by Anders Kaseorg
<anders@kaseorg.com>): - rc.d/init.d/network: Initialize bridges after bridged interfaces, deinitialize them before bridged interfaces - sysconfig/network-scripts/ifdown-eth: Destroy bridges lazily when the last bridged interface is stopped - sysconfig/network-scripts/ifup-eth: * Handle bridges before checking for module presence or wireless devices * Add bridges lazily when the first bridged interface is started
-rwxr-xr-xrc.d/init.d/network17
-rwxr-xr-xsysconfig/network-scripts/ifdown-eth9
-rwxr-xr-xsysconfig/network-scripts/ifup-eth35
3 files changed, 30 insertions, 31 deletions
diff --git a/rc.d/init.d/network b/rc.d/init.d/network
index cf0fa00a..2a287dd6 100755
--- a/rc.d/init.d/network
+++ b/rc.d/init.d/network
@@ -94,12 +94,11 @@ case "$1" in
# bring up all other interfaces configured to come up at boot time
for i in $interfaces; do
- unset DEVICE TYPE SLAVE BRIDGE
+ unset DEVICE TYPE SLAVE
eval $(LANG=C fgrep "DEVICE=" ifcfg-$i)
eval $(LANG=C fgrep "TYPE=" ifcfg-$i)
eval $(LANG=C fgrep "SLAVE=" ifcfg-$i)
- eval $(LANG=C fgrep "BRIDGE=" ifcfg-$i)
-
+
if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi
if [ "${DEVICE##cipcb}" != "$DEVICE" ] ; then
@@ -110,9 +109,8 @@ case "$1" in
xdslinterfaces="$xdslinterfaces $i"
continue
fi
-
- if [ -n "$BRIDGE" ]; then
- is_available $i
+
+ if [ "$TYPE" = "Bridge" ]; then
bridgeinterfaces="$bridgeinterfaces $i"
continue
fi
@@ -197,18 +195,17 @@ case "$1" in
# get list of bonding, cipe, and xdsl interfaces
for i in $interfaces; do
- unset DEVICE TYPE BRIDGE
+ unset DEVICE TYPE
eval $(LANG=C fgrep "DEVICE=" ifcfg-$i)
eval $(LANG=C fgrep "TYPE=" ifcfg-$i)
- eval $(LANG=C fgrep "BRIDGE=" ifcfg-$i)
-
+
if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi
if [ "${DEVICE##cipcb}" != "$DEVICE" ] ; then
cipeinterfaces="$cipeinterfaces $i"
continue
fi
- if [ -n "$BRIDGE" ]; then
+ if [ "$TYPE" = "Bridge" ]; then
bridgeinterfaces="$bridgeinterfaces $i"
continue
fi
diff --git a/sysconfig/network-scripts/ifdown-eth b/sysconfig/network-scripts/ifdown-eth
index 55c02fbd..6651c93f 100755
--- a/sysconfig/network-scripts/ifdown-eth
+++ b/sysconfig/network-scripts/ifdown-eth
@@ -26,8 +26,11 @@ if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then
# Upon removing a device from a bridge,
# it's necessary to make radvd reload its config
[ -r /var/run/radvd/radvd.pid ] && kill -HUP `cat /var/run/radvd/radvd.pid`
+ if LC_ALL=C /usr/sbin/brctl show | LC_ALL=C grep -q "^${BRIDGE} .*can't get port info"; then
+ /usr/sbin/brctl delbr ${BRIDGE}
+ fi
exit 0
-fi
+fi
. /etc/sysconfig/network
@@ -108,10 +111,6 @@ if [ "$retcode" = 0 ] ; then
# the interface went down.
fi
-if [ "$TYPE" = "Bridge" -a -x /usr/sbin/brctl ]; then
- /usr/sbin/brctl delbr ${DEVICE}
-fi
-
if [ -n "$VLAN" -a -x /sbin/vconfig ]; then
# 802.1q VLAN
if echo ${DEVICE} | LANG=C egrep -v '(:)' | LANG=C egrep -q '(eth|bond)[0-9][0-9]*\.[0-9][0-9]?[0-9]?[0-9]?' \
diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth
index 5a4a985e..dad0d851 100755
--- a/sysconfig/network-scripts/ifup-eth
+++ b/sysconfig/network-scripts/ifup-eth
@@ -50,27 +50,14 @@ if [ -n "${HWADDR}" ]; then
fi
fi
-# now check the real state
-is_available ${REALDEVICE} || {
- if [ -n "$alias" ]; then
- echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization."
- else
- echo $"Device ${DEVICE} does not seem to be present, delaying initialization."
- fi
- exit 1
-}
-
-# is the device wireless? If so, configure wireless device specifics
-is_wireless_device ${DEVICE} && . ./ifup-wireless
-
if [ "${TYPE}" = "Bridge" ]; then
if [ ! -x /usr/sbin/brctl ]; then
echo $"Bridge support not available: brctl not found"
exit 1
fi
- /sbin/ip link set dev ${DEVICE} down 2>/dev/null
- /usr/sbin/brctl delbr ${DEVICE} 2>/dev/null
- /usr/sbin/brctl addbr ${DEVICE} 2>/dev/null
+ if ! LC_ALL=C /usr/sbin/brctl show | LC_ALL=C grep -q "^${DEVICE} "; then
+ /usr/sbin/brctl addbr ${DEVICE} 2>/dev/null
+ fi
# brctl doesn't report success/failure (BZ #104408)
# Test for ourselves whether it worked.
if ! /usr/sbin/brctl show | LANG=C grep -q "^${DEVICE} " ; then
@@ -82,7 +69,23 @@ if [ "${TYPE}" = "Bridge" ]; then
[ -n "${STP}" ] && /usr/sbin/brctl stp ${DEVICE} ${STP}
fi
+# now check the real state
+is_available ${REALDEVICE} || {
+ if [ -n "$alias" ]; then
+ echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization."
+ else
+ echo $"Device ${DEVICE} does not seem to be present, delaying initialization."
+ fi
+ exit 1
+}
+
+# is the device wireless? If so, configure wireless device specifics
+is_wireless_device ${DEVICE} && . ./ifup-wireless
+
if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then
+ if ! LC_ALL=C /usr/sbin/brctl show | LC_ALL=C grep -q "^${BRIDGE} "; then
+ /usr/sbin/brctl addbr ${BRIDGE} 2>/dev/null
+ fi
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null
/sbin/ip link set dev ${DEVICE} up
/usr/sbin/brctl addif ${BRIDGE} ${DEVICE}