ikev2: add option to disable NAT traversal
[vpp.git] / test / test_ipip.py
index 511164f..8f18c07 100644 (file)
@@ -8,7 +8,7 @@ from framework import VppTestCase, VppTestRunner
 from vpp_ip import DpoProto
 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
 from vpp_ipip_tun_interface import VppIpIpTunInterface
-from vpp_nhrp import VppNhrp
+from vpp_teib import VppTeib
 from vpp_papi import VppEnum
 from socket import AF_INET, AF_INET6, inet_pton
 from util import reassemble4
@@ -45,7 +45,7 @@ class TestIPIP(VppTestCase):
     @classmethod
     def setUpClass(cls):
         super(TestIPIP, cls).setUpClass()
-        cls.create_pg_interfaces(range(2))
+        cls.create_pg_interfaces(range(3))
         cls.interfaces = list(cls.pg_interfaces)
 
     @classmethod
@@ -54,8 +54,14 @@ class TestIPIP(VppTestCase):
 
     def setUp(self):
         super(TestIPIP, self).setUp()
+        self.table = VppIpTable(self, 1, register=False)
+        self.table.add_vpp_config()
+
         for i in self.interfaces:
             i.admin_up()
+
+        self.pg2.set_table_ip4(self.table.table_id)
+        for i in self.interfaces:
             i.config_ip4()
             i.config_ip6()
             i.disable_ipv6_ra()
@@ -68,8 +74,11 @@ class TestIPIP(VppTestCase):
             for i in self.pg_interfaces:
                 i.unconfig_ip4()
                 i.unconfig_ip6()
+                i.set_table_ip4(0)
                 i.admin_down()
 
+        self.table.remove_vpp_config()
+
     def validate(self, rx, expected):
         self.assertEqual(rx, expected.__class__(expected))
 
@@ -475,7 +484,7 @@ class TestIPIP(VppTestCase):
     def test_mipip4(self):
         """ p2mp IPv4 tunnel Tests """
 
-        for itf in self.pg_interfaces:
+        for itf in self.pg_interfaces[:2]:
             #
             # one underlay nh for each overlay/tunnel peer
             #
@@ -528,12 +537,12 @@ class TestIPIP(VppTestCase):
                 route_via_tun.add_vpp_config()
 
                 #
-                # Add a NHRP entry resolves the peer
+                # Add a TEIB entry resolves the peer
                 #
-                nhrp = VppNhrp(self, ipip_if,
+                teib = VppTeib(self, ipip_if,
                                ipip_if._remote_hosts[ii].ip4,
                                itf._remote_hosts[ii].ip4)
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
                 self.logger.info(self.vapi.cli("sh adj nbr ipip0 %s" %
                                                ipip_if._remote_hosts[ii].ip4))
 
@@ -566,21 +575,57 @@ class TestIPIP(VppTestCase):
                 rx = self.send_and_expect(self.pg0, tx_i, self.pg0)
 
                 #
-                # delete and re-add the NHRP
+                # delete and re-add the TEIB
                 #
-                nhrp.remove_vpp_config()
+                teib.remove_vpp_config()
                 self.send_and_assert_no_replies(self.pg0, tx_e)
                 self.send_and_assert_no_replies(self.pg0, tx_i)
 
-                nhrp.add_vpp_config()
+                teib.add_vpp_config()
                 rx = self.send_and_expect(self.pg0, tx_e, itf)
                 for rx in rxs:
                     self.assertEqual(rx[IP].src, itf.local_ip4)
                     self.assertEqual(rx[IP].dst, itf._remote_hosts[ii].ip4)
                 rx = self.send_and_expect(self.pg0, tx_i, self.pg0)
 
+                #
+                # we can also send to the peer's address
+                #
+                inner = (IP(dst=teib.peer, src="5.5.5.5") /
+                         UDP(sport=1234, dport=1234) /
+                         Raw(b'0x44' * 100))
+                tx_e = [(Ether(dst=self.pg0.local_mac,
+                               src=self.pg0.remote_mac) /
+                         inner) for x in range(63)]
+
+                rxs = self.send_and_expect(self.pg0, tx_e, itf)
+
+            #
+            # with all of the peers in place, swap the ip-table of
+            # the ipip interface
+            #
+            table = VppIpTable(self, 2)
+            table.add_vpp_config()
+
+            ipip_if.unconfig_ip4()
+            ipip_if.set_table_ip4(self.table.table_id)
+            ipip_if.config_ip4()
+
+            #
+            # we should still be able to reach the peers from the new table
+            #
+            inner = (IP(dst=teib.peer, src="5.5.5.5") /
+                     UDP(sport=1234, dport=1234) /
+                     Raw(b'0x44' * 100))
+            tx_e = [(Ether(dst=self.pg0.local_mac,
+                           src=self.pg0.remote_mac) /
+                     inner) for x in range(63)]
+
+            rxs = self.send_and_expect(self.pg2, tx_e, itf)
+
             ipip_if.admin_down()
             ipip_if.unconfig_ip4()
+            ipip_if.set_table_ip4(0)
 
 
 class TestIPIP6(VppTestCase):