summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-03-09 19:38:34 +0100
committerGitHub <noreply@github.com>2023-03-09 19:38:34 +0100
commit0f3710927eaba4f855119a86046c5e2a5eb76d8b (patch)
treebe72879f80f4965b5a552c56ee64391af8122bf3
parent3c6e20b3bb54d7efb001e7578629b0d4275bbc36 (diff)
parentc3039903aff9f2c3cb33f4fdd9e9634aa9f09997 (diff)
downloadvyos-1x-0f3710927eaba4f855119a86046c5e2a5eb76d8b.tar.gz
vyos-1x-0f3710927eaba4f855119a86046c5e2a5eb76d8b.zip
Merge pull request #1881 from sarthurdev/qos_fix
qos: T5018: Fix issues between QoS and interface mirror/redirect
-rw-r--r--data/config-mode-dependencies.json20
-rw-r--r--python/vyos/configdict.py13
-rwxr-xr-xsrc/conf_mode/qos.py16
3 files changed, 49 insertions, 0 deletions
diff --git a/data/config-mode-dependencies.json b/data/config-mode-dependencies.json
index 9e943ba2c..ccee359d1 100644
--- a/data/config-mode-dependencies.json
+++ b/data/config-mode-dependencies.json
@@ -8,5 +8,25 @@
"ipsec": ["vpn_ipsec"],
"openconnect": ["vpn_openconnect"],
"sstp": ["vpn_sstp"]
+ },
+ "qos": {
+ "bonding": ["interfaces-bonding"],
+ "bridge": ["interfaces-bridge"],
+ "dummy": ["interfaces-dummy"],
+ "ethernet": ["interfaces-ethernet"],
+ "geneve": ["interfaces-geneve"],
+ "input": ["interfaces-input"],
+ "l2tpv3": ["interfaces-l2tpv3"],
+ "loopback": ["interfaces-loopback"],
+ "macsec": ["interfaces-macsec"],
+ "openvpn": ["interfaces-openvpn"],
+ "pppoe": ["interfaces-pppoe"],
+ "pseudo-ethernet": ["interfaces-pseudo-ethernet"],
+ "tunnel": ["interfaces-tunnel"],
+ "vti": ["interfaces-vti"],
+ "vxlan": ["interfaces-vxlan"],
+ "wireguard": ["interfaces-wireguard"],
+ "wireless": ["interfaces-wireless"],
+ "wwan": ["interfaces-wwan"]
}
}
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index 53decfbf5..434ff99d7 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -427,6 +427,10 @@ def get_interface_dict(config, base, ifname=''):
# Add interface instance name into dictionary
dict.update({'ifname': ifname})
+ # Check if QoS policy applied on this interface - See ifconfig.interface.set_mirror_redirect()
+ if config.exists(['qos', 'interface', ifname]):
+ dict.update({'traffic_policy': {}})
+
# XXX: T2665: When there is no DHCPv6-PD configuration given, we can safely
# remove the default values from the dict.
if 'dhcpv6_options' not in dict:
@@ -498,6 +502,9 @@ def get_interface_dict(config, base, ifname=''):
# Add subinterface name to dictionary
dict['vif'][vif].update({'ifname' : f'{ifname}.{vif}'})
+ if config.exists(['qos', 'interface', f'{ifname}.{vif}']):
+ dict['vif'][vif].update({'traffic_policy': {}})
+
default_vif_values = defaults(base + ['vif'])
# XXX: T2665: When there is no DHCPv6-PD configuration given, we can safely
# remove the default values from the dict.
@@ -532,6 +539,9 @@ def get_interface_dict(config, base, ifname=''):
# Add subinterface name to dictionary
dict['vif_s'][vif_s].update({'ifname' : f'{ifname}.{vif_s}'})
+ if config.exists(['qos', 'interface', f'{ifname}.{vif_s}']):
+ dict['vif_s'][vif_s].update({'traffic_policy': {}})
+
default_vif_s_values = defaults(base + ['vif-s'])
# XXX: T2665: we only wan't the vif-s defaults - do not care about vif-c
if 'vif_c' in default_vif_s_values: del default_vif_s_values['vif_c']
@@ -571,6 +581,9 @@ def get_interface_dict(config, base, ifname=''):
# Add subinterface name to dictionary
dict['vif_s'][vif_s]['vif_c'][vif_c].update({'ifname' : f'{ifname}.{vif_s}.{vif_c}'})
+ if config.exists(['qos', 'interface', f'{ifname}.{vif_s}.{vif_c}']):
+ dict['vif_s'][vif_s]['vif_c'][vif_c].update({'traffic_policy': {}})
+
default_vif_c_values = defaults(base + ['vif-s', 'vif-c'])
# XXX: T2665: When there is no DHCPv6-PD configuration given, we can safely
diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py
index dca713283..1be2c283f 100755
--- a/src/conf_mode/qos.py
+++ b/src/conf_mode/qos.py
@@ -21,7 +21,9 @@ from netifaces import interfaces
from vyos.base import Warning
from vyos.config import Config
+from vyos.configdep import set_dependents, call_dependents
from vyos.configdict import dict_merge
+from vyos.ifconfig import Section
from vyos.qos import CAKE
from vyos.qos import DropTail
from vyos.qos import FairQueue
@@ -83,6 +85,18 @@ def get_config(config=None):
get_first_key=True,
no_tag_node_value_mangle=True)
+ if 'interface' in qos:
+ for ifname, if_conf in qos['interface'].items():
+ if_node = Section.get_config_path(ifname)
+
+ if not if_node:
+ continue
+
+ path = f'interfaces {if_node}'
+ if conf.exists(f'{path} mirror') or conf.exists(f'{path} redirect'):
+ type_node = path.split(" ")[1] # return only interface type node
+ set_dependents(type_node, conf, ifname)
+
if 'policy' in qos:
for policy in qos['policy']:
# when calling defaults() we need to use the real CLI node, thus we
@@ -245,6 +259,8 @@ def apply(qos):
tmp = shaper_type(interface)
tmp.update(shaper_config, direction)
+ call_dependents()
+
return None
if __name__ == '__main__':