summaryrefslogtreecommitdiffstats
path: root/test/test_ip4.py
AgeCommit message (Expand)AuthorFilesLines
2018-12-06API: Change ip4_address and ip6_address to use type alias.Ole Troan1-1/+1
2018-12-05VPP-1508 python3 tests: xrangePaul Vinciguerra1-11/+13
2018-11-29VPP-1507: Added binary api to dump configured ip_punt_redirectPavel Kotucek1-4/+37
2018-11-27VPP-1508 python3 tests: .encode('hex')Paul Vinciguerra1-6/+5
2018-11-26Python3 tests: Fix asserts.Paul Vinciguerra1-2/+2
2018-10-22Fix buffer overflow when fragmenting packets (VPP-1383)Juraj Sloboda1-0/+50
2018-10-15VPP-1448: Fix error when recurse on down the trie.mu.duojiao1-0/+49
2018-09-07IP route update fix when multipath and drop setNeale Ranns1-1/+27
2018-08-03loop counter to prevent infiinte number of look ups per-packetNeale Ranns1-0/+18
2018-07-20IP directed broadcastNeale Ranns1-0/+69
2018-07-02make_test: add icmp packet size sweep and icmp echo testsJan Gelety1-24/+100
2018-06-11MTU: Software interface / Per-protocol MTU supportOle Troan1-2/+4
2018-05-23VPP-1283: IPv4 PMTU missing MTU value in ICMP4 message.Ole Troan1-1/+1
2018-04-13Revert "MTU: Setting of MTU on software interface (instead of hardware interf...Damjan Marion1-1/+1
2018-04-13MTU: Setting of MTU on software interface (instead of hardware interface)Ole Troan1-1/+1
2018-02-12Improve MTU handlingNeale Ranns1-0/+26
2018-01-09test: consolidate the multiple versions of send_and_*Neale Ranns1-73/+0
2017-11-11MPLS disposition actions at the tail of unicast LSPsNeale Ranns1-1/+0
2017-10-31Refactor IP input checks for re-use at MPLS dispositionNeale Ranns1-0/+135
2017-10-14Source Lookup progammable via APINeale Ranns1-1/+109
2017-10-10punt and drop features:Neale Ranns1-1/+111
2017-09-11FIB table add/delete APINeale Ranns1-3/+8
2017-08-01Tests for recursive load-balancing with no choices.Neale Ranns1-5/+35
2017-06-06Packets recieved on VLAN-0 map to the main interfaceNeale Ranns1-0/+46
2017-05-25MPLS hash function improvementsNeale Ranns1-18/+43
2017-04-26IP Flow Hash Config fixesNeale Ranns1-0/+137
2017-03-29Sub-net broadcast addresses for IPv4Neale Ranns1-1/+124
2017-03-17Fix IP feature ordering.Neale Ranns1-1/+98
2017-03-09Tests to target holes in adjacency and DPO test coverageNeale Ranns1-1/+82
2017-01-11make test: improve documentation and PEP8 complianceKlement Sekera1-7/+10
2016-12-23make test: improve handling of packet capturesKlement Sekera1-11/+8
2016-12-09make test: FIB add/update/delete - ip4 routesMatej Klotton1-2/+266
2016-12-05make test: fix missing log/packet messagesKlement Sekera1-7/+5
2016-11-15Update test documentation.Matej Klotton1-18/+60
2016-11-09Disable non-working checks in load-balancer test and rename ip->ip4Klement Sekera1-0/+165
n class="n">AF_INET, AF_INET6, inet_pton """ Test6rd is a subclass of VPPTestCase classes. 6RD tests. """ class Test6RD(VppTestCase): """ 6RD Test Case """ @classmethod def setUpClass(cls): super(Test6RD, cls).setUpClass() cls.create_pg_interfaces(range(4)) cls.interfaces = list(cls.pg_interfaces) @classmethod def tearDownClass(cls): super(Test6RD, cls).tearDownClass() def setUp(self): super(Test6RD, self).setUp() t4 = VppIpTable(self, 10) t6 = VppIpTable(self, 20, True) t4.add_vpp_config() t6.add_vpp_config() for n in range(4): i = self.pg_interfaces[n] i.admin_up() if (n > 1): i.set_table_ip4(10) i.set_table_ip6(20) i.config_ip4() i.config_ip6() i.disable_ipv6_ra() i.resolve_arp() i.resolve_ndp() def tearDown(self): for i in self.pg_interfaces: i.unconfig_ip4() i.unconfig_ip6() i.set_table_ip4(0) i.set_table_ip6(0) i.admin_down() super(Test6RD, self).tearDown() def validate_6in4(self, rx, expected): if IP not in rx: self.fail() if IPv6 not in rx: self.fail() self.assertEqual(rx[IP].src, expected[IP].src) self.assertEqual(rx[IP].dst, expected[IP].dst) self.assertEqual(rx[IP].proto, expected[IP].proto) self.assertEqual(rx[IPv6].src, expected[IPv6].src) self.assertEqual(rx[IPv6].dst, expected[IPv6].dst) def validate_4in6(self, rx, expected): if IPv6 not in rx: self.fail() if IP in rx: self.fail() self.assertEqual(rx[IPv6].src, expected[IPv6].src) self.assertEqual(rx[IPv6].dst, expected[IPv6].dst) self.assertEqual(rx[IPv6].nh, expected[IPv6].nh) def payload(self, len): return 'x' * len def test_6rd_ip6_to_ip4(self): """ ip6 -> ip4 (encap) 6rd test """ p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1", nh='UDP') rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg0.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index self.vapi.cli("show ip6 fib") p_payload = UDP(sport=1234, dport=1234) p = (p_ether / p_ip6 / p_payload) p_reply = (IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto='ipv6') / p_ip6) rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_6in4(p, p_reply) # MTU tests (default is 1480) plen = 1481 - 40 - 8 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1") p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen)) p = (p_ether / p_ip6 / p_payload) p_reply = (IP(src=self.pg0.local_ip4, dst=self.pg1.remote_ip4, proto='ipv6') / p_ip6) rx = self.send_and_assert_no_replies(self.pg0, p * 10) self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) def test_6rd_ip6_to_ip4_vrf(self): """ ip6 -> ip4 (encap) 6rd VRF test """ p_ether = Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1", nh='UDP') rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=20, ip4_table_id=10, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg2.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index self.vapi.cli("show ip6 fib") p_payload = UDP(sport=1234, dport=1234) p = (p_ether / p_ip6 / p_payload) p_reply = (IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto='ipv6') / p_ip6) rx = self.send_and_expect(self.pg2, p * 10, self.pg3) for p in rx: self.validate_6in4(p, p_reply) # MTU tests (default is 1480) plen = 1481 - 40 - 8 p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1") p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen)) p = (p_ether / p_ip6 / p_payload) p_reply = (IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4, proto='ipv6') / p_ip6) rx = self.send_and_assert_no_replies(self.pg0, p * 10) self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) def test_6rd_ip4_to_ip6(self): """ ip4 -> ip6 (decap) 6rd test """ rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg0.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index) rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg0.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index p_ip6 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) / p_ip6) p_reply = p_ip6 rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_4in6(p, p_reply) self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) def test_6rd_ip4_to_ip6_vrf(self): """ ip4 -> ip6 (decap) 6rd VRF test """ rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=20, ip4_table_id=10, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg2.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index) rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=20, ip4_table_id=10, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg2.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index self.vapi.sw_interface_set_table(self.tunnel_index, 1, 20) p_ip6 = (IPv6(src="2002:AC10:0402::1", dst=self.pg3.remote_ip6) / UDP(sport=1234, dport=1234)) p = (Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg3.remote_ip4, dst=self.pg2.local_ip4) / p_ip6) p_reply = p_ip6 rx = self.send_and_expect(self.pg2, p * 10, self.pg3) for p in rx: self.validate_4in6(p, p_reply) self.vapi.sw_interface_set_table(self.tunnel_index, 1, 0) self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) def test_6rd_ip4_to_ip6_multiple(self): """ ip4 -> ip6 (decap) 6rd test """ self.tunnel_index = [] rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg0.local_ip4, security_check=True) self.tunnel_index.append(rv.sw_if_index) rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2003::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg1.local_ip4, security_check=True) self.tunnel_index.append(rv.sw_if_index) self.vapi.cli("show ip6 fib") p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) p_ip6_1 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p_ip6_2 = (IPv6(src="2003:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p = (p_ether / p_ip4 / p_ip6_1) rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_4in6(p, p_ip6_1) p = (p_ether / p_ip4 / p_ip6_2) rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_4in6(p, p_ip6_2) for i in self.tunnel_index: self.vapi.ipip_6rd_del_tunnel(i) def test_6rd_ip4_to_ip6_suffix(self): """ ip4 -> ip6 (decap) 6rd test """ rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='172.0.0.0/8', ip4_src=self.pg0.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index self.vapi.cli("show ip6 fib") p_ether = Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) p_ip4 = IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) p_ip6 = (IPv6(src="2002:1002:0200::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p = (p_ether / p_ip4 / p_ip6) rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_4in6(p, p_ip6) self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) def test_6rd_ip4_to_ip6_sec_check(self): """ ip4 -> ip6 (decap) security check 6rd test """ rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg0.local_ip4, security_check=True) self.tunnel_index = rv.sw_if_index self.vapi.cli("show ip6 fib") p_ip6 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p_ip6_fail = (IPv6(src="2002:DEAD:0202::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) / p_ip6) p_reply = p_ip6 rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_4in6(p, p_reply) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) / p_ip6_fail) rx = self.send_and_assert_no_replies(self.pg0, p * 10) self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) def test_6rd_bgp_tunnel(self): """ 6rd BGP tunnel """ rv = self.vapi.ipip_6rd_add_tunnel(ip6_table_id=0, ip4_table_id=0, ip6_prefix='2002::/16', ip4_prefix='0.0.0.0/0', ip4_src=self.pg0.local_ip4, security_check=False) self.tunnel_index = rv.sw_if_index default_route = VppIpRoute(self, "DEAD::", 16, [VppRoutePath("2002:0808:0808::", self.tunnel_index)]) default_route.add_vpp_config() ip4_route = VppIpRoute(self, "8.0.0.0", 8, [VppRoutePath(self.pg1.remote_ip4, 0xFFFFFFFF)]) ip4_route.add_vpp_config() # Via recursive route 6 -> 4 p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IPv6(src="1::1", dst="DEAD:BEEF::1") / UDP(sport=1234, dport=1234)) p_reply = (IP(src=self.pg0.local_ip4, dst="8.8.8.8", proto='ipv6') / IPv6(src='1::1', dst='DEAD:BEEF::1', nh='UDP')) rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_6in4(p, p_reply) # Via recursive route 4 -> 6 (Security check must be disabled) p_ip6 = (IPv6(src="DEAD:BEEF::1", dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234)) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / IP(src="8.8.8.8", dst=self.pg0.local_ip4) / p_ip6) p_reply = p_ip6 rx = self.send_and_expect(self.pg0, p * 10, self.pg1) for p in rx: self.validate_4in6(p, p_reply) ip4_route.remove_vpp_config() default_route.remove_vpp_config() self.vapi.ipip_6rd_del_tunnel(self.tunnel_index) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)