Open echuawu opened 5 months ago
@kellyyeh Can you help check this issue?
I don't have a dualtor setup, but the active ports on my setup are not starting from index 0, hence the same radv test cases failed for me due to the hardcoded "eth1". This following change fixed the issue, basically replacing the hardcoded "eth1" with constructed "ethX" with the input port index X
.
diff --git a/ansible/roles/test/files/ptftests/router_adv_mflag_test.py b/ansible/roles/test/files/ptftests/router_adv_mflag_test.py
index 3049494e..cfaf77c0 100644
--- a/ansible/roles/test/files/ptftests/router_adv_mflag_test.py
+++ b/ansible/roles/test/files/ptftests/router_adv_mflag_test.py
@@ -53,15 +53,16 @@ class DataplaneBaseTest(BaseTest):
"""
- def create_icmpv6_router_advertisement_packet_send(self, dst_mac, dst_ip, src_mac, src_ip):
+ def create_icmpv6_router_advertisement_packet_send(self, dst_mac, dst_ip, src_mac, src_ip, port_index):
ether = Ether(dst=dst_mac, src=src_mac)
ip6 = IPv6(src=src_ip, dst=dst_ip, fl=0, tc=0, hlim=255)
icmp6 = RA(code=0, M=1, O=0)
# NOTE: Test expects RA packet to contain route prefix as the first option
icmp6 /= PrefixInfo(type=3, len=4)
rapkt = ether / ip6 / icmp6
- scapy2.sendp(rapkt, iface="eth1")
- logging.info(scapy2.sniff(iface='eth1', timeout=10))
+ iface = "eth" + str(port_index)
+ scapy2.sendp(rapkt, iface=iface)
+ logging.info(scapy2.sniff(iface=iface, timeout=10))
return rapkt
"""
@@ -136,7 +137,8 @@ class RadvUnSolicitedRATest(DataplaneBaseTest):
src_mac=self.downlink_vlan_mac,
dst_mac=ALL_NODES_MULTICAST_MAC_ADDRESS,
src_ip=self.downlink_vlan_ip6,
- dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS)
+ dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS,
+ port_index=self.ptf_port_index)
self.masked_rapkt = self.mask_off_dont_care_ra_packet_fields(rapkt)
def tearDown(self):
@@ -188,7 +190,8 @@ class RadvSolicitedRATest(DataplaneBaseTest):
src_mac=self.downlink_vlan_mac,
dst_mac=self.ptf_port_mac,
src_ip=self.downlink_vlan_ip6,
- dst_ip=self.ptf_port_ip6)
+ dst_ip=self.ptf_port_ip6,
+ port_index=self.ptf_port_index)
self.masked_rapkt = self.mask_off_dont_care_ra_packet_fields(rapkt)
self.rs_packet = self.create_icmpv6_router_solicitation_packet()
I don't have a dualtor setup, but the active ports on my setup are not starting from index 0, hence the same radv test cases failed for me due to the hardcoded "eth1". This following change fixed the issue, basically replacing the hardcoded "eth1" with constructed "ethX" with the input port index
X
.diff --git a/ansible/roles/test/files/ptftests/router_adv_mflag_test.py b/ansible/roles/test/files/ptftests/router_adv_mflag_test.py index 3049494e..cfaf77c0 100644 --- a/ansible/roles/test/files/ptftests/router_adv_mflag_test.py +++ b/ansible/roles/test/files/ptftests/router_adv_mflag_test.py @@ -53,15 +53,16 @@ class DataplaneBaseTest(BaseTest): """ - def create_icmpv6_router_advertisement_packet_send(self, dst_mac, dst_ip, src_mac, src_ip): + def create_icmpv6_router_advertisement_packet_send(self, dst_mac, dst_ip, src_mac, src_ip, port_index): ether = Ether(dst=dst_mac, src=src_mac) ip6 = IPv6(src=src_ip, dst=dst_ip, fl=0, tc=0, hlim=255) icmp6 = RA(code=0, M=1, O=0) # NOTE: Test expects RA packet to contain route prefix as the first option icmp6 /= PrefixInfo(type=3, len=4) rapkt = ether / ip6 / icmp6 - scapy2.sendp(rapkt, iface="eth1") - logging.info(scapy2.sniff(iface='eth1', timeout=10)) + iface = "eth" + str(port_index) + scapy2.sendp(rapkt, iface=iface) + logging.info(scapy2.sniff(iface=iface, timeout=10)) return rapkt """ @@ -136,7 +137,8 @@ class RadvUnSolicitedRATest(DataplaneBaseTest): src_mac=self.downlink_vlan_mac, dst_mac=ALL_NODES_MULTICAST_MAC_ADDRESS, src_ip=self.downlink_vlan_ip6, - dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS) + dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS, + port_index=self.ptf_port_index) self.masked_rapkt = self.mask_off_dont_care_ra_packet_fields(rapkt) def tearDown(self): @@ -188,7 +190,8 @@ class RadvSolicitedRATest(DataplaneBaseTest): src_mac=self.downlink_vlan_mac, dst_mac=self.ptf_port_mac, src_ip=self.downlink_vlan_ip6, - dst_ip=self.ptf_port_ip6) + dst_ip=self.ptf_port_ip6, + port_index=self.ptf_port_index) self.masked_rapkt = self.mask_off_dont_care_ra_packet_fields(rapkt) self.rs_packet = self.create_icmpv6_router_solicitation_packet()
Thank you @Stephenxf ! Could you associate the fix PR with this issue?
@echuawu can you take the patch and verify if it fixes the problem on your dualtor setup by any chance? If it works, I can create a PR. I don't know much about the dualtor layout, so just want the confirmation.
@echuawu can you take the patch and verify if it fixes the problem on your dualtor setup by any chance? If it works, I can create a PR. I don't know much about the dualtor layout, so just want the confirmation.
Hi @Stephenxf , currently I don't have time on it, but I had already added a task about it. I will update the validate result then.
Hi @Stephenxf, could you push the fix directly? If there is new issue, we could update it by a new PR.
Description ansible/roles/test/files/ptftests/py3/router_adv_mflag_test.py could not run pass at dualtor-64 topology. Due to there is a hard coded line in function create_icmpv6_router_advertisement_packet_send. "eth1" is hard coded in scapy2.sendp(rapkt, iface="eth1"). 2 cases are affected by this issue: radv.test_radv_ipv6_ra#test_unsolicited_router_advertisement_with_m_flag radv.test_radv_ipv6_ra#test_solicited_router_advertisement_with_m_flag
But there is no "eth1" configured at PTF in ansible/vars/topo_dualtor-64.yml:
topology: dut_num: 2 host_interfaces:
In summary, the router_adv_mflag_test.py need to be updated and adapted on dualtor-64 topology.
Steps to reproduce the issue:
Describe the results you received: The script would failed due to "OSError: [Errno 19] No such device" when trying to send packet at 'eth1':
tests.common.errors.RunAnsibleModuleFail: run module shell failed, Ansible Results => {"changed": true, "cmd": "/root/env-python3/bin/ptf --test-dir ptftests/py3 router_adv_mflag_test.RadvUnSolicitedRATest --platform-dir ptftests --platform remote -t 'hostname='\"'\"'r-tigon-21'\"'\"';downlink_vlan_mac='\"'\"'00:aa:bb:cc:dd:ee'\"'\"';downlink_vlan_ip6='\"'\"'fe80::2aa:bbff:fecc:ddee'\"'\"';ptf_port_index=6;max_ra_interval=180' --relax --debug info --log-file /tmp/router_adv_mflag_test.RadvUnSolicitedRATest.log", "delta": "0:00:01.936278", "end": "2024-01-16 19:11:55.615515", "failed": true, "msg": "non-zero return code", "rc": 1, "start": "2024-01-16 19:11:53.679237", "stderr": "/root/env-python3/bin/ptf:19: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses\n import imp\nrouter_adv_mflag_test.RadvUnSolicitedRATest ... ERROR\n\n======================================================================\nERROR: router_adv_mflag_test.RadvUnSolicitedRATest\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"ptftests/py3/router_adv_mflag_test.py\", line 139, in setUp\n dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS)\n File \"ptftests/py3/router_adv_mflag_test.py\", line 63, in create_icmpv6_router_advertisement_packet_send\n scapy2.sendp(rapkt, iface=\"eth1\")\n File \"/root/env-python3/lib/python3.7/site-packages/scapy/sendrecv.py\", line 483, in sendp\n kargs\n File \"/root/env-python3/lib/python3.7/site-packages/scapy/sendrecv.py\", line 414, in _send\n socket = socket or _func(iface)(iface=iface, kargs)\n File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/linux.py\", line 499, in init\n set_promisc(self.ins, self.iface)\n File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/linux.py\", line 179, in set_promisc\n mreq = struct.pack(\"IHH8s\", get_if_index(iff), PACKET_MR_PROMISC, 0, b\"\")\n File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/linux.py\", line 399, in get_if_index\n return int(struct.unpack(\"I\", get_if(iff, SIOCGIFINDEX)[16:20])[0])\n File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/unix.py\", line 42, in get_if\n return ioctl(sck, cmd, struct.pack(\"16s16x\", iff.encode(\"utf8\")))\nOSError: [Errno 19] No such device\n\n----------------------------------------------------------------------\nRan 1 test in 0.030s\n\nFAILED (errors=1)", "stderr_lines": ["/root/env-python3/bin/ptf:19: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses", " import imp", "router_adv_mflag_test.RadvUnSolicitedRATest ... ERROR", "", "======================================================================", "ERROR: router_adv_mflag_test.RadvUnSolicitedRATest", "----------------------------------------------------------------------", "Traceback (most recent call last):", " File \"ptftests/py3/router_adv_mflag_test.py\", line 139, in setUp", " dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS)", " File \"ptftests/py3/router_adv_mflag_test.py\", line 63, in create_icmpv6_router_advertisement_packet_send", " scapy2.sendp(rapkt, iface=\"eth1\")", " File \"/root/env-python3/lib/python3.7/site-packages/scapy/sendrecv.py\", line 483, in sendp", " kargs", " File \"/root/env-python3/lib/python3.7/site-packages/scapy/sendrecv.py\", line 414, in _send", " socket = socket or _func(iface)(iface=iface, kargs)", " File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/linux.py\", line 499, in init", " set_promisc(self.ins, self.iface)", " File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/linux.py\", line 179, in set_promisc", " mreq = struct.pack(\"IHH8s\", get_if_index(iff), PACKET_MR_PROMISC, 0, b\"\")", " File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/linux.py\", line 399, in get_if_index", " return int(struct.unpack(\"I\", get_if(iff, SIOCGIFINDEX)[16:20])[0])", " File \"/root/env-python3/lib/python3.7/site-packages/scapy/arch/unix.py\", line 42, in get_if", " return ioctl(sck, cmd, struct.pack(\"16s16x\", iff.encode(\"utf8\")))", "OSError: [Errno 19] No such device", "", "----------------------------------------------------------------------", "Ran 1 test in 0.030s", "", "FAILED (errors=1)"], "stdout": "Using packet manipulation module: ptf.packet_scapy\n\n**\nATTENTION: SOME TESTS DID NOT PASS!!!\n\nThe following tests errored:\nRadvUnSolicitedRATest\n\n**", "stdout_lines": ["Using packet manipulation module: ptf.packet_scapy", "", "**", "ATTENTION: SOME TESTS DID NOT PASS!!!", "", "The following tests errored:", "RadvUnSolicitedRATest", "", "**"]}
Describe the results you expected: Script would not failed.
Additional information you deem important: