X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_igmp.py;h=8053bc3d544f97a1d7ae7f513cba86adc0aa0455;hb=c3cb2075d;hp=c1452c9b83fbe5c2dc44c90b13446a3cfc8f5f95;hpb=0f7af53e73c47a96cc0546671a0d0a5fb5f4366c;p=vpp.git diff --git a/test/test_igmp.py b/test/test_igmp.py index c1452c9b83f..8053bc3d544 100644 --- a/test/test_igmp.py +++ b/test/test_igmp.py @@ -1,14 +1,16 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import unittest -from framework import VppTestCase, VppTestRunner, running_extended_tests -from vpp_igmp import * - from scapy.layers.l2 import Ether -from scapy.layers.inet import IP -from scapy.contrib.igmpv3 import * -from scapy.contrib.igmp import * +from scapy.packet import Raw +from scapy.layers.inet import IP, IPOption +from scapy.contrib.igmpv3 import IGMPv3, IGMPv3gr, IGMPv3mq, IGMPv3mr + +from framework import tag_fixme_vpp_workers +from framework import VppTestCase, VppTestRunner, running_extended_tests +from vpp_igmp import find_igmp_state, IGMP_FILTER, IgmpRecord, IGMP_MODE, \ + IgmpSG, VppHostState, wait_for_igmp_event from vpp_ip_route import find_mroute, VppIpTable @@ -17,9 +19,18 @@ class IgmpMode: ROUTER = 0 +@tag_fixme_vpp_workers class TestIgmp(VppTestCase): """ IGMP Test Case """ + @classmethod + def setUpClass(cls): + super(TestIgmp, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIgmp, cls).tearDownClass() + def setUp(self): super(TestIgmp, self).setUp() @@ -81,10 +92,10 @@ class TestIgmp(VppTestCase): self.vapi.igmp_enable_disable(self.pg2.sw_if_index, 0, IGMP_MODE.HOST) self.vapi.igmp_enable_disable(self.pg3.sw_if_index, 0, IGMP_MODE.HOST) - self.assertFalse(find_mroute(self, "224.0.0.1", "0.0.0.0", 32)) + self.assertTrue(find_mroute(self, "224.0.0.1", "0.0.0.0", 32)) self.assertFalse(find_mroute(self, "224.0.0.22", "0.0.0.0", 32)) - self.assertFalse(find_mroute(self, "224.0.0.1", "0.0.0.0", 32, - table_id=1)) + self.assertTrue(find_mroute(self, "224.0.0.1", "0.0.0.0", 32, + table_id=1)) self.assertFalse(find_mroute(self, "224.0.0.22", "0.0.0.0", 32, table_id=1)) @@ -186,12 +197,15 @@ class TestIgmp(VppTestCase): # # Send a general query (to the all router's address) - # expect VPP to respond with a membership report + # expect VPP to respond with a membership report. + # Pad the query with 0 - some devices in the big wild + # internet are prone to this. # p_g = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / IP(src=self.pg0.remote_ip4, dst='224.0.0.1', tos=0xc0) / IGMPv3(type="Membership Query", mrcode=100) / - IGMPv3mq(gaddr="0.0.0.0")) + IGMPv3mq(gaddr="0.0.0.0") / + Raw(b'\x00' * 10)) self.send(self.pg0, p_g) @@ -232,6 +246,19 @@ class TestIgmp(VppTestCase): self.verify_report(capture[0], [IgmpRecord(h1.sg, "Mode Is Include")]) + # + # A group and source specific query that reports more sources + # than the packet actually has. + # + p_gs2 = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / + IP(src=self.pg0.remote_ip4, dst='239.1.1.1', tos=0xc0, + options=[IPOption(copy_flag=1, optclass="control", + option="router_alert")]) / + IGMPv3(type="Membership Query", mrcode=100) / + IGMPv3mq(gaddr="239.1.1.1", numsrc=4, srcaddrs=["1.1.1.1"])) + + self.send_and_assert_no_replies(self.pg0, p_gs2, timeout=10) + # # A group and source specific query, with the source NOT matching # the source VPP has. There should be no response. @@ -265,7 +292,7 @@ class TestIgmp(VppTestCase): [IgmpRecord(h1.sg, "Mode Is Include")]) # - # Two source and group specific queires in qucik sucession, the + # Two source and group specific queries in quick succession, the # first does not have VPPs source the second does. then vice-versa # self.send(self.pg0, [p_gs2, p_gs1]) @@ -445,6 +472,8 @@ class TestIgmp(VppTestCase): h10.add_vpp_config() capture = self.pg0.get_capture(2, timeout=10) + # wait for a little bit + self.sleep(1) # # remove state, expect the report for the removal @@ -554,7 +583,7 @@ class TestIgmp(VppTestCase): # # resend the join. wait for two queries and then send a current-state - # record to include all sources. this should reset the exiry time + # record to include all sources. this should reset the expiry time # on the sources and thus they will still be present in 2 seconds time. # If the source timer was not refreshed, then the state would have # expired in 3 seconds. @@ -601,7 +630,7 @@ class TestIgmp(VppTestCase): self.assertFalse(self.vapi.igmp_dump()) # - # resend the join, then a leave. Router sends a gruop+source + # resend the join, then a leave. Router sends a group+source # specific query containing both sources # self.send(self.pg0, p_j) @@ -658,7 +687,7 @@ class TestIgmp(VppTestCase): "239.1.1.3", "0.0.0.0", 1)) # - # A 'allow sourcees' for {} should be ignored as it should + # A 'allow sources' for {} should be ignored as it should # never be sent. # p_j = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /