summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-07-24 17:18:45 +0200
committerChristian Poessinger <christian@poessinger.com>2020-07-25 15:36:44 +0200
commitadd7eaebe7b8ebd4e143eb939d3ba7871ead0502 (patch)
tree4aaf42dbb7a4fdd1af3b5cd743a05b2db6ac9cec
parent0d21de93ce02fb0ae6e2e3ceb13dfd5b8dbe755f (diff)
downloadvyos-1x-add7eaebe7b8ebd4e143eb939d3ba7871ead0502.tar.gz
vyos-1x-add7eaebe7b8ebd4e143eb939d3ba7871ead0502.zip
ifconfig: T2653: move vlan configuration code to base class
This is required as other interfaces (e.g. pseudo-ethernet or bond) will have VLANs, too.
-rw-r--r--python/vyos/ifconfig/ethernet.py29
-rw-r--r--python/vyos/ifconfig/interface.py28
2 files changed, 28 insertions, 29 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index 77128633d..b2f701e00 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -17,7 +17,6 @@ import os
import re
import jmespath
-from vyos.configdict import get_ethertype
from vyos.ifconfig.interface import Interface
from vyos.ifconfig.vlan import VLAN
from vyos.validate import assert_list
@@ -299,34 +298,6 @@ class EthernetIf(Interface):
duplex = config.get('duplex')
self.set_speed_duplex(speed, duplex)
- # remove no longer required 802.1ad (Q-in-Q VLANs)
- for vif_s_id in config.get('vif_s_remove', {}):
- self.del_vlan(vif_s_id)
-
- # create/update 802.1ad (Q-in-Q VLANs)
- for vif_s_id, vif_s in config.get('vif_s', {}).items():
- tmp=get_ethertype(vif_s.get('ethertype', '0x88A8'))
- s_vlan = self.add_vlan(vif_s_id, ethertype=tmp)
- s_vlan.update(vif_s)
-
- # remove no longer required client VLAN (vif-c)
- for vif_c_id in vif_s.get('vif_c_remove', {}):
- s_vlan.del_vlan(vif_c_id)
-
- # create/update client VLAN (vif-c) interface
- for vif_c_id, vif_c in vif_s.get('vif_c', {}).items():
- c_vlan = s_vlan.add_vlan(vif_c_id)
- c_vlan.update(vif_c)
-
- # remove no longer required 802.1q VLAN interfaces
- for vif_id in config.get('vif_remove', {}):
- self.del_vlan(vif_id)
-
- # create/update 802.1q VLAN interfaces
- for vif_id, vif in config.get('vif', {}).items():
- vlan = self.add_vlan(vif_id)
- vlan.update(vif)
-
# Enable/Disable of an interface must always be done at the end of the
# derived class to make use of the ref-counting set_admin_state()
# function. We will only enable the interface if 'up' was called as
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 5942904b5..1fe4f74f2 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -31,6 +31,7 @@ from netifaces import AF_INET6
from vyos import ConfigError
from vyos.configdict import list_diff
+from vyos.configdict import get_ethertype
from vyos.util import mac2eui64
from vyos.validate import is_ipv4
from vyos.validate import is_ipv6
@@ -951,3 +952,30 @@ class Interface(Control):
bridge = config.get('is_bridge_member')
self.add_to_bridge(bridge)
+ # remove no longer required 802.1ad (Q-in-Q VLANs)
+ for vif_s_id in config.get('vif_s_remove', {}):
+ self.del_vlan(vif_s_id)
+
+ # create/update 802.1ad (Q-in-Q VLANs)
+ for vif_s_id, vif_s in config.get('vif_s', {}).items():
+ tmp=get_ethertype(vif_s.get('ethertype', '0x88A8'))
+ s_vlan = self.add_vlan(vif_s_id, ethertype=tmp)
+ s_vlan.update(vif_s)
+
+ # remove no longer required client VLAN (vif-c)
+ for vif_c_id in vif_s.get('vif_c_remove', {}):
+ s_vlan.del_vlan(vif_c_id)
+
+ # create/update client VLAN (vif-c) interface
+ for vif_c_id, vif_c in vif_s.get('vif_c', {}).items():
+ c_vlan = s_vlan.add_vlan(vif_c_id)
+ c_vlan.update(vif_c)
+
+ # remove no longer required 802.1q VLAN interfaces
+ for vif_id in config.get('vif_remove', {}):
+ self.del_vlan(vif_id)
+
+ # create/update 802.1q VLAN interfaces
+ for vif_id, vif in config.get('vif', {}).items():
+ vlan = self.add_vlan(vif_id)
+ vlan.update(vif)