From 7da16c0493fa98a071cd1035c0621e9331fbfd8d Mon Sep 17 00:00:00 2001 From: "wenda.ni" Date: Wed, 7 Jul 2021 03:49:53 +0800 Subject: [PATCH 01/27] erspan ipv6 underlay Signed-off-by: wenda.ni --- orchagent/mirrororch.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index 37c2ef73df..a06c6163b4 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -34,7 +34,8 @@ #define MIRROR_SESSION_DEFAULT_VLAN_PRI 0 #define MIRROR_SESSION_DEFAULT_VLAN_CFI 0 -#define MIRROR_SESSION_DEFAULT_IP_HDR_VER 4 +#define MIRROR_SESSION_IP_HDR_VER_4 4 +#define MIRROR_SESSION_IP_HDR_VER_6 6 #define MIRROR_SESSION_DSCP_SHIFT 2 #define MIRROR_SESSION_DSCP_MIN 0 #define MIRROR_SESSION_DSCP_MAX 63 @@ -343,7 +344,7 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector Date: Tue, 6 Jul 2021 22:38:01 +0000 Subject: [PATCH 02/27] Introduce src, dst ips Signed-off-by: Wenda Ni --- tests/test_mirror.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index f74ff6fa0d..4190a96eaa 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -122,12 +122,14 @@ def test_MirrorAddRemove(self, dvs, testlog): self.setup_db(dvs) session = "TEST_SESSION" + src_ip = "1.1.1.1" + dst_ip = "2.2.2.2" marker = dvs.add_log_marker() # create mirror session - self.create_mirror_session(session, "1.1.1.1", "2.2.2.2", "0x6558", "8", "100", "0") + self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" - self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP 2.2.2.2", 1) + self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP {}".format(dst_ip), 1) # bring up Ethernet16 self.set_interface_status(dvs, "Ethernet16", "up") @@ -170,9 +172,9 @@ def test_MirrorAddRemove(self, dvs, testlog): elif fv[0] == "SAI_MIRROR_SESSION_ATTR_TTL": assert fv[1] == "100" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_SRC_IP_ADDRESS": - assert fv[1] == "1.1.1.1" + assert fv[1] == src_ip elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_IP_ADDRESS": - assert fv[1] == "2.2.2.2" + assert fv[1] == dst_ip elif fv[0] == "SAI_MIRROR_SESSION_ATTR_SRC_MAC_ADDRESS": assert fv[1] == dvs.runcmd("bash -c \"ip link show eth0 | grep ether | awk '{print $2}'\"")[1].strip().upper() elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": @@ -183,7 +185,7 @@ def test_MirrorAddRemove(self, dvs, testlog): assert False # remove route - self.remove_route(dvs, "2.2.2.2") + self.remove_route(dvs, dst_ip) assert self.get_mirror_session_state(session)["status"] == "inactive" # remove neighbor @@ -201,7 +203,7 @@ def test_MirrorAddRemove(self, dvs, testlog): marker = dvs.add_log_marker() # remove mirror session self.remove_mirror_session(session) - self.check_syslog(dvs, marker, "Detached next hop observer for destination IP 2.2.2.2", 1) + self.check_syslog(dvs, marker, "Detached next hop observer for destination IP {}".format(dst_ip), 1) def create_vlan(self, dvs, vlan): #dvs.runcmd("ip link del Bridge") From 0c797828939f78e930797726899c2d3486e9b75e Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 6 Jul 2021 22:42:49 +0000 Subject: [PATCH 03/27] Introduce interface address Signed-off-by: Wenda Ni --- tests/test_mirror.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 4190a96eaa..fb6c335006 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -124,6 +124,7 @@ def test_MirrorAddRemove(self, dvs, testlog): session = "TEST_SESSION" src_ip = "1.1.1.1" dst_ip = "2.2.2.2" + intf_addr = "10.0.0.0/31" marker = dvs.add_log_marker() # create mirror session @@ -136,7 +137,7 @@ def test_MirrorAddRemove(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "inactive" # add IP address to Ethernet16 - self.add_ip_address("Ethernet16", "10.0.0.0/31") + self.add_ip_address("Ethernet16", intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # add neighbor to Ethernet16 @@ -193,7 +194,7 @@ def test_MirrorAddRemove(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "inactive" # remove IP address - self.remove_ip_address("Ethernet16", "10.0.0.0/31") + self.remove_ip_address("Ethernet16", intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # bring down Ethernet16 From f60b974d20a9dcc7dd2fdcc446462f0f785155a7 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 6 Jul 2021 22:43:48 +0000 Subject: [PATCH 04/27] Introduce next hop ip Signed-off-by: Wenda Ni --- tests/test_mirror.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index fb6c335006..5cace72f2b 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -125,6 +125,7 @@ def test_MirrorAddRemove(self, dvs, testlog): src_ip = "1.1.1.1" dst_ip = "2.2.2.2" intf_addr = "10.0.0.0/31" + nhop_ip = "10.0.0.1" marker = dvs.add_log_marker() # create mirror session @@ -141,7 +142,7 @@ def test_MirrorAddRemove(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "inactive" # add neighbor to Ethernet16 - self.add_neighbor("Ethernet16", "10.0.0.1", "02:04:06:08:10:12") + self.add_neighbor("Ethernet16", nhop_ip, "02:04:06:08:10:12") assert self.get_mirror_session_state(session)["status"] == "inactive" # add route to mirror destination via 10.0.0.1 @@ -190,7 +191,7 @@ def test_MirrorAddRemove(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "inactive" # remove neighbor - self.remove_neighbor("Ethernet16", "10.0.0.1") + self.remove_neighbor("Ethernet16", nhop_ip) assert self.get_mirror_session_state(session)["status"] == "inactive" # remove IP address From 726e6000232c31c403829ec5172d0a449136029d Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 6 Jul 2021 22:45:04 +0000 Subject: [PATCH 05/27] Refactor route add Signed-off-by: Wenda Ni --- tests/test_mirror.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 5cace72f2b..fa696b56f5 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -145,12 +145,12 @@ def test_MirrorAddRemove(self, dvs, testlog): self.add_neighbor("Ethernet16", nhop_ip, "02:04:06:08:10:12") assert self.get_mirror_session_state(session)["status"] == "inactive" - # add route to mirror destination via 10.0.0.1 - self.add_route(dvs, "2.2.2.2", "10.0.0.1") + # add route to mirror destination via next hop ip + self.add_route(dvs, dst_ip, nhop_ip) assert self.get_mirror_session_state(session)["status"] == "active" assert self.get_mirror_session_state(session)["monitor_port"] == "Ethernet16" assert self.get_mirror_session_state(session)["dst_mac"] == "02:04:06:08:10:12" - assert self.get_mirror_session_state(session)["route_prefix"] == "2.2.2.2/32" + assert self.get_mirror_session_state(session)["route_prefix"] == "{}/{}".format(dst_ip, 32) # check asic database tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_MIRROR_SESSION") From e9ecc9b54278186022590280005dbe0ff5c5b395 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 08:18:04 +0000 Subject: [PATCH 06/27] test MirrorAddRemove ipv6 encap Signed-off-by: Wenda Ni --- tests/test_mirror.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index fa696b56f5..f1ba2c4394 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -107,7 +107,7 @@ def check_syslog(self, dvs, marker, log, expected_cnt): (ec, out) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \'%s\' | wc -l" % (marker, log)]) assert out.strip() == str(expected_cnt) - def test_MirrorAddRemove(self, dvs, testlog): + def _test_MirrorAddRemove(self, dvs, testlog, v6_encap=False): """ This test covers the basic mirror session creation and removal operations Operation flow: @@ -119,13 +119,12 @@ def test_MirrorAddRemove(self, dvs, testlog): The session becomes inactive again till the end 4. Remove miror session """ - self.setup_db(dvs) session = "TEST_SESSION" - src_ip = "1.1.1.1" - dst_ip = "2.2.2.2" - intf_addr = "10.0.0.0/31" - nhop_ip = "10.0.0.1" + src_ip = "1.1.1.1" if v6_encap == False else "fc00::1:1:1:1" + dst_ip = "2.2.2.2" if v6_encap == False else "fc00::2:2:2:2" + intf_addr = "10.0.0.0/31" if v6_encap == False else "fc00::/126" + nhop_ip = "10.0.0.1" if v6_encap == False else "fc00::1" marker = dvs.add_log_marker() # create mirror session @@ -150,7 +149,7 @@ def test_MirrorAddRemove(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "active" assert self.get_mirror_session_state(session)["monitor_port"] == "Ethernet16" assert self.get_mirror_session_state(session)["dst_mac"] == "02:04:06:08:10:12" - assert self.get_mirror_session_state(session)["route_prefix"] == "{}/{}".format(dst_ip, 32) + assert self.get_mirror_session_state(session)["route_prefix"] == "{}/{}".format(dst_ip, 32 if v6_encap == False else 128) # check asic database tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_MIRROR_SESSION") @@ -168,7 +167,7 @@ def test_MirrorAddRemove(self, dvs, testlog): elif fv[0] == "SAI_MIRROR_SESSION_ATTR_ERSPAN_ENCAPSULATION_TYPE": assert fv[1] == "SAI_ERSPAN_ENCAPSULATION_TYPE_MIRROR_L3_GRE_TUNNEL" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": - assert fv[1] == "4" + assert fv[1] == "4" if v6_encap == False else "6" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_TOS": assert fv[1] == "32" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_TTL": @@ -207,6 +206,12 @@ def test_MirrorAddRemove(self, dvs, testlog): self.remove_mirror_session(session) self.check_syslog(dvs, marker, "Detached next hop observer for destination IP {}".format(dst_ip), 1) + def test_MirrorAddRemove(self, dvs, testlog): + self.setup_db(dvs) + + #self._test_MirrorAddRemove(dvs, testlog) + self._test_MirrorAddRemove(dvs, testlog, v6_encap=True) + def create_vlan(self, dvs, vlan): #dvs.runcmd("ip link del Bridge") #dvs.runcmd("ip link add Bridge up type bridge") From 090410f40f9cecb08af1d61b472ca488c324cd23 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 09:21:41 +0000 Subject: [PATCH 07/27] Refactor MirrorToLagAddRemove Signed-off-by: Wenda Ni --- tests/test_mirror.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index f1ba2c4394..a5949be58c 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -407,12 +407,16 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): self.setup_db(dvs) session = "TEST_SESSION" + src_ip = "10.10.10.10" + dst_ip = "11.11.11.11" + # dst ip in directly connected subnet + intf_addr = "11.11.11.0/24" marker = dvs.add_log_marker() # create mirror session - self.create_mirror_session(session, "10.10.10.10", "11.11.11.11", "0x6558", "8", "100", "0") + self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" - self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP 11.11.11.11", 1) + self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP {}".format(dst_ip), 1) # create port channel; create port channel member self.create_port_channel(dvs, "008") @@ -423,11 +427,11 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): self.set_interface_status(dvs, "Ethernet88", "up") # add ip address to port channel 008 - self.add_ip_address("PortChannel008", "11.11.11.0/24") + self.add_ip_address("PortChannel008", intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # create neighbor to port channel 008 - self.add_neighbor("PortChannel008", "11.11.11.11", "88:88:88:88:88:88") + self.add_neighbor("PortChannel008", dst_ip, "88:88:88:88:88:88") assert self.get_mirror_session_state(session)["status"] == "active" # check asic database @@ -443,11 +447,11 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): assert fv[1] == "88:88:88:88:88:88" # remove neighbor - self.remove_neighbor("PortChannel008", "11.11.11.11") + self.remove_neighbor("PortChannel008", dst_ip) assert self.get_mirror_session_state(session)["status"] == "inactive" # remove ip address - self.remove_ip_address("PortChannel008", "11.11.11.0/24") + self.remove_ip_address("PortChannel008", intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # bring down port channel and port channel member @@ -461,7 +465,7 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): marker = dvs.add_log_marker() # remove mirror session self.remove_mirror_session(session) - self.check_syslog(dvs, marker, "Detached next hop observer for destination IP 11.11.11.11", 1) + self.check_syslog(dvs, marker, "Detached next hop observer for destination IP {}".format(dst_ip), 1) # Ignore testcase in Debian Jessie From cd2c7791c6ca90d06a8251d6139f4f46e24e1628 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 09:25:11 +0000 Subject: [PATCH 08/27] Uncomment test Signed-off-by: Wenda Ni --- tests/test_mirror.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index a5949be58c..b692fd254c 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -209,7 +209,7 @@ def _test_MirrorAddRemove(self, dvs, testlog, v6_encap=False): def test_MirrorAddRemove(self, dvs, testlog): self.setup_db(dvs) - #self._test_MirrorAddRemove(dvs, testlog) + self._test_MirrorAddRemove(dvs, testlog) self._test_MirrorAddRemove(dvs, testlog, v6_encap=True) def create_vlan(self, dvs, vlan): From f9c211c99dba8a3a2a64627ba21392785e6e443c Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 09:25:53 +0000 Subject: [PATCH 09/27] Introduce _test_MirrorToLagAddRemove Signed-off-by: Wenda Ni --- tests/test_mirror.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index b692fd254c..4789deffee 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -392,7 +392,7 @@ def remove_port_channel_member(self, channel, interface): time.sleep(1) - def test_MirrorToLagAddRemove(self, dvs, testlog): + def _test_MirrorToLagAddRemove(self, dvs, testlog): """ This test covers basic mirror session creation and removal operations with destination port sits in a LAG @@ -404,7 +404,6 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): 4. Remove mirror session """ - self.setup_db(dvs) session = "TEST_SESSION" src_ip = "10.10.10.10" @@ -467,6 +466,10 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): self.remove_mirror_session(session) self.check_syslog(dvs, marker, "Detached next hop observer for destination IP {}".format(dst_ip), 1) + def test_MirrorToLagAddRemove(self, dvs, testlog): + self.setup_db(dvs) + + self._test_MirrorToLagAddRemove(dvs, testlog) # Ignore testcase in Debian Jessie # TODO: Remove this skip if Jessie support is no longer needed From ad07aa55261d57f0b8013f77884b0d95d12d9e97 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 18:08:15 +0000 Subject: [PATCH 10/27] test MirrorToLagAddRemove ipv6 encap Signed-off-by: Wenda Ni --- tests/test_mirror.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 4789deffee..d341b59438 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -392,7 +392,7 @@ def remove_port_channel_member(self, channel, interface): time.sleep(1) - def _test_MirrorToLagAddRemove(self, dvs, testlog): + def _test_MirrorToLagAddRemove(self, dvs, testlog, v6_encap=False): """ This test covers basic mirror session creation and removal operations with destination port sits in a LAG @@ -406,10 +406,10 @@ def _test_MirrorToLagAddRemove(self, dvs, testlog): """ session = "TEST_SESSION" - src_ip = "10.10.10.10" - dst_ip = "11.11.11.11" + src_ip = "10.10.10.10" if v6_encap == False else "fc00::10:10:10:10" + dst_ip = "11.11.11.11" if v6_encap == False else "fc00::11:11:11:11" # dst ip in directly connected subnet - intf_addr = "11.11.11.0/24" + intf_addr = "11.11.11.0/24" if v6_encap == False else "fc00::11:11:11:0/112" marker = dvs.add_log_marker() # create mirror session @@ -470,6 +470,7 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): self.setup_db(dvs) self._test_MirrorToLagAddRemove(dvs, testlog) + self._test_MirrorToLagAddRemove(dvs, testlog, v6_encap=True) # Ignore testcase in Debian Jessie # TODO: Remove this skip if Jessie support is no longer needed From 61149a56f105750cf25815488eb3aafd3cdb74f7 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 19:01:22 +0000 Subject: [PATCH 11/27] Refactor MirrorToVlanAddRemove Signed-off-by: Wenda Ni --- tests/test_mirror.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index d341b59438..bf5066026c 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -266,12 +266,16 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): self.setup_db(dvs) session = "TEST_SESSION" + src_ip = "5.5.5.5" + # dst ip in directly connected vlan subnet + dst_ip = "6.6.6.6" + intf_addr = "6.6.6.0/24" marker = dvs.add_log_marker() # create mirror session - self.create_mirror_session(session, "5.5.5.5", "6.6.6.6", "0x6558", "8", "100", "0") + self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" - self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP 6.6.6.6", 1) + self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP {}".format(dst_ip), 1) # create vlan; create vlan member self.create_vlan(dvs, "6") @@ -282,11 +286,11 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): self.set_interface_status(dvs, "Ethernet4", "up") # add ip address to vlan 6 - self.add_ip_address("Vlan6", "6.6.6.0/24") + self.add_ip_address("Vlan6", intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # create neighbor to vlan 6 - self.add_neighbor("Vlan6", "6.6.6.6", "66:66:66:66:66:66") + self.add_neighbor("Vlan6", dst_ip, "66:66:66:66:66:66") assert self.get_mirror_session_state(session)["status"] == "inactive" # create fdb entry to ethernet4 @@ -315,9 +319,9 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): elif fv[0] == "SAI_MIRROR_SESSION_ATTR_TTL": assert fv[1] == "100" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_SRC_IP_ADDRESS": - assert fv[1] == "5.5.5.5" + assert fv[1] == src_ip elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_IP_ADDRESS": - assert fv[1] == "6.6.6.6" + assert fv[1] == dst_ip elif fv[0] == "SAI_MIRROR_SESSION_ATTR_SRC_MAC_ADDRESS": assert fv[1] == dvs.runcmd("bash -c \"ip link show eth0 | grep ether | awk '{print $2}'\"")[1].strip().upper() elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": @@ -342,11 +346,11 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "inactive" # remove neighbor - self.remove_neighbor("Vlan6", "6.6.6.6") + self.remove_neighbor("Vlan6", dst_ip) assert self.get_mirror_session_state(session)["status"] == "inactive" # remove ip address - self.remove_ip_address("Vlan6", "6.6.6.0/24") + self.remove_ip_address("Vlan6", intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # bring down vlan and member @@ -360,7 +364,7 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): marker = dvs.add_log_marker() # remove mirror session self.remove_mirror_session(session) - self.check_syslog(dvs, marker, "Detached next hop observer for destination IP 6.6.6.6", 1) + self.check_syslog(dvs, marker, "Detached next hop observer for destination IP {}".format(dst_ip), 1) def create_port_channel(self, dvs, channel): tbl = swsscommon.ProducerStateTable(self.pdb, "LAG_TABLE") From af5e1e1c97a9021d035f42ffc24132e6b156a7d5 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 19:33:01 +0000 Subject: [PATCH 12/27] Introduce _test_MirrorToVlanAddRemove Signed-off-by: Wenda Ni --- tests/test_mirror.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index bf5066026c..4eb7aedb91 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -248,11 +248,7 @@ def remove_fdb(self, vlan, mac): tbl._del("Vlan" + vlan + ":" + mac) time.sleep(1) - - # Ignore testcase in Debian Jessie - # TODO: Remove this skip if Jessie support is no longer needed - @pytest.mark.skipif(StrictVersion(distro.linux_distribution()[1]) <= StrictVersion('8.9'), reason="Debian 8.9 or before has no support") - def test_MirrorToVlanAddRemove(self, dvs, testlog): + def _test_MirrorToVlanAddRemove(self, dvs, testlog): """ This test covers basic mirror session creation and removal operation with destination port sits in a VLAN @@ -263,7 +259,6 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): 3. Remove FDB; remove neighbor; remove IP; remove VLAN 4. Remove mirror session """ - self.setup_db(dvs) session = "TEST_SESSION" src_ip = "5.5.5.5" @@ -366,6 +361,14 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): self.remove_mirror_session(session) self.check_syslog(dvs, marker, "Detached next hop observer for destination IP {}".format(dst_ip), 1) + # Ignore testcase in Debian Jessie + # TODO: Remove this skip if Jessie support is no longer needed + @pytest.mark.skipif(StrictVersion(distro.linux_distribution()[1]) <= StrictVersion('8.9'), reason="Debian 8.9 or before has no support") + def test_MirrorToVlanAddRemove(self, dvs, testlog): + self.setup_db(dvs) + + self._test_MirrorToVlanAddRemove(dvs, testlog) + def create_port_channel(self, dvs, channel): tbl = swsscommon.ProducerStateTable(self.pdb, "LAG_TABLE") fvs = swsscommon.FieldValuePairs([("admin", "up"), ("mtu", "9100")]) From 6e96186c78ba14efe4b52261a0483114b95bbf1f Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 19:45:20 +0000 Subject: [PATCH 13/27] test MirrorToVlanAddRemove ipv6 encap Signed-off-by: Wenda Ni --- tests/test_mirror.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 4eb7aedb91..7029a1f4bd 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -248,7 +248,7 @@ def remove_fdb(self, vlan, mac): tbl._del("Vlan" + vlan + ":" + mac) time.sleep(1) - def _test_MirrorToVlanAddRemove(self, dvs, testlog): + def _test_MirrorToVlanAddRemove(self, dvs, testlog, v6_encap=False): """ This test covers basic mirror session creation and removal operation with destination port sits in a VLAN @@ -261,10 +261,10 @@ def _test_MirrorToVlanAddRemove(self, dvs, testlog): """ session = "TEST_SESSION" - src_ip = "5.5.5.5" + src_ip = "5.5.5.5" if v6_encap == False else "fc00::5:5:5:5" # dst ip in directly connected vlan subnet - dst_ip = "6.6.6.6" - intf_addr = "6.6.6.0/24" + dst_ip = "6.6.6.6" if v6_encap == False else "fc00::6:6:6:6" + intf_addr = "6.6.6.0/24" if v6_encap == False else "fc00::6:6:6:0/112" marker = dvs.add_log_marker() # create mirror session @@ -308,7 +308,7 @@ def _test_MirrorToVlanAddRemove(self, dvs, testlog): elif fv[0] == "SAI_MIRROR_SESSION_ATTR_ERSPAN_ENCAPSULATION_TYPE": assert fv[1] == "SAI_ERSPAN_ENCAPSULATION_TYPE_MIRROR_L3_GRE_TUNNEL" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": - assert fv[1] == "4" + assert fv[1] == "4" if v6_encap == False else "6" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_TOS": assert fv[1] == "32" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_TTL": @@ -368,6 +368,7 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog): self.setup_db(dvs) self._test_MirrorToVlanAddRemove(dvs, testlog) + self._test_MirrorToVlanAddRemove(dvs, testlog, v6_encap=True) def create_port_channel(self, dvs, channel): tbl = swsscommon.ProducerStateTable(self.pdb, "LAG_TABLE") From 21ce117bef71d1254f28481ddf64f7f8e4737e0d Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 19:48:36 +0000 Subject: [PATCH 14/27] test_MirrorToLagAddRemove check IPHDR_VERSION Signed-off-by: Wenda Ni --- tests/test_mirror.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 7029a1f4bd..6cc114dd5f 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -399,7 +399,6 @@ def remove_port_channel_member(self, channel, interface): tbl._del("PortChannel" + channel + ":" + interface) time.sleep(1) - def _test_MirrorToLagAddRemove(self, dvs, testlog, v6_encap=False): """ This test covers basic mirror session creation and removal operations @@ -452,6 +451,8 @@ def _test_MirrorToLagAddRemove(self, dvs, testlog, v6_encap=False): assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet88" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": assert fv[1] == "88:88:88:88:88:88" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # remove neighbor self.remove_neighbor("PortChannel008", dst_ip) From 12d4267c72e7684891985f8bd7dd996847ed28ae Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 21:16:05 +0000 Subject: [PATCH 15/27] Refactor MirrorDestMoveVlan Signed-off-by: Wenda Ni --- tests/test_mirror.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 6cc114dd5f..d295283481 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -500,16 +500,23 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): self.setup_db(dvs) session = "TEST_SESSION" + src_ip = "7.7.7.7" + dst_ip = "8.8.8.8" + port_intf_addr = "80.0.0.0/31" + port_nhop_ip = "80.0.0.1" + port_ip_prefix = "8.8.0.0/16" + # dst ip moves to directly connected vlan subnet + vlan_intf_addr = "8.8.8.0/24" # create mirror session - self.create_mirror_session(session, "7.7.7.7", "8.8.8.8", "0x6558", "8", "100", "0") + self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" # bring up port; add ip; add neighbor; add route self.set_interface_status(dvs, "Ethernet32", "up") - self.add_ip_address("Ethernet32", "80.0.0.0/31") - self.add_neighbor("Ethernet32", "80.0.0.1", "02:04:06:08:10:12") - self.add_route(dvs, "8.8.0.0/16", "80.0.0.1") + self.add_ip_address("Ethernet32", port_intf_addr) + self.add_neighbor("Ethernet32", port_nhop_ip, "02:04:06:08:10:12") + self.add_route(dvs, port_ip_prefix, port_nhop_ip) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -532,11 +539,11 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "active" # add ip address to vlan 9 - self.add_ip_address("Vlan9", "8.8.8.0/24") + self.add_ip_address("Vlan9", vlan_intf_addr) assert self.get_mirror_session_state(session)["status"] == "inactive" # create neighbor to vlan 9 - self.add_neighbor("Vlan9", "8.8.8.8", "88:88:88:88:88:88") + self.add_neighbor("Vlan9", dst_ip, "88:88:88:88:88:88") assert self.get_mirror_session_state(session)["status"] == "inactive" # create fdb entry to ethernet48 @@ -568,11 +575,11 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): assert self.get_mirror_session_state(session)["status"] == "inactive" # remove neighbor - self.remove_neighbor("Vlan9", "8.8.8.8") + self.remove_neighbor("Vlan9", dst_ip) assert self.get_mirror_session_state(session)["status"] == "inactive" # remove ip address - self.remove_ip_address("Vlan9", "8.8.8.0/24") + self.remove_ip_address("Vlan9", vlan_intf_addr) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -593,9 +600,9 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): self.remove_vlan("9") # remove route; remove neighbor; remove ip; bring down port - self.remove_route(dvs, "8.8.8.0/24") - self.remove_neighbor("Ethernet32", "80.0.0.1") - self.remove_ip_address("Ethernet32", "80.0.0.0/31") + self.remove_route(dvs, vlan_intf_addr) + self.remove_neighbor("Ethernet32", port_nhop_ip) + self.remove_ip_address("Ethernet32", port_intf_addr) self.set_interface_status(dvs, "Ethernet32", "down") # remove mirror session From fbed7251213bf6c100a0776d046c4fd3a19a2f93 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 21:22:07 +0000 Subject: [PATCH 16/27] Introduce _test_MirrorDestMoveVlan Signed-off-by: Wenda Ni --- tests/test_mirror.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index d295283481..4409d8e34e 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -119,7 +119,6 @@ def _test_MirrorAddRemove(self, dvs, testlog, v6_encap=False): The session becomes inactive again till the end 4. Remove miror session """ - session = "TEST_SESSION" src_ip = "1.1.1.1" if v6_encap == False else "fc00::1:1:1:1" dst_ip = "2.2.2.2" if v6_encap == False else "fc00::2:2:2:2" @@ -259,7 +258,6 @@ def _test_MirrorToVlanAddRemove(self, dvs, testlog, v6_encap=False): 3. Remove FDB; remove neighbor; remove IP; remove VLAN 4. Remove mirror session """ - session = "TEST_SESSION" src_ip = "5.5.5.5" if v6_encap == False else "fc00::5:5:5:5" # dst ip in directly connected vlan subnet @@ -411,7 +409,6 @@ def _test_MirrorToLagAddRemove(self, dvs, testlog, v6_encap=False): 4. Remove mirror session """ - session = "TEST_SESSION" src_ip = "10.10.10.10" if v6_encap == False else "fc00::10:10:10:10" dst_ip = "11.11.11.11" if v6_encap == False else "fc00::11:11:11:11" @@ -481,10 +478,7 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): self._test_MirrorToLagAddRemove(dvs, testlog) self._test_MirrorToLagAddRemove(dvs, testlog, v6_encap=True) - # Ignore testcase in Debian Jessie - # TODO: Remove this skip if Jessie support is no longer needed - @pytest.mark.skipif(StrictVersion(distro.linux_distribution()[1]) <= StrictVersion('8.9'), reason="Debian 8.9 or before has no support") - def test_MirrorDestMoveVlan(self, dvs, testlog): + def _test_MirrorDestMoveVlan(self, dvs, testlog): """ This test tests mirror session destination move from non-VLAN to VLAN and back to non-VLAN port @@ -497,8 +491,6 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): 7. Disable non-VLAN monitor port 8. Remove mirror session """ - self.setup_db(dvs) - session = "TEST_SESSION" src_ip = "7.7.7.7" dst_ip = "8.8.8.8" @@ -608,6 +600,13 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): # remove mirror session self.remove_mirror_session(session) + # Ignore testcase in Debian Jessie + # TODO: Remove this skip if Jessie support is no longer needed + @pytest.mark.skipif(StrictVersion(distro.linux_distribution()[1]) <= StrictVersion('8.9'), reason="Debian 8.9 or before has no support") + def test_MirrorDestMoveVlan(self, dvs, testlog): + self.setup_db(dvs) + + self._test_MirrorDestMoveVlan(dvs, testlog) def test_MirrorDestMoveLag(self, dvs, testlog): """ From 1e2456241b1c5d2a667cbe889b56916ea648c6f6 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 23:18:01 +0000 Subject: [PATCH 17/27] test MirrorDestMoveVlan ipv6 encap Signed-off-by: Wenda Ni --- tests/test_mirror.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 4409d8e34e..640e1c6d51 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -478,7 +478,7 @@ def test_MirrorToLagAddRemove(self, dvs, testlog): self._test_MirrorToLagAddRemove(dvs, testlog) self._test_MirrorToLagAddRemove(dvs, testlog, v6_encap=True) - def _test_MirrorDestMoveVlan(self, dvs, testlog): + def _test_MirrorDestMoveVlan(self, dvs, testlog, v6_encap=False): """ This test tests mirror session destination move from non-VLAN to VLAN and back to non-VLAN port @@ -492,13 +492,13 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog): 8. Remove mirror session """ session = "TEST_SESSION" - src_ip = "7.7.7.7" - dst_ip = "8.8.8.8" - port_intf_addr = "80.0.0.0/31" - port_nhop_ip = "80.0.0.1" - port_ip_prefix = "8.8.0.0/16" + src_ip = "7.7.7.7" if v6_encap == False else "fc00::7:7:7:7" + dst_ip = "8.8.8.8" if v6_encap == False else "fc00::8:8:8:8" + port_intf_addr = "80.0.0.0/31" if v6_encap == False else "fc00::80:0:0:0/126" + port_nhop_ip = "80.0.0.1" if v6_encap == False else "fc00::80:0:0:1" + port_ip_prefix = "8.8.0.0/16" if v6_encap == False else "fc00::8:8:0:0/96" # dst ip moves to directly connected vlan subnet - vlan_intf_addr = "8.8.8.0/24" + vlan_intf_addr = "8.8.8.0/24" if v6_encap == False else "fc00::8:8:8:0/112" # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") @@ -532,6 +532,8 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog): # add ip address to vlan 9 self.add_ip_address("Vlan9", vlan_intf_addr) + time.sleep(1) + # inactive due to no neighbor mac or fdb entry assert self.get_mirror_session_state(session)["status"] == "inactive" # create neighbor to vlan 9 @@ -607,6 +609,7 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): self.setup_db(dvs) self._test_MirrorDestMoveVlan(dvs, testlog) + self._test_MirrorDestMoveVlan(dvs, testlog, v6_encap=True) def test_MirrorDestMoveLag(self, dvs, testlog): """ From 8f45af545826b84a3a1e8012837031004c542558 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 23:46:44 +0000 Subject: [PATCH 18/27] Refactor MirrorDestMoveLag Signed-off-by: Wenda Ni --- tests/test_mirror.py | 53 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 640e1c6d51..4a9cf489db 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -521,6 +521,8 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog, v6_encap=False): assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet32" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_VLAN_HEADER_VALID": assert fv[1] == "false" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # mirror session move round 1 # create vlan; create vlan member; bring up vlan and member @@ -562,6 +564,8 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog, v6_encap=False): assert fv[1] == "0" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_VLAN_CFI": assert fv[1] == "0" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # mirror session move round 2 # remove fdb entry @@ -586,6 +590,8 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog, v6_encap=False): assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet32" elif fv[0] == "SAI_MIRROR_SESSION_ATTR_VLAN_HEADER_VALID": assert fv[1] == "false" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # bring down vlan and member; remove vlan member; remove vlan self.set_interface_status(dvs, "Ethernet48", "down") @@ -611,7 +617,7 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): self._test_MirrorDestMoveVlan(dvs, testlog) self._test_MirrorDestMoveVlan(dvs, testlog, v6_encap=True) - def test_MirrorDestMoveLag(self, dvs, testlog): + def test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): """ This test tests mirror session destination move from non-LAG to LAG and back to non-LAG port @@ -627,16 +633,22 @@ def test_MirrorDestMoveLag(self, dvs, testlog): self.setup_db(dvs) session = "TEST_SESSION" + src_ip = "12.12.12.12" + dst_ip = "13.13.13.13" + port_intf_addr = "100.0.0.0/31" + port_nhop_ip = "100.0.0.1" + lag_intf_addr = "200.0.0.0/31" + lag_nhop_ip = "200.0.0.1" # create mirror session - self.create_mirror_session(session, "12.12.12.12", "13.13.13.13", "0x6558", "8", "100", "0") + self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" # bring up port; add ip; add neighbor; add route self.set_interface_status(dvs, "Ethernet64", "up") - self.add_ip_address("Ethernet64", "100.0.0.0/31") - self.add_neighbor("Ethernet64", "100.0.0.1", "02:04:06:08:10:12") - self.add_route(dvs, "13.13.0.0/16", "100.0.0.1") + self.add_ip_address("Ethernet64", port_intf_addr) + self.add_neighbor("Ethernet64", port_nhop_ip, "02:04:06:08:10:12") + self.add_route(dvs, "13.13.0.0/16", port_nhop_ip) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -647,8 +659,10 @@ def test_MirrorDestMoveLag(self, dvs, testlog): for fv in fvs: if fv[0] == "SAI_MIRROR_SESSION_ATTR_MONITOR_PORT": assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet64" - if fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": assert fv[1] == "02:04:06:08:10:12" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # mirror session move round 1 # create port channel; create port channel member; bring up @@ -658,12 +672,12 @@ def test_MirrorDestMoveLag(self, dvs, testlog): self.set_interface_status(dvs, "Ethernet32", "up") # add ip address to port channel 080; create neighbor to port channel 080 - self.add_ip_address("PortChannel080", "200.0.0.0/31") - self.add_neighbor("PortChannel080", "200.0.0.1", "12:10:08:06:04:02") + self.add_ip_address("PortChannel080", lag_intf_addr) + self.add_neighbor("PortChannel080", lag_nhop_ip, "12:10:08:06:04:02") assert self.get_mirror_session_state(session)["status"] == "active" # add route - self.add_route(dvs, "13.13.13.0/24", "200.0.0.1") + self.add_route(dvs, "13.13.13.0/24", lag_nhop_ip) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -674,8 +688,10 @@ def test_MirrorDestMoveLag(self, dvs, testlog): for fv in fvs: if fv[0] == "SAI_MIRROR_SESSION_ATTR_MONITOR_PORT": assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet32" - if fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": assert fv[1] == "12:10:08:06:04:02" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # mirror session move round 2 # remove port channel member @@ -695,15 +711,16 @@ def test_MirrorDestMoveLag(self, dvs, testlog): for fv in fvs: if fv[0] == "SAI_MIRROR_SESSION_ATTR_MONITOR_PORT": assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet32" - if fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": assert fv[1] == "12:10:08:06:04:02" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # mirror session move round 4 # remove route self.remove_route(dvs, "13.13.13.0/24") assert self.get_mirror_session_state(session)["status"] == "active" - port_oid = "" # check monitor port tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_MIRROR_SESSION") assert len(tbl.getKeys()) == 1 @@ -712,12 +729,14 @@ def test_MirrorDestMoveLag(self, dvs, testlog): for fv in fvs: if fv[0] == "SAI_MIRROR_SESSION_ATTR_MONITOR_PORT": assert dvs.asicdb.portoidmap[fv[1]] == "Ethernet64" - if fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": assert fv[1] == "02:04:06:08:10:12" + elif fv[0] == "SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": + assert fv[1] == "4" if v6_encap == False else "6" # remove neighbor; remove ip address to port channel 080 - self.remove_neighbor("PortChannel080", "200.0.0.1") - self.remove_ip_address("PortChannel080", "200.0.0.0/31") + self.remove_neighbor("PortChannel080", lag_nhop_ip) + self.remove_ip_address("PortChannel080", lag_intf_addr) # bring down; remove port channel member; remove port channel self.set_interface_status(dvs, "Ethernet32", "down") @@ -728,8 +747,8 @@ def test_MirrorDestMoveLag(self, dvs, testlog): # remove route; remove neighbor; remove ip; bring down port self.remove_route(dvs, "13.13.0.0/16") - self.remove_neighbor("Ethernet64", "100.0.0.1") - self.remove_ip_address("Ethernet64", "100.0.0.0/31") + self.remove_neighbor("Ethernet64", port_nhop_ip) + self.remove_ip_address("Ethernet64", port_intf_addr) self.set_interface_status(dvs, "Ethernet64", "down") assert self.get_mirror_session_state(session)["status"] == "inactive" From ca4dbf331829d61fa9114c754249f3869953a13a Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 7 Jul 2021 23:53:03 +0000 Subject: [PATCH 19/27] Introduce _test_MirrorDestMoveLag Signed-off-by: Wenda Ni --- tests/test_mirror.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 4a9cf489db..f9151c1acf 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -617,7 +617,7 @@ def test_MirrorDestMoveVlan(self, dvs, testlog): self._test_MirrorDestMoveVlan(dvs, testlog) self._test_MirrorDestMoveVlan(dvs, testlog, v6_encap=True) - def test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): + def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): """ This test tests mirror session destination move from non-LAG to LAG and back to non-LAG port @@ -630,8 +630,6 @@ def test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): 7. Disable non-LAG monitor port 8. Remove mirror session """ - self.setup_db(dvs) - session = "TEST_SESSION" src_ip = "12.12.12.12" dst_ip = "13.13.13.13" @@ -755,6 +753,10 @@ def test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): # remove mirror session self.remove_mirror_session(session) + def test_MirrorDestMoveLag(self, dvs, testlog): + self.setup_db(dvs) + + self._test_MirrorDestMoveLag(dvs, testlog) def create_acl_table(self, table, interfaces): tbl = swsscommon.Table(self.cdb, "ACL_TABLE") From 320efa0a9f5f6936d9da6ff42f232eed4cb38805 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Thu, 8 Jul 2021 00:07:36 +0000 Subject: [PATCH 20/27] test MirrorDestMoveLag ipv6 encap Signed-off-by: Wenda Ni --- tests/test_mirror.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index f9151c1acf..0d62a50d26 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -631,12 +631,14 @@ def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): 8. Remove mirror session """ session = "TEST_SESSION" - src_ip = "12.12.12.12" - dst_ip = "13.13.13.13" - port_intf_addr = "100.0.0.0/31" - port_nhop_ip = "100.0.0.1" - lag_intf_addr = "200.0.0.0/31" - lag_nhop_ip = "200.0.0.1" + src_ip = "12.12.12.12" if v6_encap == False else "fc00::12:12:12:12" + dst_ip = "13.13.13.13" if v6_encap == False else "fc00::13:13:13:13" + port_intf_addr = "100.0.0.0/31" if v6_encap == False else "fc00::100:0:0:0/126" + port_nhop_ip = "100.0.0.1" if v6_encap == False else "fc00::100:0:0:1" + port_ip_prefix = "13.13.0.0/16" if v6_encap == False else "fc00::13:13:0:0/96" + lag_intf_addr = "200.0.0.0/31" if v6_encap == False else "fc00::200:0:0:0/126" + lag_nhop_ip = "200.0.0.1" if v6_encap == False else "fc00::200:0:0:1" + lag_ip_prefix = "13.13.13.0/24" if v6_encap == False else "fc00::13:13:13:0/112" # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") @@ -646,7 +648,7 @@ def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): self.set_interface_status(dvs, "Ethernet64", "up") self.add_ip_address("Ethernet64", port_intf_addr) self.add_neighbor("Ethernet64", port_nhop_ip, "02:04:06:08:10:12") - self.add_route(dvs, "13.13.0.0/16", port_nhop_ip) + self.add_route(dvs, port_ip_prefix, port_nhop_ip) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -675,7 +677,7 @@ def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): assert self.get_mirror_session_state(session)["status"] == "active" # add route - self.add_route(dvs, "13.13.13.0/24", lag_nhop_ip) + self.add_route(dvs, lag_ip_prefix, lag_nhop_ip) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -716,7 +718,7 @@ def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): # mirror session move round 4 # remove route - self.remove_route(dvs, "13.13.13.0/24") + self.remove_route(dvs, lag_ip_prefix) assert self.get_mirror_session_state(session)["status"] == "active" # check monitor port @@ -744,7 +746,7 @@ def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): assert self.get_mirror_session_state(session)["status"] == "active" # remove route; remove neighbor; remove ip; bring down port - self.remove_route(dvs, "13.13.0.0/16") + self.remove_route(dvs, port_ip_prefix) self.remove_neighbor("Ethernet64", port_nhop_ip) self.remove_ip_address("Ethernet64", port_intf_addr) self.set_interface_status(dvs, "Ethernet64", "down") From fef1dfa589a7c78b1b6bab2c0f55a3b061c448cc Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Fri, 9 Jul 2021 20:58:06 +0000 Subject: [PATCH 21/27] ipv6 next hop key Signed-off-by: Wenda Ni --- orchagent/mirrororch.cpp | 2 +- tests/test_mirror.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index a06c6163b4..590d4c74c6 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -1249,7 +1249,7 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update) else { string alias = ""; - session.nexthopInfo.nexthop = NextHopKey("0.0.0.0", alias); + session.nexthopInfo.nexthop = session.dstIp.isV6() ? NextHopKey("::", alias) : NextHopKey("0.0.0.0", alias); } // Update State DB Nexthop diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 0d62a50d26..27fba5acf9 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -129,6 +129,7 @@ def _test_MirrorAddRemove(self, dvs, testlog, v6_encap=False): # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" + assert self.get_mirror_session_state(session)["next_hop_ip"] == ("0.0.0.0@" if v6_encap == False else "::@") self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP {}".format(dst_ip), 1) # bring up Ethernet16 @@ -268,6 +269,7 @@ def _test_MirrorToVlanAddRemove(self, dvs, testlog, v6_encap=False): # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" + assert self.get_mirror_session_state(session)["next_hop_ip"] == ("0.0.0.0@" if v6_encap == False else "::@") self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP {}".format(dst_ip), 1) # create vlan; create vlan member @@ -419,6 +421,7 @@ def _test_MirrorToLagAddRemove(self, dvs, testlog, v6_encap=False): # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" + assert self.get_mirror_session_state(session)["next_hop_ip"] == ("0.0.0.0@" if v6_encap == False else "::@") self.check_syslog(dvs, marker, "Attached next hop observer .* for destination IP {}".format(dst_ip), 1) # create port channel; create port channel member @@ -503,6 +506,7 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog, v6_encap=False): # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" + assert self.get_mirror_session_state(session)["next_hop_ip"] == ("0.0.0.0@" if v6_encap == False else "::@") # bring up port; add ip; add neighbor; add route self.set_interface_status(dvs, "Ethernet32", "up") @@ -643,6 +647,7 @@ def _test_MirrorDestMoveLag(self, dvs, testlog, v6_encap=False): # create mirror session self.create_mirror_session(session, src_ip, dst_ip, "0x6558", "8", "100", "0") assert self.get_mirror_session_state(session)["status"] == "inactive" + assert self.get_mirror_session_state(session)["next_hop_ip"] == ("0.0.0.0@" if v6_encap == False else "::@") # bring up port; add ip; add neighbor; add route self.set_interface_status(dvs, "Ethernet64", "up") From 07689baa0c2ca34c3d8d123e2cd2213570f5124c Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Fri, 9 Jul 2021 21:59:07 +0000 Subject: [PATCH 22/27] Add missing test run Signed-off-by: Wenda Ni --- tests/test_mirror.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 27fba5acf9..7cdcc5575f 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -764,6 +764,7 @@ def test_MirrorDestMoveLag(self, dvs, testlog): self.setup_db(dvs) self._test_MirrorDestMoveLag(dvs, testlog) + self._test_MirrorDestMoveLag(dvs, testlog, v6_encap=True) def create_acl_table(self, table, interfaces): tbl = swsscommon.Table(self.cdb, "ACL_TABLE") From b2f84750221f44096ca703f0be47b7dd40e67b11 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Fri, 9 Jul 2021 22:09:18 +0000 Subject: [PATCH 23/27] Add comment Signed-off-by: Wenda Ni --- orchagent/mirrororch.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index 590d4c74c6..f9b3979cce 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -436,6 +436,7 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector Date: Thu, 15 Jul 2021 00:46:00 +0000 Subject: [PATCH 24/27] Address comment: use !isV4() for ipv6 Signed-off-by: Wenda Ni --- orchagent/mirrororch.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index f9b3979cce..dea97fc2b6 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -344,20 +344,10 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector Date: Fri, 16 Jul 2021 09:29:16 +0000 Subject: [PATCH 25/27] Stablize test MirrorDestMoveVlan Signed-off-by: Wenda Ni --- tests/test_mirror.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 7cdcc5575f..c6e88ec557 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -538,7 +538,7 @@ def _test_MirrorDestMoveVlan(self, dvs, testlog, v6_encap=False): # add ip address to vlan 9 self.add_ip_address("Vlan9", vlan_intf_addr) - time.sleep(1) + time.sleep(2) # inactive due to no neighbor mac or fdb entry assert self.get_mirror_session_state(session)["status"] == "inactive" From 7c9dff248bb5c566adc7c87732478012116e5455 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 4 Aug 2021 01:13:02 +0000 Subject: [PATCH 26/27] Update neigh table family field value Signed-off-by: Wenda Ni --- tests/test_mirror.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mirror.py b/tests/test_mirror.py index c6e88ec557..74ef22e693 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -60,7 +60,7 @@ def remove_ip_address(self, interface, ip): def add_neighbor(self, interface, ip, mac): tbl = swsscommon.ProducerStateTable(self.pdb, "NEIGH_TABLE") fvs = swsscommon.FieldValuePairs([("neigh", mac), - ("family", "IPv4")]) + ("family", "IPv4" if "." in ip else "IPv6")]) tbl.set(interface + ":" + ip, fvs) time.sleep(1) From ba31e8eafdad9928dff3b2a5c78f12ce26b4f1a0 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 15 Dec 2021 01:17:57 +0000 Subject: [PATCH 27/27] Address comment: src & dst family check Signed-off-by: Wenda Ni --- orchagent/mirrororch.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index cac94a66e8..2bef904975 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -453,6 +453,12 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector