From abc7060ddcca0315682427a1e38faed8cfa01796 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 7 Mar 2026 22:33:02 +0100 Subject: vyos.ifconfig: T8358: clear qdiscs when deleting mirror CLI node When removing the mirror CLI node to stop mirroring or redirecting traffic to another interface, the egress configuration was not cleared. This caused traffic to continue being sent out the SPAN port even after the node was removed. Fix by properly clearing all tc(8) qdiscs. Update smoketests to verify nothing remains after mirror deletion. --- python/vyos/ifconfig/interface.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 33b643e7e..a416de1ab 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -1617,7 +1617,7 @@ class Interface(Control): if 'netns' in self.config: return None - source_if = self.config['ifname'] + source_if = self.ifname mirror_config = None if 'mirror' in self.config: @@ -1631,8 +1631,8 @@ class Interface(Control): # clear existing ingess - ignore errors (e.g. "Error: Cannot find specified # qdisc on specified device") - we simply cleanup all stuff here if not 'qos' in self.config: - self._popen(f'tc qdisc del dev {source_if} parent ffff: 2>/dev/null'); - self._popen(f'tc qdisc del dev {source_if} parent 1: 2>/dev/null'); + self._popen(f'tc qdisc del dev {source_if} root 2>/dev/null') + self._popen(f'tc qdisc del dev {source_if} ingress 2>/dev/null') # Apply interface mirror policy if mirror_config: @@ -1644,14 +1644,14 @@ class Interface(Control): handle = '1: root prio' parent = '1:' - # Mirror egress traffic + # Mirror traffic mirror_cmd = f'tc qdisc add dev {source_if} handle {handle}; ' # Export the mirrored traffic to the interface mirror_cmd += f'tc filter add dev {source_if} parent {parent} protocol '\ f'all prio 10 u32 match u32 0 0 flowid 1:1 action mirred '\ f'egress mirror dev {target_if}' _, err = self._popen(mirror_cmd) - if err: print('tc qdisc(filter for mirror port failed') + if err: print('tc filter for mirror port failed') # Apply interface traffic redirection policy elif 'redirect' in self.config: @@ -1662,7 +1662,7 @@ class Interface(Control): _, err = self._popen(f'tc filter add dev {source_if} parent ffff: protocol '\ f'all prio 10 u32 match u32 0 0 flowid 1:1 action mirred '\ f'egress redirect dev {target_if}') - if err: print('tc filter add for redirect failed') + if err: print('tc filter for redirect failed') def set_per_client_thread(self, enable): """ -- cgit v1.2.3