summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-03 22:23:38 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-04 11:25:31 +0200
commit0d156a3947981e71774359b4566ac2af5892abe9 (patch)
tree2ae1c8595054efc46a3cf4cac236eade96ed7265 /src
parentda2bb10b8e4c15aaf993fc82eb0f9b8c564a2113 (diff)
downloadvyos-1x-0d156a3947981e71774359b4566ac2af5892abe9.tar.gz
vyos-1x-0d156a3947981e71774359b4566ac2af5892abe9.zip
bonding: T1614: add vif-c VLAN interface support
Tested using: ============= set interfaces bonding bond0 address 192.0.2.1/24 set interfaces bonding bond0 description "VyOS bonding" set interfaces bonding bond0 disable-link-detect set interfaces bonding bond0 hash-policy layer2+3 set interfaces bonding bond0 ip arp-cache-timeout 86400 set interfaces bonding bond0 mac 00:91:00:00:00:01 set interfaces bonding bond0 mode active-backup set interfaces bonding bond0 mtu 9000 set interfaces bonding bond0 member interface eth1 set interfaces bonding bond0 member interface eth2 set interfaces bonding bond0 vif-s 100 address 192.168.10.1/24 set interfaces bonding bond0 vif-s 100 description "802.1ad service VLAN 100" set interfaces bonding bond0 vif-s 100 mtu 1500 set interfaces bonding bond0 vif-s 100 mac 00:91:00:00:00:02 set interfaces bonding bond0 vif-s 100 vif-c 110 address "192.168.110.1/24" set interfaces bonding bond0 vif-s 100 vif-c 110 description "client VLAN 110" set interfaces bonding bond0 vif-s 100 vif-c 120 address "192.168.120.1/24" set interfaces bonding bond0 vif-s 100 vif-c 120 description "client VLAN 120" set interfaces bonding bond0 vif-s 100 vif-c 130 address "192.168.130.1/24" set interfaces bonding bond0 vif-s 100 vif-c 130 description "client VLAN 130" set interfaces bonding bond0 vif 400 address 192.168.40.1/24 set interfaces bonding bond0 vif 400 description "802.1q VLAN 400" set interfaces bonding bond0 vif 400 mtu 1500 set interfaces bonding bond0 vif 400 mac 00:91:00:00:00:03
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interface-bonding.py65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py
index c2f0086aa..b01018e5b 100755
--- a/src/conf_mode/interface-bonding.py
+++ b/src/conf_mode/interface-bonding.py
@@ -145,33 +145,41 @@ def vlan_to_dict(conf):
if conf.exists('disable'):
vlan['disable'] = True
+ # Media Access Control (MAC) address
+ if conf.exists('mac'):
+ vlan['mac'] = conf.return_value('mac')
+
+ # Maximum Transmission Unit (MTU)
+ if conf.exists('mtu'):
+ vlan['mtu'] = int(conf.return_value('mtu'))
+
# ethertype is mandatory on vif-s nodes and only exists here!
# check if this is a vif-s node at all:
if conf.get_level().split()[-2] == 'vif-s':
+ vlan['vif_c'] = []
+ vlan['vif_c_remove'] = []
+
# ethertype uses a default of 0x88A8
tmp = '0x88A8'
if conf.exists('ethertype'):
tmp = conf.return_value('ethertype')
vlan['ethertype'] = get_ethertype(tmp)
- # Media Access Control (MAC) address
- if conf.exists('mac'):
- vlan['mac'] = conf.return_value('mac')
-
- # Maximum Transmission Unit (MTU)
- if conf.exists('mtu'):
- vlan['mtu'] = int(conf.return_value('mtu'))
-
- # check if there is a Q-in-Q vlan customer interface
- # and call this function recursively
- if conf.exists('vif-c'):
- cfg_level = conf.get_level()
- # add new key (vif-c) to dictionary
- vlan['vif-c'] = []
- for vif in conf.list_nodes('vif-c'):
- # set config level to vif interface
- conf.set_level(cfg_level + ' vif-c ' + vif)
- vlan['vif-c'].append(vlan_to_dict(conf))
+ # get vif-c interfaces (currently effective) - to determine which vif-c
+ # interface is no longer present and needs to be removed
+ eff_intf = conf.list_effective_nodes('vif-c')
+ act_intf = conf.list_nodes('vif-c')
+ vlan['vif_c_remove'] = diff(eff_intf, act_intf)
+
+ # check if there is a Q-in-Q vlan customer interface
+ # and call this function recursively
+ if conf.exists('vif-c'):
+ cfg_level = conf.get_level()
+ # add new key (vif-c) to dictionary
+ for vif in conf.list_nodes('vif-c'):
+ # set config level to vif interface
+ conf.set_level(cfg_level + ' vif-c ' + vif)
+ vlan['vif_c'].append(vlan_to_dict(conf))
return vlan
@@ -309,7 +317,7 @@ def get_config():
if conf.exists('member interface'):
bond['member'] = conf.return_values('member interface')
- # Determine interface addresses (currently effective) - to determine which
+ # get interface addresses (currently effective) - to determine which
# address is no longer valid and needs to be removed from the bond
eff_addr = conf.return_effective_values('address')
act_addr = conf.return_values('address')
@@ -321,8 +329,8 @@ def get_config():
# re-set configuration level and retrieve vif-s interfaces
conf.set_level(cfg_base)
- # Determine vif-s interfaces (currently effective) - to determine which
- # vif-s interface is no longer present and needs to be removed
+ # get vif-s interfaces (currently effective) - to determine which vif-s
+ # interface is no longer present and needs to be removed
eff_intf = conf.list_effective_nodes('vif-s')
act_intf = conf.list_nodes('vif-s')
bond['vif_s_remove'] = diff(eff_intf, act_intf)
@@ -458,8 +466,19 @@ def apply(bond):
# create service VLAN interfaces (vif-s)
for vif_s in bond['vif_s']:
- vlan = b.add_vlan(vif_s['id'], ethertype=vif_s['ethertype'])
- apply_vlan_config(vlan, vif_s)
+ s_vlan = b.add_vlan(vif_s['id'], ethertype=vif_s['ethertype'])
+ apply_vlan_config(s_vlan, vif_s)
+
+ # remove no longer required client VLAN interfaces (vif-c)
+ # on lower service VLAN interface
+ for vif_c in vif_s['vif_c_remove']:
+ s_vlan.del_vlan(vif_c)
+
+ # create client VLAN interfaces (vif-c)
+ # on lower service VLAN interface
+ for vif_c in vif_s['vif_c']:
+ c_vlan = s_vlan.add_vlan(vif_c['id'])
+ apply_vlan_config(c_vlan, vif_c)
# remove no longer required VLAN interfaces (vif)
for vif in bond['vif_remove']: