Package: bridge-utils
Version: 1.5-6
Severity: wishlist
Tags: patch

Dear Maintainer,


I came into the situation where I wanted to assign a specific hw address
to a bridge device.  However, using the bridge_hw option didn't work for
me as I wasn't adding any interfaces to the bridge (the bridge is used
for attaching virtualbox VMs which somehow magically work without `brctl
show` displaying any interfaces).  Changing the mac address with
`ip link set address … dev br0` after the bridge was created caused it
to change its state from UNKNOWN to DOWN which make it unfunctional for
virtualbox.  Manually changing the state to UP didn't work either.


While reading the ip-link.8 man page I noticed that this can also be
used to create bridge devices with the option of specifying a mac
address.  After some testing, I ask you to consider using this way to
create bridge interfaces in conjunction with the bridge_hw option, as
the hw address stays the same even after interfaces are added and
removed.  See the following sample output of some commands (I've tried
it with the mac addresses for br0 being both larger and smaller compared
to eth0).

# ip link add br0 address fc:cc:cc:cc:cc:cc type bridge
# ip a s dev br0
27: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
    link/ether cc:cc:cc:cc:cc:cc brd ff:ff:ff:ff:ff:ff
# brctl addif br0 eth0
# ip a s dev eth0
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master br0
state DOWN group default qlen 1000
    link/ether aa:aa:aa:aa:aa:aa brd ff:ff:ff:ff:ff:ff
# ip a s dev br0
27: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
    link/ether cc:cc:cc:cc:cc:cc brd ff:ff:ff:ff:ff:ff
# brctl delif br0 eth0
# ip a s dev eth0
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN
group default qlen 1000
    link/ether aa:aa:aa:aa:aa:aa brd ff:ff:ff:ff:ff:ff
# ip a s dev br0
27: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
    link/ether cc:cc:cc:cc:cc:cc brd ff:ff:ff:ff:ff:ff
# brctl delbr br0

As far as I can tell using `ip link add …` without the address yields
the same behavior as using brctl addbr, so I wrote a (trivial) patch to
/lib/bridge-utils/ifupdown.sh implementing the change suggested above.
Of course the man page would also need an update if the change was accepted.


Regards
Lukas Schwaighofer


-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.10-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages bridge-utils depends on:
ii  libc6  2.17-93

bridge-utils recommends no packages.

Versions of packages bridge-utils suggests:
ii  ifupdown   0.7.44
ii  net-tools  1.60-25

-- no debconf information
--- ifupdown.sh.orig    2013-10-08 10:52:10.436394216 +0200
+++ ifupdown.sh.new     2013-10-08 10:58:57.283961964 +0200
@@ -27,7 +27,11 @@
 
 # Previous work (create the interface)
 if [ "$MODE" = "start" ] && [ ! -d /sys/class/net/$IFACE ]; then
-  brctl addbr $IFACE || exit 1
+  BROPTS=""
+  if [ "$IF_BRIDGE_HW" ] ; then
+    BROPTS="$BROPTS address $IF_BRIDGE_HW"
+  fi
+  ip link add $IFACE $BROPTS type bridge || exit 1
 # Wait for the ports to become available
   if [ "$IF_BRIDGE_WAITPORT" ]
   then
@@ -66,10 +70,6 @@
       if [ -x /etc/network/if-pre-up.d/vlan ]; then
         env IFACE=$port /etc/network/if-pre-up.d/vlan
       fi
-      if [ "$IF_BRIDGE_HW" ]
-      then
-         ifconfig $port down; ifconfig $port hw ether $IF_BRIDGE_HW
-      fi
       if [ -f /proc/sys/net/ipv6/conf/$port/disable_ipv6 ]
       then
         echo 1 > /proc/sys/net/ipv6/conf/$port/disable_ipv6

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to