X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_ipip.py;h=6f1d3b883c0a68493c6a42c5668015ec7f39f0b8;hb=59fa121f8;hp=c01972a24138abb63915a614da312f7dab0f9b79;hpb=8feeaff56fa9a4fbdfc06131f28a1060ffd9645d;p=vpp.git diff --git a/test/test_ipip.py b/test/test_ipip.py index c01972a2413..6f1d3b883c0 100644 --- a/test/test_ipip.py +++ b/test/test_ipip.py @@ -17,6 +17,19 @@ IPIP tests. """ +def ipip_add_tunnel(test, src, dst, table_id=0, tc_tos=0xff): + """ Add a IPIP tunnel """ + return test.vapi.ipip_add_tunnel( + tunnel={ + 'src': src, + 'dst': dst, + 'table_id': table_id, + 'instance': 0xffffffff, + 'tc_tos': tc_tos + } + ) + + class TestIPIP(VppTestCase): """ IPIP Test Case """ @@ -26,6 +39,10 @@ class TestIPIP(VppTestCase): cls.create_pg_interfaces(range(2)) cls.interfaces = list(cls.pg_interfaces) + @classmethod + def tearDownClass(cls): + super(TestIPIP, cls).tearDownClass() + def setUp(self): super(TestIPIP, self).setUp() for i in self.interfaces: @@ -67,10 +84,10 @@ class TestIPIP(VppTestCase): p_payload = UDP(sport=1234, dport=1234) # IPv4 transport - rv = self.vapi.ipip_add_tunnel( - src_address=self.pg0.local_ip4n, - dst_address=self.pg1.remote_ip4n, - is_ipv6=0, tc_tos=0xFF) + rv = ipip_add_tunnel(self, + self.pg0.local_ip4, + self.pg1.remote_ip4, + tc_tos=0xFF) sw_if_index = rv.sw_if_index # Set interface up and enable IP on it @@ -131,7 +148,7 @@ class TestIPIP(VppTestCase): for p in rx: self.validate(p[1], p4_reply) - err = self.statistics.get_counter( + err = self.statistics.get_err_counter( '/err/ipip4-input/packets decapsulated') self.assertEqual(err, 10) @@ -145,7 +162,7 @@ class TestIPIP(VppTestCase): for p in rx: self.validate(p[1], p6_reply) - err = self.statistics.get_counter( + err = self.statistics.get_err_counter( '/err/ipip4-input/packets decapsulated') self.assertEqual(err, 20) @@ -156,6 +173,11 @@ class TestIPIP(VppTestCase): sw_if_index=self.pg1.sw_if_index, enable_ip4=1) + self.vapi.ip_reassembly_set(timeout_ms=1000, max_reassemblies=1000, + max_reassembly_length=1000, + expire_walk_interval_ms=10000, + is_ip6=0) + # Send lots of fragments, verify reassembled packet frags, p4_reply = self.generate_ip4_frags(3131, 1400) f = [] @@ -169,7 +191,7 @@ class TestIPIP(VppTestCase): for p in rx: self.validate(p[1], p4_reply) - err = self.statistics.get_counter( + err = self.statistics.get_err_counter( '/err/ipip4-input/packets decapsulated') self.assertEqual(err, 1020) @@ -217,9 +239,7 @@ class TestIPIP(VppTestCase): def test_ipip_create(self): """ ipip create / delete interface test """ - rv = self.vapi.ipip_add_tunnel( - src_address=inet_pton(AF_INET, '1.2.3.4'), - dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0) + rv = ipip_add_tunnel(self, '1.2.3.4', '2.3.4.5') sw_if_index = rv.sw_if_index self.vapi.ipip_del_tunnel(sw_if_index) @@ -228,10 +248,7 @@ class TestIPIP(VppTestCase): t = VppIpTable(self, 20) t.add_vpp_config() - rv = self.vapi.ipip_add_tunnel( - src_address=inet_pton(AF_INET, '1.2.3.4'), - dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0, - table_id=20) + rv = ipip_add_tunnel(self, '1.2.3.4', '2.3.4.5', table_id=20) sw_if_index = rv.sw_if_index self.vapi.ipip_del_tunnel(sw_if_index) @@ -248,6 +265,10 @@ class TestIPIP6(VppTestCase): cls.create_pg_interfaces(range(2)) cls.interfaces = list(cls.pg_interfaces) + @classmethod + def tearDownClass(cls): + super(TestIPIP6, cls).tearDownClass() + def setUp(self): super(TestIPIP6, self).setUp() for i in self.interfaces: @@ -270,9 +291,10 @@ class TestIPIP6(VppTestCase): def setup_tunnel(self): # IPv6 transport - rv = self.vapi.ipip_add_tunnel( - src_address=self.pg0.local_ip6n, - dst_address=self.pg1.remote_ip6n, tc_tos=255) + rv = ipip_add_tunnel(self, + self.pg0.local_ip6, + self.pg1.remote_ip6, + tc_tos=255) sw_if_index = rv.sw_if_index self.tunnel_if_index = sw_if_index @@ -407,8 +429,13 @@ class TestIPIP6(VppTestCase): sw_if_index=self.pg1.sw_if_index, enable_ip6=1) + self.vapi.ip_reassembly_set(timeout_ms=1000, max_reassemblies=1000, + max_reassembly_length=1000, + expire_walk_interval_ms=10000, + is_ip6=1) + # Send lots of fragments, verify reassembled packet - before_cnt = self.statistics.get_counter( + before_cnt = self.statistics.get_err_counter( '/err/ipip6-input/packets decapsulated') frags, p6_reply = self.generate_ip6_frags(3131, 1400) f = [] @@ -422,7 +449,7 @@ class TestIPIP6(VppTestCase): for p in rx: self.validate(p[1], p6_reply) - cnt = self.statistics.get_counter( + cnt = self.statistics.get_err_counter( '/err/ipip6-input/packets decapsulated') self.assertEqual(cnt, before_cnt + 1000) @@ -484,9 +511,7 @@ class TestIPIP6(VppTestCase): def test_ipip_create(self): """ ipip create / delete interface test """ - rv = self.vapi.ipip_add_tunnel( - src_address=inet_pton(AF_INET, '1.2.3.4'), - dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0) + rv = ipip_add_tunnel(self, '1.2.3.4', '2.3.4.5') sw_if_index = rv.sw_if_index self.vapi.ipip_del_tunnel(sw_if_index) @@ -495,10 +520,7 @@ class TestIPIP6(VppTestCase): t = VppIpTable(self, 20) t.add_vpp_config() - rv = self.vapi.ipip_add_tunnel( - src_address=inet_pton(AF_INET, '1.2.3.4'), - dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0, - table_id=20) + rv = ipip_add_tunnel(self, '1.2.3.4', '2.3.4.5', table_id=20) sw_if_index = rv.sw_if_index self.vapi.ipip_del_tunnel(sw_if_index)