-
Notifications
You must be signed in to change notification settings - Fork 1k
[pytest/test_drop_counters.py] Fixed IGMP test case #1624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
95137b0
FIxed IGMP test case
yvolynets-mlnx 22e5f75
Simplified removing "Raw" layer from packet
yvolynets-mlnx 08ac7cc
Minor fix in IGMP test
yvolynets-mlnx 3db7b5d
Fixed merge conflicts.
yvolynets-mlnx 4adbb35
Merged drop_couters folder
yvolynets-mlnx 7e26939
More merge conflicts resolution
yvolynets-mlnx 40d28f0
Merge branch 'master' into drop_count_igmp_fix
yvolynets-mlnx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -854,7 +854,7 @@ def test_ip_pkt_with_expired_ttl(ptfadapter, duthost, setup, tx_dut_ports, pkt_f | |
| do_test("L3", pkt, ptfadapter, duthost, ports_info, setup["neighbor_sniff_ports"], tx_dut_ports) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("igmp_version,msg_type", [("v1", "membership_query"), ("v3", "membership_query"), ("v1", "membership_report"), | ||
| @pytest.mark.parametrize("igmp_version,msg_type", [("v1", "general_query"), ("v3", "general_query"), ("v1", "membership_report"), | ||
| ("v2", "membership_report"), ("v3", "membership_report"), ("v2", "leave_group")]) | ||
| def test_non_routable_igmp_pkts(ptfadapter, duthost, setup, tx_dut_ports, pkt_fields, igmp_version, msg_type, ports_info): | ||
| """ | ||
|
|
@@ -875,7 +875,7 @@ def test_non_routable_igmp_pkts(ptfadapter, duthost, setup, tx_dut_ports, pkt_fi | |
| # Leave Message ALL-ROUTERS (224.0.0.2) | ||
|
|
||
| # TODO: fix this workaround as of now current PTF and Scapy versions do not support creation of IGMP packets | ||
| # Temporaly created hex of IGMP packet layer | ||
| # Temporaly created hex of IGMP packet layer by using scapy version 2.4.3. | ||
| # Example how to get HEX of specific IGMP packets: | ||
| # v3_membership_query = IGMPv3(type=0x11, mrcode=0, chksum=None)/scapy.contrib.igmpv3.IGMPv3mq(gaddr="224.0.0.1", | ||
| # srcaddrs=["172.16.11.1", "10.0.0.59"], qrv=1, qqic=125, numsrc=2) | ||
|
|
@@ -885,33 +885,45 @@ def test_non_routable_igmp_pkts(ptfadapter, duthost, setup, tx_dut_ports, pkt_fi | |
| # records=[gr_obj]).build() | ||
| # The rest packets are build like "simple_igmp_packet" function from PTF testutils.py | ||
|
|
||
| ethernet_dst = {"membership_query": "01:00:5e:00:00:01", | ||
| "membership_report": "01:00:5e:02:02:04", | ||
| "leave_group": "01:00:5e:00:00:02"} | ||
| ip_dst = {"membership_query": "224.0.0.1", | ||
| "membership_report": "224.2.2.4", | ||
| "leave_group": "224.0.0.2"} | ||
| igmp_types = {"v1": {"membership_query": "\x11\x00\x0e\xfe\xe0\x00\x00\x01", | ||
| "membership_report": "\x12\x00\x0b\xf9\xe0\x02\x02\x04"}, | ||
| "v2": {"membership_report": "\x16\x00\x07\xf9\xe0\x02\x02\x04", | ||
| "leave_group": "\x17\x00\x08\xfd\xe0\x00\x00\x02"}, | ||
| "v3": {"membership_query": "\x11\x00L2\xe0\x00\x00\x01\x01}\x00\x02\xac\x10\x0b\x01\n\x00\x00;", | ||
| "membership_report": "\"\x009\xa9\x00\x00\x00\x01\x01\x00\x00\x02\xe0\x02\x02\x04\xac\x10\x0b\x01\n\x00\x00;"} | ||
| } | ||
| from scapy.contrib.igmp import IGMP | ||
| Ether = testutils.scapy.Ether | ||
| IP = testutils.scapy.IP | ||
|
|
||
| log_pkt_params(ports_info["dut_iface"], ethernet_dst[msg_type], ports_info["src_mac"], ip_dst[msg_type], pkt_fields["ipv4_src"]) | ||
| if "vlan" in tx_dut_ports[ports_info["dut_iface"]].lower() and msg_type == "membership_report": | ||
| pytest.skip("Test case is not supported on VLAN interface") | ||
|
|
||
| pkt = testutils.simple_ip_packet( | ||
| eth_dst=ethernet_dst[msg_type], # DUT port | ||
| eth_src=ports_info["src_mac"], # PTF port | ||
| ip_src=pkt_fields["ipv4_src"], # PTF source | ||
| ip_dst=ip_dst[msg_type], | ||
| ip_ttl=1, | ||
| ) | ||
| igmp_proto = 0x02 | ||
| multicast_group_addr = "224.1.1.1" | ||
| ethernet_dst = "01:00:5e:01:01:01" | ||
| ip_dst = {"general_query": "224.0.0.1", | ||
| "membership_report": multicast_group_addr} | ||
| igmp_types = {"v1": {"general_query": IGMP(type=0x11, gaddr="224.0.0.1"), | ||
| "membership_report": IGMP(type=0x12, gaddr=multicast_group_addr)}, | ||
| "v2": {"membership_report": IGMP(type=0x16, gaddr=multicast_group_addr), | ||
| "leave_group": IGMP(type=0x17, gaddr=multicast_group_addr)}, | ||
| "v3": {"general_query": "\x11\x00L2\xe0\x00\x00\x01\x01}\x00\x02\xac\x10\x0b\x01\n\x00\x00;", | ||
| "membership_report": "\"\x009\xa9\x00\x00\x00\x01\x01\x00\x00\x02\xe0\x02\x02\x04\xac\x10\x0b\x01\n\x00\x00;"} | ||
| } | ||
|
|
||
| del pkt[testutils.scapy.scapy.all.Raw] | ||
| pkt = pkt / igmp_types[igmp_version][msg_type] | ||
| if igmp_version == "v3": | ||
| pkt = testutils.simple_ip_packet( | ||
| eth_dst=ethernet_dst, | ||
| eth_src=ports_info["src_mac"], | ||
| ip_src=pkt_fields["ipv4_src"], | ||
| ip_dst=ip_dst[msg_type], | ||
| ip_ttl=1, | ||
| ip_proto=igmp_proto | ||
| ) | ||
| del pkt["Raw"] | ||
yvolynets-mlnx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pkt = pkt / igmp_types[igmp_version][msg_type] | ||
| else: | ||
| eth_layer = Ether(src=ports_info["src_mac"], dst=ethernet_dst) | ||
| ip_layer = IP(src=pkt_fields["ipv4_src"], ) | ||
| igmp_layer = igmp_types[igmp_version][msg_type] | ||
| assert igmp_layer.igmpize(ip=ip_layer, ether=eth_layer), "Can't create IGMP packet" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor issue. please use pytest_assert instead. There are known issue with assert. |
||
| pkt = eth_layer/ip_layer/igmp_layer | ||
|
|
||
| log_pkt_params(ports_info["dut_iface"], ethernet_dst, ports_info["src_mac"], pkt.getlayer("IP").dst, pkt_fields["ipv4_src"]) | ||
| do_test("L3", pkt, ptfadapter, duthost, ports_info, setup["dut_to_ptf_port_map"].values(), tx_dut_ports) | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.