diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-08 18:48:31 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-20 21:28:53 +0200 |
commit | bebb43450fcca4c086ab1a64be6919441c7c0032 (patch) | |
tree | 5e32091c3d1111b25cb1ce69902581ced3321ea6 /python/vyos | |
parent | a610e328750e3cfc23c29a2cafb40d7ef7082b13 (diff) | |
download | vyos-1x-bebb43450fcca4c086ab1a64be6919441c7c0032.tar.gz vyos-1x-bebb43450fcca4c086ab1a64be6919441c7c0032.zip |
Python/ifconfig: T1557: support VLAN {ingress,egress}-qos-mapping
ingress-qos-map - defines a mapping of VLAN header prio field to the Linux
internal packet priority on incoming frames. The format is FROM:TO with
multiple mappings separated by spaces.
egress-qos-map - defines a mapping of Linux internal packet priority to VLAN
header prio field but for outgoing frames. The format is the same as for
ingress-qos-map.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/configdict.py | 22 | ||||
-rw-r--r-- | python/vyos/ifconfig.py | 22 |
2 files changed, 40 insertions, 4 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 4bc8863bb..1c9cf6897 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -116,6 +116,10 @@ def vlan_to_dict(conf): 'dhcpv6_temporary': False, 'disable': False, 'disable_link_detect': 1, + 'egress_qos': '', + 'egress_qos_changed': False, + 'ingress_qos': '', + 'ingress_qos_changed': False, 'mac': '', 'mtu': 1500 } @@ -153,7 +157,7 @@ def vlan_to_dict(conf): if conf.exists('disable-link-detect'): vlan['disable_link_detect'] = 2 - # disable bond interface + # disable VLAN interface if conf.exists('disable'): vlan['disable'] = True @@ -165,6 +169,22 @@ def vlan_to_dict(conf): if conf.exists('mtu'): vlan['mtu'] = int(conf.return_value('mtu')) + # VLAN egress QoS + if conf.exists('egress-qos'): + vlan['egress_qos'] = conf.return_value('egress-qos') + + # egress changes QoS require VLAN interface recreation + if vlan['egress_qos'] != conf.return_effective_value('egress-qos'): + vlan['egress_qos_changed'] = True + + # VLAN ingress QoS + if conf.exists('ingress-qos'): + vlan['ingress_qos'] = conf.return_value('ingress-qos') + + # ingress changes QoS require VLAN interface recreation + if vlan['ingress_qos'] != conf.return_effective_value('ingress-qos'): + vlan['ingress_qos_changed'] = True + # 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': diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 7181ff42f..80b5592c2 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1005,7 +1005,7 @@ class VLANIf(Interface): def __init__(self, ifname, type=None): super().__init__(ifname, type) - def add_vlan(self, vlan_id, ethertype=''): + def add_vlan(self, vlan_id, ethertype='', ingress_qos='', egress_qos=''): """ A virtual LAN (VLAN) is any broadcast domain that is partitioned and isolated in a computer network at the data link layer (OSI layer 2). @@ -1017,6 +1017,13 @@ class VLANIf(Interface): A new object of type VLANIf is returned once the interface has been created. + + @param ethertype: If specified, create 802.1ad or 802.1q Q-in-Q VLAN + interface + @param ingress_qos: Defines a mapping of VLAN header prio field to the + Linux internal packet priority on incoming frames. + @param ingress_qos: Defines a mapping of Linux internal packet priority + to VLAN header prio field but for outgoing frames. """ vlan_ifname = self._ifname + '.' + str(vlan_id) if not os.path.exists('/sys/class/net/{}'.format(vlan_ifname)): @@ -1026,9 +1033,18 @@ class VLANIf(Interface): self._ethertype = ethertype ethertype = 'proto {}'.format(ethertype) + # Optional ingress QOS mapping + opt_i = '' + if ingress_qos: + opt_i = 'ingress-qos-map ' + ingress_qos + # Optional egress QOS mapping + opt_e = '' + if egress_qos: + opt_e = 'egress-qos-map ' + egress_qos + # create interface in the system - cmd = 'ip link add link {intf} name {intf}.{vlan} type vlan {proto} id {vlan}'.format( - intf=self._ifname, vlan=self._vlan_id, proto=ethertype) + cmd = 'ip link add link {intf} name {intf}.{vlan} type vlan {proto} id {vlan} {opt_e} {opt_i}' \ + .format(intf=self._ifname, vlan=self._vlan_id, proto=ethertype, opt_e=opt_e, opt_i=opt_i) self._cmd(cmd) # return new object mapping to the newly created interface |