Package: bridge-utils
Version: 1.2-1
Severity: wishlist
Tags: patch
Hello!
I created the following patch, which allows for specifying `bridge_ports'
interfaces by using regular expressions, as described in the updated
documentation file. Please consider to include this patch.
There is a comment in the `postdown' file that could be addressed and /
or there could be some preprocessing mechanism used to avoid the
duplication of code between the two modified program files.
Regards,
Thomas
diff -ru bridge-utils-1.2.orig/debian/README.Debian
bridge-utils-1.2/debian/README.Debian
--- bridge-utils-1.2.orig/debian/README.Debian 2007-01-01 15:13:38.000000000
+0100
+++ bridge-utils-1.2/debian/README.Debian 2007-01-01 20:10:57.000000000
+0100
@@ -29,7 +29,7 @@
Well, after setting this, an ifup br0, or the next reboot, should let you
have a bridge up and running, after waiting for the ports to get to the
forwarding status, of course. This bridge will be using all your ethX
-interfaces, as we have stated on the bridge_port line.
+interfaces, as we have stated on the bridge_ports line.
Now the Debian bridge setup scripts will wait for it to get ready to
work. They do this by trying to guess the maximum time that the bridge
@@ -95,13 +95,12 @@
/etc/network/interfaces to setup the bridge, so you don't have to go and
look at the scripts...
-bridge_ports <interfaces>
+bridge_ports <interface specification>
this option must exist for the scripts to setup the bridge, with
it you specify the ports you want to add to your bridge, either
using "none" if you want a bridge without any interfaces or you
- want to add them later using brctl, "all" if you want all the
- ethX interfaces to be added to the bridge, or a list of the
- interfaces you want to add separated by spaces, for example:
+ want to add them later using brctl, or a list of the interfaces
+ you want to add separated by spaces, for example:
bridge_ports eth0 eth4
@@ -109,6 +108,26 @@
will be used by the bridge, as this will be setup automatically
by the scripts when bringing the bridge up.
+ If you need to specify the interfaces more flexibly, you can
+ use the following syntax:
+
+ bridge_ports regex (eth|vif).*
+
+ This means to evaluate (as in egrep(1)) the expressions that
+ follow after "regex" until either the end or a "noregex" statement
+ is reached. The regular expressions are evaluated against all
+ local interfaces and those that match are added.
+
+ Specifying "all" is short for "regex eth.* noregex" and will get
+ all the ethX interfaces added to the bridge.
+
+ Carrying this to the extremes, the following is valid syntax:
+
+ bridge_ports all regex if.0 noregex ext0 regex vif.*
+
+ This will add all ethX interfaces, the ifX0 interfaces, the ext0
+ interface and all vifX interfaces.
+
bridge_ageing <time>
set ageing time, default is 300, can have a fractional part.
diff -ru bridge-utils-1.2.orig/debian/postdown bridge-utils-1.2/debian/postdown
--- bridge-utils-1.2.orig/debian/postdown 2007-01-01 15:13:38.000000000
+0100
+++ bridge-utils-1.2/debian/postdown 2007-01-01 17:07:18.000000000 +0100
@@ -25,11 +25,56 @@
ifconfig $IFACE down
-for i in $INTERFACES
+# TODO: Should be perhaps simply remove all interfaces that are currently
+# attached to the bridge? But what to do then with the invokations of
+# `if-pre-up.d/vlan'?
+all_interfaces= &&
+unset all_interfaces &&
+set x $INTERFACES &&
+shift &&
+while [ x"${1+set}" = xset ]
do
- if [ "$i" = "all" ]; then
- i=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/')
- fi
+ # For compatibility: the `all' option.
+ case $1 in
+ all)
+ shift &&
+ set regex eth.\* noregex ${1+"$@"}
+ ;;
+ esac
+
+ case $1-`uname -s` in
+ regex-Linux)
+ all_interfaces=`sed -n 's%^[\ ]*\([^:]*\):.*$%\1%p' < /proc/net/dev`
+ shift
+ ;;
+ regex-*)
+ echo -n "$0 needs to be ported for your `uname -s` system. " >&2
+ echo "Trying to continue nevertheless." >&2
+ shift
+ ;;
+ noregex-*)
+ all_interfaces=
+ unset all_interfaces
+ shift
+ ;;
+ esac
+
+ case ${all_interfaces+regex} in
+ regex)
+ # The following interface specification are to be parsed as regular
+ # expressions against all interfaces the system provides.
+ i=`egrep "^$1$" << EOAI
+$all_interfaces
+EOAI
+`
+ ;;
+ *)
+ # Literal interfaces.
+ i=$1
+ ;;
+ esac
+ shift
+
for port in $i
do
ifconfig $port down && brctl delif $IFACE $port && \
diff -ru bridge-utils-1.2.orig/debian/preup bridge-utils-1.2/debian/preup
--- bridge-utils-1.2.orig/debian/preup 2007-01-01 15:13:38.000000000 +0100
+++ bridge-utils-1.2/debian/preup 2007-01-01 17:07:12.000000000 +0100
@@ -25,11 +25,53 @@
brctl addbr $IFACE &&
-for i in $INTERFACES
+all_interfaces= &&
+unset all_interfaces &&
+set x $INTERFACES &&
+shift &&
+while [ x"${1+set}" = xset ]
do
- if [ "$i" = "all" ]; then
- i=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/')
- fi
+ # For compatibility: the `all' option.
+ case $1 in
+ all)
+ shift &&
+ set regex eth.\* noregex ${1+"$@"}
+ ;;
+ esac
+
+ case $1-`uname -s` in
+ regex-Linux)
+ all_interfaces=`sed -n 's%^[\ ]*\([^:]*\):.*$%\1%p' < /proc/net/dev`
+ shift
+ ;;
+ regex-*)
+ echo -n "$0 needs to be ported for your `uname -s` system. " >&2
+ echo "Trying to continue nevertheless." >&2
+ shift
+ ;;
+ noregex-*)
+ all_interfaces=
+ unset all_interfaces
+ shift
+ ;;
+ esac
+
+ case ${all_interfaces+regex} in
+ regex)
+ # The following interface specification are to be parsed as regular
+ # expressions against all interfaces the system provides.
+ i=`egrep "^$1$" << EOAI
+$all_interfaces
+EOAI
+`
+ ;;
+ *)
+ # Literal interfaces.
+ i=$1
+ ;;
+ esac
+ shift
+
for port in $i
do
if [ -x /etc/network/if-pre-up.d/vlan ]; then