Package: bridge-utils
Version: 1.5-2
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu oneiric ubuntu-patch

Hi Manty,

The attached patch implements the udev rule that we discussed to trigger
bring-up of bridges when a member interface is made available via the
kernel.  This fixes the race condition on startup where
/etc/rcS.d/S<NN>networking may run before the physical network interfaces
have all been fully probed by the kernel, thereby preventing bridges from
being correctly initialized on boot.

I believe the udev rule is fully idempotent (it will DTRT whether triggered
before or after /etc/init.d/networking).  It is based on the upstart job
previously included in the Ubuntu bridge-utils package.  If acceptable, this
patch will let Ubuntu get back in sync with Debian on the bridge-utils
package (after the next LTS - until then, some upgrade code is needed to
handle the transition from upstart job to udev rule).

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
[email protected]                                     [email protected]
diff -u bridge-utils-1.5/debian/rules bridge-utils-1.5/debian/rules
--- bridge-utils-1.5/debian/rules
+++ bridge-utils-1.5/debian/rules
@@ -73,6 +73,7 @@
 	ln -s /lib/bridge-utils/ifupdown.sh $(IDIR)/etc/network/if-pre-up.d/bridge
 	ln -s /lib/bridge-utils/ifupdown.sh $(IDIR)/etc/network/if-post-down.d/bridge
 	$(INSTALL_SCRIPT) -m 755 debian/bridge-utils.sh $(IDIR)/lib/bridge-utils/
+	$(INSTALL_SCRIPT) -m 755 debian/bridge-network-interface.sh $(IDIR)/lib/udev/bridge-network-interface
 	
 #	dh_movefiles
 
@@ -91,6 +92,7 @@
 #	dh_installemacsen
 #	dh_installpam
 #	dh_installinit
+	dh_installudev --name bridge-network-interface
 #	dh_installcron
 	dh_installman doc/brctl.8 debian/bridge-utils-interfaces.5
 	dh_installinfo
diff -u bridge-utils-1.5/debian/dirs bridge-utils-1.5/debian/dirs
--- bridge-utils-1.5/debian/dirs
+++ bridge-utils-1.5/debian/dirs
@@ -4,0 +5 @@
+lib/udev
only in patch2:
unchanged:
--- bridge-utils-1.5.orig/debian/bridge-utils.bridge-network-interface.udev
+++ bridge-utils-1.5/debian/bridge-utils.bridge-network-interface.udev
@@ -0,0 +1 @@
+ACTION=="add", SUBSYSTEM=="net", RUN+="bridge-network-interface"
only in patch2:
unchanged:
--- bridge-utils-1.5.orig/debian/bridge-network-interface.sh
+++ bridge-utils-1.5/debian/bridge-network-interface.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# bridge-network-interface - configure a network bridge
+#
+# This service checks whether a physical network device that has been added
+# is one of the ports in a bridge config, and if so, brings up the related
+# bridge
+
+set -e
+
+if [ -z "$INTERFACE" ]; then
+	echo "missing \$INTERFACE" >&2
+	exit 1
+fi
+
+. /lib/bridge-utils/bridge-utils.sh
+
+mkdir -p /var/run/network
+for i in $(ifquery --list --allow auto); do
+	ports=$(ifquery $i | sed -n -e's/^bridge_ports: //p')
+	for port in $(bridge_parse_ports $ports); do
+		case $port in
+			$INTERFACE|$INTERFACE.*)
+				ifup --allow auto $i
+				brctl addif $i $port && ifconfig $port 0.0.0.0 up
+				break
+				;;
+		esac
+	done
+done

Reply via email to