From 2776e4086038071f25e67579fc4215ef95ea26a6 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Fri, 28 Jan 2011 16:53:06 -0800 Subject: [PATCH] xenserver: Allow LACP configuration from xapi. Makes required changes to interface reconfigure to allow LACP configuration from xapi. Conforms to XenServer style bonding configuration which is slightly different from OVS. Signed-off-by: Ethan Jackson Bug #4213. --- tests/interface-reconfigure.at | 4 +-- ..._xensource_libexec_InterfaceReconfigure.py | 3 +- ...urce_libexec_InterfaceReconfigureBridge.py | 1 + ...rce_libexec_InterfaceReconfigureVswitch.py | 28 +++++++++++++++---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at index 9b478382..bb7eff76 100644 --- a/tests/interface-reconfigure.at +++ b/tests/interface-reconfigure.at @@ -809,7 +809,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi1 configuration --may-exist add-br xapi1 --with-iface --if-exists del-port bond0 --fake-iface add-bond xapi1 bond0 eth0 eth1 - set Port bond0 MAC="00:22:19:22:4b:af" bond_downdelay=200 other-config:bond-miimon-interval=100 other-config:bond-detect-mode=carrier bond_mode=balance-slb bond_updelay=31000 + set Port bond0 MAC="00:22:19:22:4b:af" other-config:bond-miimon-interval=100 bond_downdelay=200 bond_updelay=31000 other-config:bond-detect-mode=carrier lacp=off bond_mode=balance-slb set Bridge xapi1 other-config:hwaddr="00:22:19:22:4b:af" set Bridge xapi1 fail_mode=standalone br-set-external-id xapi1 xs-network-uuids 45cbbb43-113d-a712-3231-c6463f253cef;99be2da4-6c33-6f8e-49ea-3bc592fe3c85 @@ -891,7 +891,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi2 configuration --may-exist add-br xapi1 --with-iface --if-exists del-port bond0 --fake-iface add-bond xapi1 bond0 eth0 eth1 - set Port bond0 MAC="00:22:19:22:4b:af" bond_downdelay=200 other-config:bond-miimon-interval=100 other-config:bond-detect-mode=carrier bond_mode=balance-slb bond_updelay=31000 + set Port bond0 MAC="00:22:19:22:4b:af" other-config:bond-miimon-interval=100 bond_downdelay=200 bond_updelay=31000 other-config:bond-detect-mode=carrier lacp=off bond_mode=balance-slb set Bridge xapi1 other-config:hwaddr="00:22:19:22:4b:af" set Bridge xapi1 fail_mode=standalone br-set-external-id xapi1 xs-network-uuids 45cbbb43-113d-a712-3231-c6463f253cef;99be2da4-6c33-6f8e-49ea-3bc592fe3c85 diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py index e99ae583..68f7204c 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py @@ -282,7 +282,8 @@ _POOL_XML_TAG = "pool" _ETHTOOL_OTHERCONFIG_ATTRS = ['ethtool-%s' % x for x in 'autoneg', 'speed', 'duplex', 'rx', 'tx', 'sg', 'tso', 'ufo', 'gso' ] _PIF_OTHERCONFIG_ATTRS = [ 'domain', 'peerdns', 'defaultroute', 'mtu', 'static-routes' ] + \ - [ 'bond-%s' % x for x in 'mode', 'miimon', 'downdelay', 'updelay', 'use_carrier' ] + \ + [ 'bond-%s' % x for x in 'mode', 'miimon', 'downdelay', + 'updelay', 'use_carrier', 'hashing-algorithm' ] + \ _ETHTOOL_OTHERCONFIG_ATTRS _PIF_ATTRS = { 'uuid': (_str_to_xml,_str_from_xml), diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py index 28a70b6a..8803122d 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py @@ -349,6 +349,7 @@ def _configure_bond_interface(pif): "downdelay": "200", "updelay": "31000", "use_carrier": "1", + "hashing-algorithm": "src_mac", } # override defaults with values from other-config whose keys being with "bond-" diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py index 9e069f30..33beb76c 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py @@ -147,6 +147,7 @@ def datapath_configure_bond(pif,slaves): "downdelay": "200", "updelay": "31000", "use_carrier": "1", + "hashing-algorithm": "src_mac", } # override defaults with values from other-config whose keys # being with "bond-" @@ -155,6 +156,8 @@ def datapath_configure_bond(pif,slaves): key.startswith("bond-"), oc.items()) overrides = map(lambda (key,val): (key[5:], val), overrides) bond_options.update(overrides) + mode = None + halgo = None argv += ['--', 'set', 'Port', interface] if pifrec['MAC'] != "": @@ -188,15 +191,30 @@ def datapath_configure_bond(pif,slaves): except ValueError: log("bridge %s has invalid %s '%s'" % (bridge, name, value)) elif name == "mode": - - if val in ['balance-slb', 'active-backup']: - argv += ['bond_%s=%s' % (name, val)] - else: - log("bridge %s has invalid %s '%s'" % (bridge, name, val)) + mode = val + elif name == "hashing-algorithm": + halgo = val else: # Pass other bond options into other_config. argv += ["other-config:%s=%s" % (vsctl_escape("bond-%s" % name), vsctl_escape(val))] + + if mode == 'lacp': + argv += ['lacp=active'] + + if halgo == 'src_mac': + argv += ['bond_mode=balance-slb'] + elif halgo == "tcpudp_ports": + argv += ['bond_mode=balance-tcp'] + else: + log("bridge %s has invalid bond-hashing-algorithm '%s'" % (bridge, halgo)) + argv += ['bond_mode=balance-slb'] + elif mode in ['balance-slb', 'active-backup']: + argv += ['lacp=off', 'bond_mode=%s' % mode] + else: + log("bridge %s has invalid bond-mode '%s'" % (bridge, mode)) + argv += ['lacp=off', 'bond_mode=balance-slb'] + return argv def datapath_deconfigure_bond(netdev): -- 2.30.2