1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

Move clag_enable setting to ifupdown2 ifenslave.

Ticket: CM-4802
Reviewed By:
Testing Done: yes

1. clag_enable needs to be set before slaves are added to the bond. Otherwise
bonding driver will bring the slaves up independent of clagd.
2. also added post_down clagd addon to cleanup the clag-id on ifdown.
This commit is contained in:
anuradhak
2015-02-02 09:54:53 -08:00
parent 67b8126335
commit ff01349dd4
3 changed files with 22 additions and 1 deletions

View File

@@ -246,6 +246,11 @@ class ifenslave(moduleBase):
ifaceobj.link_type != ifaceLinkType.LINK_NA):
rtnetlink_api.rtnl_api.link_set(slave, "up")
def _set_clag_enable(self, ifaceobj):
attrval = ifaceobj.get_attr_value_first('clag-id')
attrval = attrval if attrval else '0'
self.ifenslavecmd.set_clag_enable(ifaceobj.name, attrval)
def _apply_slaves_lacp_bypass_prio(self, ifaceobj):
slaves = self.ifenslavecmd.get_slaves(ifaceobj.name)
if not slaves:
@@ -285,6 +290,8 @@ class ifenslave(moduleBase):
if not self.ipcmd.link_exists(ifaceobj.name):
self.ifenslavecmd.create_bond(ifaceobj.name)
self._apply_master_settings(ifaceobj)
# clag_enable has to happen before the slaves are added to the bond
self._set_clag_enable(ifaceobj)
self._add_slaves(ifaceobj)
self._apply_slaves_lacp_bypass_prio(ifaceobj)
if ifaceobj.addr_method == 'manual':

View File

@@ -18,6 +18,7 @@ down,dhcp
down,addressvirtual
down,address
down,usercmds
post-down,clagd
post-down,mstpctl
post-down,bridgevlan
post-down,bridge

View File

@@ -53,7 +53,8 @@ class ifenslaveutil(utilsBase):
self.read_file_oneline('/sys/class/net/%s/bonding/%s'
%(bondname, x))),
['use_carrier', 'miimon', 'min_links', 'num_unsol_na',
'num_grat_arp', 'lacp_bypass_allow', 'lacp_bypass_period'])
'num_grat_arp', 'lacp_bypass_allow', 'lacp_bypass_period',
'clag_enable'])
except Exception, e:
pass
@@ -191,6 +192,18 @@ class ifenslaveutil(utilsBase):
def get_miimon(self, bondname):
return self._cache_get([bondname, 'linkinfo', 'miimon'])
def set_clag_enable(self, bondname, clag_id):
clag_enable = '0' if clag_id == '0' else '1'
if self._cache_check([bondname, 'linkinfo', 'clag_enable'],
clag_enable) == False:
self.write_file('/sys/class/net/%s' %bondname +
'/bonding/clag_enable', clag_enable)
self._cache_update([bondname, 'linkinfo', 'clag_enable'],
clag_enable)
def get_clag_enable(self, bondname):
return self._cache_get([bondname, 'linkinfo', 'clag_enable'])
def set_mode(self, bondname, mode, prehook=None):
valid_modes = ['balance-rr', 'active-backup', 'balance-xor',
'broadcast', '802.3ad', 'balance-tlb', 'balance-alb']