From e8957b575b050b075b74c94c3352d253414f4a6f Mon Sep 17 00:00:00 2001 From: jack9603301 Date: Tue, 8 Dec 2020 15:12:13 +0800 Subject: mirror: T3089: support two-way traffic mirroring --- smoketest/scripts/cli/base_interfaces_test.py | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'smoketest/scripts/cli') diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py index 4187fd77c..d1bb9c3fe 100644 --- a/smoketest/scripts/cli/base_interfaces_test.py +++ b/smoketest/scripts/cli/base_interfaces_test.py @@ -28,6 +28,22 @@ from vyos.util import dict_search from vyos.validate import is_intf_addr_assigned from vyos.validate import is_ipv6_link_local +def read_mirror_rule(interfaces): + Success = 0 + for interface in interfaces: + get_tc_cmd = 'tc -j qdisc' + tmp = cmd(get_tc_cmd, shell=True) + data = json.loads(tmp) + for rule in data: + dev = rule['dev'] + handle = rule['handle'] + kind = rule['kind'] + if dev == interface and handle == "ffff:" and kind == "ingress": + Success+=1 + elif dev == interface and handle == "1:" and kind == "prio": + Success+=1 + return Success + class BasicInterfaceTest: class BaseTest(unittest.TestCase): _test_ip = False @@ -73,25 +89,19 @@ class BasicInterfaceTest: Success = 0 i = 0 if self._test_mirror: + # Check the two-way mirror rules of ingress and egress for interface in self._interfaces: - self.session.set(self._base_path + [interface, 'mirror', 'lo']) + self.session.set(self._base_path + [interface, 'mirror', 'ingress', 'lo']) + self.session.set(self._base_path + [interface, 'mirror', 'egress', 'lo']) i+=1 self.session.commit() # Parse configuration - for interface in self._interfaces: - get_tc_cmd = 'tc -j qdisc' - tmp = cmd(get_tc_cmd, shell=True) - data = json.loads(tmp) - for rule in data: - dev = rule['dev'] - handle = rule['handle'] - kind = rule['kind'] - if dev == interface and handle == "ffff:" and kind == "ingress": - Success+=1 - if Success == i: + Success = read_mirror_rule(self._interfaces) + if Success == i*2: self.assertTrue(True) else: self.assertTrue(False) + i=0 else: return None -- cgit v1.2.3