X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_ip4.py;h=346904ab9816a24d9ad9e49560b499d52be3c396;hb=4271c971919bb8defa3ca54f4a362676cd57bfb2;hp=6f764373075fdd9aa2a5f683b6d5bb22bbc53bba;hpb=a5b2eec0535f9025319a752891d77ff9948ae0df;p=vpp.git diff --git a/test/test_ip4.py b/test/test_ip4.py index 6f764373075..346904ab981 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -18,10 +18,20 @@ from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \ VppMplsTable, VppIpTable from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint +NUM_PKTS = 67 + class TestIPv4(VppTestCase): """ IPv4 Test Case """ + @classmethod + def setUpClass(cls): + super(TestIPv4, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPv4, cls).tearDownClass() + def setUp(self): """ Perform test setup before test case. @@ -74,9 +84,10 @@ class TestIPv4(VppTestCase): def tearDown(self): """Run standard test teardown and log ``show ip arp``.""" super(TestIPv4, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.cli("show ip arp")) - # info(self.vapi.cli("show ip fib")) # many entries + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.cli("show ip arp")) + # info(self.vapi.cli("show ip fib")) # many entries def config_fib_entries(self, count): """For each interface add to the FIB table *count* routes to @@ -229,6 +240,14 @@ class TestIPv4(VppTestCase): class TestICMPEcho(VppTestCase): """ ICMP Echo Test Case """ + @classmethod + def setUpClass(cls): + super(TestICMPEcho, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestICMPEcho, cls).tearDownClass() + def setUp(self): super(TestICMPEcho, self).setUp() @@ -442,6 +461,10 @@ class TestIPv4FibCrud(VppTestCase): super(TestIPv4FibCrud, cls).tearDownClass() raise + @classmethod + def tearDownClass(cls): + super(TestIPv4FibCrud, cls).tearDownClass() + def setUp(self): super(TestIPv4FibCrud, self).setUp() self.reset_packet_infos() @@ -568,6 +591,14 @@ class TestIPv4FibCrud(VppTestCase): class TestIPNull(VppTestCase): """ IPv4 routes via NULL """ + @classmethod + def setUpClass(cls): + super(TestIPNull, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPNull, cls).tearDownClass() + def setUp(self): super(TestIPNull, self).setUp() @@ -658,7 +689,7 @@ class TestIPNull(VppTestCase): self.pg1.sw_if_index)]) r1.add_vpp_config() - rx = self.send_and_expect(self.pg0, p * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) # # insert a more specific as a drop @@ -666,14 +697,22 @@ class TestIPNull(VppTestCase): r2 = VppIpRoute(self, "1.1.1.1", 32, [], is_drop=1) r2.add_vpp_config() - self.send_and_assert_no_replies(self.pg0, p * 65, "Drop Route") + self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS, "Drop Route") r2.remove_vpp_config() - rx = self.send_and_expect(self.pg0, p * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) class TestIPDisabled(VppTestCase): """ IPv4 disabled """ + @classmethod + def setUpClass(cls): + super(TestIPDisabled, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPDisabled, cls).tearDownClass() + def setUp(self): super(TestIPDisabled, self).setUp() @@ -762,13 +801,21 @@ class TestIPDisabled(VppTestCase): class TestIPSubNets(VppTestCase): """ IPv4 Subnets """ + @classmethod + def setUpClass(cls): + super(TestIPSubNets, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPSubNets, cls).tearDownClass() + def setUp(self): super(TestIPSubNets, self).setUp() # create a 2 pg interfaces self.create_pg_interfaces(range(2)) - # pg0 we will use to experiemnt + # pg0 we will use to experiment self.pg0.admin_up() # pg1 is setup normally @@ -875,6 +922,14 @@ class TestIPSubNets(VppTestCase): class TestIPLoadBalance(VppTestCase): """ IPv4 Load-Balancing """ + @classmethod + def setUpClass(cls): + super(TestIPLoadBalance, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPLoadBalance, cls).tearDownClass() + def setUp(self): super(TestIPLoadBalance, self).setUp() @@ -899,9 +954,13 @@ class TestIPLoadBalance(VppTestCase): input.add_stream(pkts) self.pg_enable_capture(self.pg_interfaces) self.pg_start() + rxs = [] for oo in outputs: rx = oo._get_capture(1) self.assertNotEqual(0, len(rx)) + for r in rx: + rxs.append(r) + return rxs def send_and_expect_one_itf(self, input, pkts, itf): input.add_stream(pkts) @@ -924,7 +983,7 @@ class TestIPLoadBalance(VppTestCase): src_ip_pkts = [] src_mpls_pkts = [] - for ii in range(65): + for ii in range(NUM_PKTS): port_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.1") / UDP(sport=1234, dport=1234 + ii) / Raw('\xa5' * 100)) @@ -963,7 +1022,7 @@ class TestIPLoadBalance(VppTestCase): # src,dst # We are not going to ensure equal amounts of packets across each link, # since the hash algorithm is statistical and therefore this can never - # be guaranteed. But wuth 64 different packets we do expect some + # be guaranteed. But with 64 different packets we do expect some # balancing. So instead just ensure there is traffic on each link. # self.send_and_expect_load_balancing(self.pg0, port_ip_pkts, @@ -1037,6 +1096,53 @@ class TestIPLoadBalance(VppTestCase): [self.pg1, self.pg2, self.pg3, self.pg4]) + # + # bring down pg1 expect LB to adjust to use only those that are pu + # + self.pg1.link_down() + + rx = self.send_and_expect_load_balancing(self.pg0, src_pkts, + [self.pg2, self.pg3, + self.pg4]) + self.assertEqual(len(src_pkts), len(rx)) + + # + # bring down pg2 expect LB to adjust to use only those that are pu + # + self.pg2.link_down() + + rx = self.send_and_expect_load_balancing(self.pg0, src_pkts, + [self.pg3, self.pg4]) + self.assertEqual(len(src_pkts), len(rx)) + + # + # bring the links back up - expect LB over all again + # + self.pg1.link_up() + self.pg2.link_up() + + rx = self.send_and_expect_load_balancing(self.pg0, src_pkts, + [self.pg1, self.pg2, + self.pg3, self.pg4]) + self.assertEqual(len(src_pkts), len(rx)) + + # + # The same link-up/down but this time admin state + # + self.pg1.admin_down() + self.pg2.admin_down() + rx = self.send_and_expect_load_balancing(self.pg0, src_pkts, + [self.pg3, self.pg4]) + self.assertEqual(len(src_pkts), len(rx)) + self.pg1.admin_up() + self.pg2.admin_up() + self.pg1.resolve_arp() + self.pg2.resolve_arp() + rx = self.send_and_expect_load_balancing(self.pg0, src_pkts, + [self.pg1, self.pg2, + self.pg3, self.pg4]) + self.assertEqual(len(src_pkts), len(rx)) + # # Recursive prefixes # - testing that 2 stages of load-balancing, no choices @@ -1060,15 +1166,53 @@ class TestIPLoadBalance(VppTestCase): route_1_1_1_2.add_vpp_config() # - # inject the packet on pg0 - expect load-balancing across all 4 paths + # inject the packet on pg0 - rx only on via routes output interface # self.vapi.cli("clear trace") self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3) + # + # Add a LB route in the presence of a down link - expect no + # packets over the down link + # + self.pg3.link_down() + + route_10_0_0_3 = VppIpRoute(self, "10.0.0.3", 32, + [VppRoutePath(self.pg3.remote_ip4, + self.pg3.sw_if_index), + VppRoutePath(self.pg4.remote_ip4, + self.pg4.sw_if_index)]) + route_10_0_0_3.add_vpp_config() + + port_pkts = [] + for ii in range(257): + port_pkts.append(Ether(src=self.pg0.remote_mac, + dst=self.pg0.local_mac) / + IP(dst="10.0.0.3", src="20.0.0.2") / + UDP(sport=1234, dport=1234 + ii) / + Raw('\xa5' * 100)) + + self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg4) + + # bring the link back up + self.pg3.link_up() + + rx = self.send_and_expect_load_balancing(self.pg0, port_pkts, + [self.pg3, self.pg4]) + self.assertEqual(len(src_pkts), len(rx)) + class TestIPVlan0(VppTestCase): """ IPv4 VLAN-0 """ + @classmethod + def setUpClass(cls): + super(TestIPVlan0, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPVlan0, cls).tearDownClass() + def setUp(self): super(TestIPVlan0, self).setUp() @@ -1098,7 +1242,7 @@ class TestIPVlan0(VppTestCase): IP(dst=self.pg1.remote_ip4, src=self.pg0.remote_ip4) / UDP(sport=1234, dport=1234) / - Raw('\xa5' * 100)) * 65 + Raw('\xa5' * 100)) * NUM_PKTS # # Expect that packets sent on VLAN-0 are forwarded on the @@ -1110,6 +1254,14 @@ class TestIPVlan0(VppTestCase): class TestIPPunt(VppTestCase): """ IPv4 Punt Police/Redirect """ + @classmethod + def setUpClass(cls): + super(TestIPPunt, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPPunt, cls).tearDownClass() + def setUp(self): super(TestIPPunt, self).setUp() @@ -1160,7 +1312,7 @@ class TestIPPunt(VppTestCase): self.pg_start() # - # the number of packet recieved should be greater than 0, + # the number of packet received should be greater than 0, # but not equal to the number sent, since some were policed # rx = self.pg1._get_capture(1) @@ -1168,7 +1320,7 @@ class TestIPPunt(VppTestCase): self.assertLess(len(rx), len(pkts)) # - # remove the poilcer. back to full rx + # remove the policer. back to full rx # self.vapi.ip_punt_police(policer.policer_index, is_add=0) self.vapi.policer_add_del(b"ip4-punt", 400, 0, 10, 0, @@ -1236,6 +1388,14 @@ class TestIPPunt(VppTestCase): class TestIPDeag(VppTestCase): """ IPv4 Deaggregate Routes """ + @classmethod + def setUpClass(cls): + super(TestIPDeag, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPDeag, cls).tearDownClass() + def setUp(self): super(TestIPDeag, self).setUp() @@ -1345,6 +1505,14 @@ class TestIPDeag(VppTestCase): class TestIPInput(VppTestCase): """ IPv4 Input Exceptions """ + @classmethod + def setUpClass(cls): + super(TestIPInput, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPInput, cls).tearDownClass() + def setUp(self): super(TestIPInput, self).setUp() @@ -1378,7 +1546,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_short * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p_short * NUM_PKTS, self.pg1) # # Packet too long - this is dropped @@ -1391,7 +1559,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_long * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_long * NUM_PKTS, "too long") # @@ -1405,7 +1573,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_chksum * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_chksum * NUM_PKTS, "bad checksum") # @@ -1419,7 +1587,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_ver * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_ver * NUM_PKTS, "funky version") # @@ -1433,7 +1601,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_frag * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_frag * NUM_PKTS, "frag offset") # @@ -1447,7 +1615,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_ttl * 65, self.pg0) + rx = self.send_and_expect(self.pg0, p_ttl * NUM_PKTS, self.pg0) rx = rx[0] icmp = rx[ICMP] @@ -1471,7 +1639,7 @@ class TestIPInput(VppTestCase): self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1500, 0, 0, 0]) - rx = self.send_and_expect(self.pg0, p_mtu * 65, self.pg0) + rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg0) rx = rx[0] icmp = rx[ICMP] @@ -1482,7 +1650,7 @@ class TestIPInput(VppTestCase): self.assertEqual(icmp.dst, self.pg1.remote_ip4) self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [2500, 0, 0, 0]) - rx = self.send_and_expect(self.pg0, p_mtu * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg1) # Reset MTU for subsequent tests self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [9000, 0, 0, 0]) @@ -1510,6 +1678,14 @@ class TestIPInput(VppTestCase): class TestIPDirectedBroadcast(VppTestCase): """ IPv4 Directed Broadcast """ + @classmethod + def setUpClass(cls): + super(TestIPDirectedBroadcast, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPDirectedBroadcast, cls).tearDownClass() + def setUp(self): super(TestIPDirectedBroadcast, self).setUp() @@ -1553,10 +1729,10 @@ class TestIPDirectedBroadcast(VppTestCase): # # test packet is L2 broadcast # - rx = self.send_and_expect(self.pg1, p0 * 65, self.pg0) + rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0) self.assertTrue(rx[0][Ether].dst, "ff:ff:ff:ff:ff:ff") - self.send_and_assert_no_replies(self.pg0, p1 * 65, + self.send_and_assert_no_replies(self.pg0, p1 * NUM_PKTS, "directed broadcast disabled") # @@ -1564,12 +1740,12 @@ class TestIPDirectedBroadcast(VppTestCase): # self.vapi.sw_interface_set_ip_directed_broadcast( self.pg0.sw_if_index, 0) - self.send_and_assert_no_replies(self.pg1, p0 * 65, + self.send_and_assert_no_replies(self.pg1, p0 * NUM_PKTS, "directed broadcast disabled") self.vapi.sw_interface_set_ip_directed_broadcast( self.pg0.sw_if_index, 1) - rx = self.send_and_expect(self.pg1, p0 * 65, self.pg0) + rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0) self.pg0.unconfig_ip4() self.pg1.unconfig_ip4() @@ -1578,6 +1754,14 @@ class TestIPDirectedBroadcast(VppTestCase): class TestIPLPM(VppTestCase): """ IPv4 longest Prefix Match """ + @classmethod + def setUpClass(cls): + super(TestIPLPM, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPLPM, cls).tearDownClass() + def setUp(self): super(TestIPLPM, self).setUp() @@ -1620,8 +1804,8 @@ class TestIPLPM(VppTestCase): Raw('\xa5' * 2000)) self.logger.info(self.vapi.cli("sh ip fib mtrie")) - rx = self.send_and_expect(self.pg0, p_8 * 65, self.pg2) - rx = self.send_and_expect(self.pg0, p_24 * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p_8 * NUM_PKTS, self.pg2) + rx = self.send_and_expect(self.pg0, p_24 * NUM_PKTS, self.pg1) class TestIPv4Frag(VppTestCase): @@ -1641,6 +1825,10 @@ class TestIPv4Frag(VppTestCase): i.config_ip4() i.resolve_arp() + @classmethod + def tearDownClass(cls): + super(TestIPv4Frag, cls).tearDownClass() + def test_frag_large_packets(self): """ Fragmentation of large packets """