X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=test%2Ftest_mpls.py;h=8d5d5abb48df0c75d28aeb8b66b74bf4fb1b87d1;hb=8feeaff56;hp=d943f8281e9b41092514ebaa5228fc791d8c645d;hpb=c0a93143412b4be7bba087bf633855aeeaee7c56;p=vpp.git diff --git a/test/test_mpls.py b/test/test_mpls.py index d943f8281e9..8d5d5abb48d 100644 --- a/test/test_mpls.py +++ b/test/test_mpls.py @@ -8,9 +8,10 @@ from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute, \ VppMplsIpBind, VppIpMRoute, VppMRoutePath, \ MRouteItfFlags, MRouteEntryFlags, VppIpTable, VppMplsTable, \ - VppMplsLabel, MplsLspMode + VppMplsLabel, MplsLspMode, find_mpls_route from vpp_mpls_tunnel_interface import VppMPLSTunnelInterface +import scapy.compat from scapy.packet import Raw from scapy.layers.l2 import Ether from scapy.layers.inet import IP, UDP, ICMP @@ -360,7 +361,7 @@ class TestMPLS(VppTestCase): # ICMP sourced from the interface's address self.assertEqual(rx_ip.src, src_if.local_ip6) # hop-limit reset to 255 for IMCP packet - self.assertEqual(rx_ip.hlim, 254) + self.assertEqual(rx_ip.hlim, 255) icmp = rx[ICMPv6TimeExceeded] @@ -379,6 +380,12 @@ class TestMPLS(VppTestCase): labels=[VppMplsLabel(33)])]) route_32_eos.add_vpp_config() + self.assertTrue( + find_mpls_route(self, 0, 32, 1, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[VppMplsLabel(33)])])) + # # a stream that matches the route for 10.0.0.1 # PG0 is in the default table @@ -389,6 +396,8 @@ class TestMPLS(VppTestCase): self.verify_capture_labelled(self.pg0, rx, tx, [VppMplsLabel(33, ttl=31, exp=1)]) + self.assertEqual(route_32_eos.get_stats_to()['packets'], 257) + # # A simple MPLS xconnect - non-eos label in label out # @@ -409,6 +418,7 @@ class TestMPLS(VppTestCase): self.verify_capture_labelled(self.pg0, rx, tx, [VppMplsLabel(33, ttl=20, exp=7), VppMplsLabel(99)]) + self.assertEqual(route_32_neos.get_stats_to()['packets'], 257) # # A simple MPLS xconnect - non-eos label in label out, uniform mode @@ -442,7 +452,7 @@ class TestMPLS(VppTestCase): self.verify_capture_ip4(self.pg0, rx, tx) # - # disposed packets have an invalid IPv4 checkusm + # disposed packets have an invalid IPv4 checksum # tx = self.create_stream_labelled_ip4(self.pg0, [VppMplsLabel(33)], dst_ip=self.pg0.remote_ip4, @@ -575,6 +585,9 @@ class TestMPLS(VppTestCase): VppMplsLabel(44), VppMplsLabel(45, ttl=2)]) + self.assertEqual(route_34_eos.get_stats_to()['packets'], 257) + self.assertEqual(route_32_neos.get_stats_via()['packets'], 257) + # # A recursive EOS x-connect, which resolves through another x-connect # in uniform mode @@ -635,6 +648,7 @@ class TestMPLS(VppTestCase): VppMplsLabel(44), VppMplsLabel(46), VppMplsLabel(55)]) + self.assertEqual(ip_10_0_0_1.get_stats_to()['packets'], 257) ip_10_0_0_1.remove_vpp_config() route_34_neos.remove_vpp_config() @@ -782,6 +796,8 @@ class TestMPLS(VppTestCase): [VppMplsLabel(32), VppMplsLabel(44)]) + self.assertEqual(route_11_0_0_1.get_stats_to()['packets'], 257) + # # add a recursive path, with 2 labels, via the 3 label route # @@ -805,6 +821,18 @@ class TestMPLS(VppTestCase): VppMplsLabel(44), VppMplsLabel(45)]) + self.assertEqual(route_11_0_0_2.get_stats_to()['packets'], 257) + + rx = self.send_and_expect(self.pg0, tx, self.pg0) + self.verify_capture_labelled_ip4(self.pg0, rx, tx, + [VppMplsLabel(32), + VppMplsLabel(33), + VppMplsLabel(34), + VppMplsLabel(44), + VppMplsLabel(45)]) + + self.assertEqual(route_11_0_0_2.get_stats_to()['packets'], 514) + # # cleanup # @@ -929,6 +957,19 @@ class TestMPLS(VppTestCase): VppMplsLabel(46, ttl=47), VppMplsLabel(33, ttl=47)]) + def test_mpls_tunnel_many(self): + """ Multiple Tunnels """ + + for ii in range(10): + mpls_tun = VppMPLSTunnelInterface( + self, + [VppRoutePath(self.pg0.remote_ip4, + self.pg0.sw_if_index, + labels=[VppMplsLabel(44, ttl=32), + VppMplsLabel(46, MplsLspMode.UNIFORM)])]) + mpls_tun.add_vpp_config() + mpls_tun.admin_up() + def test_v4_exp_null(self): """ MPLS V4 Explicit NULL test """ @@ -1240,7 +1281,7 @@ class TestMPLS(VppTestCase): self.send_and_assert_no_replies(self.pg0, tx, "RPF-ID drop none") # - # set the RPF-ID of the enrtry to match the input packet's + # set the RPF-ID of the entry to match the input packet's # route_232_1_1_1.update_rpf_id(55) @@ -1250,7 +1291,7 @@ class TestMPLS(VppTestCase): self.verify_capture_ip4(self.pg1, rx, tx) # - # disposed packets have an invalid IPv4 checkusm + # disposed packets have an invalid IPv4 checksum # tx = self.create_stream_labelled_ip4(self.pg0, [VppMplsLabel(34)], dst_ip="232.1.1.1", n=65, @@ -1310,7 +1351,7 @@ class TestMPLS(VppTestCase): self.send_and_assert_no_replies(self.pg0, tx, "RPF Miss") # - # set the RPF-ID of the enrtry to match the input packet's + # set the RPF-ID of the entry to match the input packet's # route_ff.update_rpf_id(55) @@ -1330,7 +1371,7 @@ class TestMPLS(VppTestCase): self.verify_capture_ip6_icmp(self.pg0, rx, tx) # - # set the RPF-ID of the enrtry to not match the input packet's + # set the RPF-ID of the entry to not match the input packet's # route_ff.update_rpf_id(56) tx = self.create_stream_labelled_ip6(self.pg0, @@ -1351,7 +1392,7 @@ class TestMPLSDisabled(VppTestCase): self.tbl = VppMplsTable(self, 0) self.tbl.add_vpp_config() - # PG0 is MPLS enalbed + # PG0 is MPLS enabled self.pg0.admin_up() self.pg0.config_ip4() self.pg0.resolve_arp() @@ -1532,7 +1573,7 @@ class TestMPLSPIC(VppTestCase): rx0 = self.pg0._get_capture(1) rx1 = self.pg1._get_capture(1) - # not testig the LB hashing algorithm so we're not concerned + # not testing the LB hashing algorithm so we're not concerned # with the split ratio, just as long as neither is 0 self.assertNotEqual(0, len(rx0)) self.assertNotEqual(0, len(rx1)) @@ -1540,7 +1581,7 @@ class TestMPLSPIC(VppTestCase): # # use a test CLI command to stop the FIB walk process, this # will prevent the FIB converging the VPN routes and thus allow - # us to probe the interim (psot-fail, pre-converge) state + # us to probe the interim (post-fail, pre-converge) state # self.vapi.ppcli("test fib-walk-process disable") @@ -1640,7 +1681,7 @@ class TestMPLSPIC(VppTestCase): # # use a test CLI command to stop the FIB walk process, this # will prevent the FIB converging the VPN routes and thus allow - # us to probe the interim (psot-fail, pre-converge) state + # us to probe the interim (post-fail, pre-converge) state # self.vapi.ppcli("test fib-walk-process disable") @@ -1740,7 +1781,7 @@ class TestMPLSPIC(VppTestCase): # # use a test CLI command to stop the FIB walk process, this # will prevent the FIB converging the VPN routes and thus allow - # us to probe the interim (psot-fail, pre-converge) state + # us to probe the interim (post-fail, pre-converge) state # self.vapi.ppcli("test fib-walk-process disable") @@ -1833,7 +1874,7 @@ class TestMPLSL2(VppTestCase): verify_mpls_stack(self, rx, mpls_labels) tx_eth = tx[Ether] - rx_eth = Ether(str(rx[MPLS].payload)) + rx_eth = Ether(scapy.compat.raw(rx[MPLS].payload)) self.assertEqual(rx_eth.src, tx_eth.src) self.assertEqual(rx_eth.dst, tx_eth.dst) @@ -1896,7 +1937,7 @@ class TestMPLSL2(VppTestCase): self.assertEqual(rx0[0][Ether].src, payload[Ether].src) # - # Inject a packet from the custoer/L2 side + # Inject a packet from the customer/L2 side # tx1 = pcore[MPLS].payload * 65 rx1 = self.send_and_expect(self.pg1, tx1, self.pg0) @@ -1931,10 +1972,10 @@ class TestMPLSL2(VppTestCase): # # add to tunnel to the customers bridge-domain # - self.vapi.sw_interface_set_l2_bridge(mpls_tun.sw_if_index, - bd_id=1) - self.vapi.sw_interface_set_l2_bridge(self.pg1.sw_if_index, - bd_id=1) + self.vapi.sw_interface_set_l2_bridge( + rx_sw_if_index=mpls_tun.sw_if_index, bd_id=1) + self.vapi.sw_interface_set_l2_bridge( + rx_sw_if_index=self.pg1.sw_if_index, bd_id=1) # # Packet from the customer interface and from the core @@ -1986,12 +2027,10 @@ class TestMPLSL2(VppTestCase): # # remove interfaces from customers bridge-domain # - self.vapi.sw_interface_set_l2_bridge(mpls_tun.sw_if_index, - bd_id=1, - enable=0) - self.vapi.sw_interface_set_l2_bridge(self.pg1.sw_if_index, - bd_id=1, - enable=0) + self.vapi.sw_interface_set_l2_bridge( + rx_sw_if_index=mpls_tun.sw_if_index, bd_id=1, enable=0) + self.vapi.sw_interface_set_l2_bridge( + rx_sw_if_index=self.pg1.sw_if_index, bd_id=1, enable=0) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)