[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH][RFC] network-bridge problems when specifying bridge name



I've noticed that network-bridge breaks networking when specifying a bridge name, e.g. "network-bridge start bridge=foo". On SLES10 SP2:

xen21# /etc/xen/scripts/network-bridge start bridge=mybr
eth1 device: Broadcom Corporation NetXtreme BCM5715 Gigabit Ethernet (rev a3)
   eth1      configuration: lcs-id-00:e0:81:80:1d:af
Nothing to flush.
Waiting for peth1 to negotiate link....
   mybr
             No configuration found for mybr
xen21# ifconfig
peth1     Link encap:Ethernet  HWaddr 00:E0:81:80:1D:AF
         inet6 addr: fe80::2e0:81ff:fe80:1daf/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:23 errors:0 dropped:0 overruns:0 frame:0
         TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:2354 (2.2 Kb)  TX bytes:344 (344.0 b)
         Interrupt:18
xen21# brctl show
bridge name     bridge id               STP enabled     interfaces
mybr               8000.00e081801daf       no              peth1
xen21# /etc/xen/scripts/network-bridge stop bridge=mybr
Device "peth0" does not exist.
Cannot find device "peth0"

And on Fedora 8:

[root]# /etc/xen/scripts/network-bridge start bridge=mybr
Nothing to flush.
Waiting for peth0 to negotiate link...SIOCGIFFLAGS: No such device
Error for wireless request "Set Encode" (8B2A) :
   SET failed on device eth0 ; No such device.
SIOCGIFFLAGS: No such device
Failed to bring up eth0.
[root]# ifconfig
peth0     Link encap:Ethernet  HWaddr 00:0D:56:BF:A6:EA
         inet6 addr: fe80::20d:56ff:febf:a6ea/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:4541070 errors:0 dropped:0 overruns:0 frame:0
         TX packets:292907 errors:742 dropped:0 overruns:0 carrier:742
         collisions:100893 txqueuelen:100
         RX bytes:1097742528 (1.0 GiB)  TX bytes:21013371 (20.0 MiB)
         Base address:0xdcc0 Memory:ff6e0000-ff700000
[root]# brctl show
bridge name     bridge id               STP enabled     interfaces
mybr                8000.000d56bfa6ea       no              peth0
[root]# /etc/xen/scripts/network-bridge stop bridge=mybr
Device "p" does not exist.
Cannot find device "p"

I've spun an initial patch to address this problem on these platforms when the net device contains static configuration. dhcp configured net devices are a little more troublesome since dhcp is handled differently between the various distros, e.g. SuSE uses if[up|down]-dhcp. The dhcp client daemon must be started on the bridge in order to renew leases.

Comments and suggestion are certainly welcome :-). I question whether specification of bridge name should be permitted as all sorts of unforeseen issues may arise from what is essentially a device rename, e.g. dhcp client daemon problem noted above, firewall rules, heartbeat config files that specify net device name, ... On the other hand, there are probably a lot of custom network-bridge wrappers containing

/etc/xen/scripts/network-bridge start netdev=eth0 bridge=xenbr0
/etc/xen/scripts/network-bridge start netdev=eth1 bridge=xenbr1
..

TIA,
Jim





diff -r 483d006cc607 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Fri Apr 25 13:46:27 2008 +0100
+++ b/tools/examples/network-bridge     Mon Apr 28 22:36:23 2008 -0600
@@ -72,6 +72,9 @@ find_alt_device () {
     echo "$ifs"
 }
 
+if [ $bridge ]; then
+    namedbr=$bridge
+fi
 netdev=${netdev:-$(ip route list 0.0.0.0/0  | \
                    sed 's/.*dev \([a-z]\+[0-9]\+\).*$/\1/')}
 if is_network_root ; then
@@ -198,6 +201,42 @@ show_status () {
     echo '============================================================'
 }
 
+op_start_named_bridge () {
+    if link_exists "$bridge"; then
+        # The device is already up.
+        return
+    fi
+
+    create_bridge ${bridge}
+
+    preiftransfer ${netdev}
+    transfer_addrs ${netdev} ${bridge}
+    get_ip_info ${netdev}
+    ip addr flush ${netdev} > /dev/null 2>&1
+    brctl addif ${bridge} ${netdev}
+    do_ifup ${bridge}
+
+    if [ ${antispoof} = 'yes' ] ; then
+       antispoofing
+    fi
+}
+
+op_stop_named_bridge () {
+    if ! link_exists "$bridge"; then
+       return
+    fi
+
+    transfer_addrs ${bridge} ${netdev}
+    get_ip_info ${bridge}
+    ip link set ${netdev} down
+    ip addr flush ${bridge}
+    
+    brctl delif ${bridge} ${netdev}
+    ip link set ${bridge} down
+    do_ifup ${netdev}
+    brctl delbr ${bridge}
+}
+
 op_start () {
     if [ "${bridge}" = "null" ] ; then
        return
@@ -281,11 +320,19 @@ add_to_bridge2() {
 
 case "$command" in
     start)
-       op_start
+       if [ $namedbr ]; then
+           op_start_named_bridge
+       else
+           op_start
+       fi
        ;;
     
     stop)
-       op_stop
+       if [ $namedbr ]; then
+           op_stop_named_bridge
+       else
+           op_stop
+       fi
        ;;
 
     status)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.