aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-12-29 23:55:18 +0000
committerDamjan Marion <dmarion@me.com>2020-01-27 20:40:30 +0000
commit14053c9dbd75182f5302f7388d17508f3930f7ce (patch)
tree527f7675cfe18b13cc7c1923cd7959ec80459a7c /test
parent59ff918ea5b86112ffc89054aa38107703354585 (diff)
ipip: Multi-point interface
Type: feature plus fixes for gre Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: I0eca5f94b8b8ea0fcfb058162cafea4491708db6
Diffstat (limited to 'test')
-rw-r--r--test/test_gre.py24
-rw-r--r--test/test_ipip.py111
-rw-r--r--test/vpp_ipip_tun_interface.py8
3 files changed, 130 insertions, 13 deletions
diff --git a/test/test_gre.py b/test/test_gre.py
index f8c410050e1..e3e21c0ad99 100644
--- a/test/test_gre.py
+++ b/test/test_gre.py
@@ -1066,7 +1066,7 @@ class TestGRE(VppTestCase):
rx = self.send_and_expect(self.pg0, tx_e, itf)
self.verify_tunneled_4o4(self.pg0, rx, tx_e,
itf.local_ip4,
- gre_if._remote_hosts[ii].ip4)
+ itf._remote_hosts[ii].ip4)
tx_i = self.create_tunnel_stream_4o4(self.pg0,
itf._remote_hosts[ii].ip4,
@@ -1087,7 +1087,7 @@ class TestGRE(VppTestCase):
rx = self.send_and_expect(self.pg0, tx_e, itf)
self.verify_tunneled_4o4(self.pg0, rx, tx_e,
itf.local_ip4,
- gre_if._remote_hosts[ii].ip4)
+ itf._remote_hosts[ii].ip4)
rx = self.send_and_expect(self.pg0, tx_i, self.pg0)
self.verify_decapped_4o4(self.pg0, rx, tx_i)
@@ -1131,6 +1131,14 @@ class TestGRE(VppTestCase):
route_addr = "4::%d" % ii
#
+ # Add a NHRP entry resolves the peer
+ #
+ nhrp = VppNhrp(self, gre_if,
+ gre_if._remote_hosts[ii].ip6,
+ itf._remote_hosts[ii].ip6)
+ nhrp.add_vpp_config()
+
+ #
# route traffic via the peer
#
route_via_tun = VppIpRoute(
@@ -1140,14 +1148,6 @@ class TestGRE(VppTestCase):
route_via_tun.add_vpp_config()
#
- # Add a NHRP entry resolves the peer
- #
- nhrp = VppNhrp(self, gre_if,
- gre_if._remote_hosts[ii].ip6,
- itf._remote_hosts[ii].ip6)
- nhrp.add_vpp_config()
-
- #
# Send a packet stream that is routed into the tunnel
# - packets are GRE encapped
#
@@ -1155,7 +1155,7 @@ class TestGRE(VppTestCase):
rx = self.send_and_expect(self.pg0, tx_e, itf)
self.verify_tunneled_6o6(self.pg0, rx, tx_e,
itf.local_ip6,
- gre_if._remote_hosts[ii].ip6)
+ itf._remote_hosts[ii].ip6)
tx_i = self.create_tunnel_stream_6o6(self.pg0,
itf._remote_hosts[ii].ip6,
itf.local_ip6,
@@ -1174,7 +1174,7 @@ class TestGRE(VppTestCase):
rx = self.send_and_expect(self.pg0, tx_e, itf)
self.verify_tunneled_6o6(self.pg0, rx, tx_e,
itf.local_ip6,
- gre_if._remote_hosts[ii].ip6)
+ itf._remote_hosts[ii].ip6)
rx = self.send_and_expect(self.pg0, tx_i, self.pg0)
self.verify_decapped_6o6(self.pg0, rx, tx_i)
diff --git a/test/test_ipip.py b/test/test_ipip.py
index 869dbaaa3af..511164f11ac 100644
--- a/test/test_ipip.py
+++ b/test/test_ipip.py
@@ -8,6 +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_papi import VppEnum
from socket import AF_INET, AF_INET6, inet_pton
from util import reassemble4
@@ -471,6 +472,116 @@ class TestIPIP(VppTestCase):
def payload(self, len):
return 'x' * len
+ def test_mipip4(self):
+ """ p2mp IPv4 tunnel Tests """
+
+ for itf in self.pg_interfaces:
+ #
+ # one underlay nh for each overlay/tunnel peer
+ #
+ itf.generate_remote_hosts(4)
+ itf.configure_ipv4_neighbors()
+
+ #
+ # Create an p2mo IPIP tunnel.
+ # - set it admin up
+ # - assign an IP Addres
+ # - Add a route via the tunnel
+ #
+ ipip_if = VppIpIpTunInterface(self, itf,
+ itf.local_ip4,
+ "0.0.0.0",
+ mode=(VppEnum.vl_api_tunnel_mode_t.
+ TUNNEL_API_MODE_MP))
+ ipip_if.add_vpp_config()
+ ipip_if.admin_up()
+ ipip_if.config_ip4()
+ ipip_if.generate_remote_hosts(4)
+
+ self.logger.info(self.vapi.cli("sh adj"))
+ self.logger.info(self.vapi.cli("sh ip fib"))
+
+ #
+ # ensure we don't match to the tunnel if the source address
+ # is all zeros
+ #
+ # tx = self.create_tunnel_stream_4o4(self.pg0,
+ # "0.0.0.0",
+ # itf.local_ip4,
+ # self.pg0.local_ip4,
+ # self.pg0.remote_ip4)
+ # self.send_and_assert_no_replies(self.pg0, tx)
+
+ #
+ # for-each peer
+ #
+ for ii in range(1, 4):
+ route_addr = "4.4.4.%d" % ii
+
+ #
+ # route traffic via the peer
+ #
+ route_via_tun = VppIpRoute(
+ self, route_addr, 32,
+ [VppRoutePath(ipip_if._remote_hosts[ii].ip4,
+ ipip_if.sw_if_index)])
+ route_via_tun.add_vpp_config()
+
+ #
+ # Add a NHRP entry resolves the peer
+ #
+ nhrp = VppNhrp(self, ipip_if,
+ ipip_if._remote_hosts[ii].ip4,
+ itf._remote_hosts[ii].ip4)
+ nhrp.add_vpp_config()
+ self.logger.info(self.vapi.cli("sh adj nbr ipip0 %s" %
+ ipip_if._remote_hosts[ii].ip4))
+
+ #
+ # Send a packet stream that is routed into the tunnel
+ # - packets are IPIP encapped
+ #
+ inner = (IP(dst=route_addr, 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)
+
+ for rx in rxs:
+ self.assertEqual(rx[IP].src, itf.local_ip4)
+ self.assertEqual(rx[IP].dst, itf._remote_hosts[ii].ip4)
+
+ tx_i = [(Ether(dst=self.pg0.local_mac,
+ src=self.pg0.remote_mac) /
+ IP(src=itf._remote_hosts[ii].ip4,
+ dst=itf.local_ip4) /
+ IP(src=self.pg0.local_ip4, dst=self.pg0.remote_ip4) /
+ UDP(sport=1234, dport=1234) /
+ Raw(b'0x44' * 100)) for x in range(63)]
+
+ self.logger.info(self.vapi.cli("sh ipip tunnel-hash"))
+ rx = self.send_and_expect(self.pg0, tx_i, self.pg0)
+
+ #
+ # delete and re-add the NHRP
+ #
+ nhrp.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()
+ 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)
+
+ ipip_if.admin_down()
+ ipip_if.unconfig_ip4()
+
class TestIPIP6(VppTestCase):
""" IPIP6 Test Case """
diff --git a/test/vpp_ipip_tun_interface.py b/test/vpp_ipip_tun_interface.py
index ea5cfa118aa..67cc1b5f1d8 100644
--- a/test/vpp_ipip_tun_interface.py
+++ b/test/vpp_ipip_tun_interface.py
@@ -1,5 +1,6 @@
from vpp_tunnel_interface import VppTunnelInterface
from ipaddress import ip_address
+from vpp_papi import VppEnum
class VppIpIpTunInterface(VppTunnelInterface):
@@ -9,13 +10,17 @@ class VppIpIpTunInterface(VppTunnelInterface):
def __init__(self, test, parent_if, src, dst,
table_id=0, dscp=0x0,
- flags=0):
+ flags=0, mode=None):
super(VppIpIpTunInterface, self).__init__(test, parent_if)
self.src = src
self.dst = dst
self.table_id = table_id
self.dscp = dscp
self.flags = flags
+ self.mode = mode
+ if not self.mode:
+ self.mode = (VppEnum.vl_api_tunnel_mode_t.
+ TUNNEL_API_MODE_P2P)
def add_vpp_config(self):
r = self.test.vapi.ipip_add_tunnel(
@@ -26,6 +31,7 @@ class VppIpIpTunInterface(VppTunnelInterface):
'flags': self.flags,
'dscp': self.dscp,
'instance': 0xffffffff,
+ 'mode': self.mode,
})
self.set_sw_if_index(r.sw_if_index)
self.test.registry.register(self, self.test.logger)