This is an IPIP (hence IPv4-only) counterpart to the GRE elementary test
for a configuration where overlay and underlay are each in a different
VRF.
Signed-off-by: Petr Machata <petrm(a)mellanox.com>
---
Notes:
Changes from v1 to v2:
- Split out this code to patch of its own.
- Replace manual route handling with add_nhs_route() call
recipes/switchdev/ipip-002-ipip-hier-basic.py | 60 ++++++++++++++++++++++++++
recipes/switchdev/ipip-002-ipip-hier-basic.xml | 57 ++++++++++++++++++++++++
2 files changed, 117 insertions(+)
create mode 100644 recipes/switchdev/ipip-002-ipip-hier-basic.py
create mode 100644 recipes/switchdev/ipip-002-ipip-hier-basic.xml
diff --git a/recipes/switchdev/ipip-002-ipip-hier-basic.py
b/recipes/switchdev/ipip-002-ipip-hier-basic.py
new file mode 100644
index 0000000..33ca148
--- /dev/null
+++ b/recipes/switchdev/ipip-002-ipip-hier-basic.py
@@ -0,0 +1,60 @@
+"""
+Copyright 2017 Mellanox Technologies. All rights reserved.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+petrm(a)mellanox.com (Petr Machata)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib, vrf, dummy, ipip
+from ipip_common import ping_test, encap_route, \
+ add_forward_route, connect_host_ifaces, \
+ test_ip, ipv4, ipv6
+from time import sleep
+import logging
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m2_if1, sw_if1, sw_if2 = ifaces
+
+ m1_if1.add_nhs_route(ipv4(test_ip(2, 0)), [ipv4(test_ip(1, 1, []))])
+ m2_if1.add_nhs_route("1.2.3.4/32", [ipv4(test_ip(99, 1, []))])
+
+ vrf_None = None
+ tl = TestLib(ctl, aliases)
+ sw_if1.reset(ip=test_ip(1, 1))
+ sw_if2.reset(ip=test_ip(99,1))
+
+ logging.info("=== Hierarchical configuration")
+ with vrf(sw) as vrf_u, \
+ vrf(sw) as vrf_o:
+ connect_host_ifaces(sw, sw_if1, vrf_o, sw_if2, vrf_u)
+ sw_if1.reset()
+ sw_if2.reset()
+ add_forward_route(sw, vrf_u, "1.2.3.5")
+
+ with encap_route(m2, vrf_None, 1, "ipip1", ip=ipv4):
+ # - Set up encap route before decap route.
+ # - Tear down encap route before decap route.
+ logging.info("--- Dup, Eup, Edown, Ddown")
+ with dummy(sw, vrf_u, ip=["1.2.3.4/32"]) as d, \
+ ipip(sw, d, vrf_o,
+ tos="inherit",
+ local_ip="1.2.3.4",
+ remote_ip="1.2.3.5") as g, \
+ encap_route(sw, vrf_o, 2, g):
+
+ sleep(15)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g)
+
+do_task(ctl, [ctl.get_host("machine1"),
+ ctl.get_host("machine2"),
+ ctl.get_host("switch")],
+ [ctl.get_host("machine1").get_interface("if1"),
+ ctl.get_host("machine2").get_interface("if1"),
+ ctl.get_host("switch").get_interface("if1"),
+ ctl.get_host("switch").get_interface("if2")],
+ ctl.get_aliases())
diff --git a/recipes/switchdev/ipip-002-ipip-hier-basic.xml
b/recipes/switchdev/ipip-002-ipip-hier-basic.xml
new file mode 100644
index 0000000..fcacbbc
--- /dev/null
+++ b/recipes/switchdev/ipip-002-ipip-hier-basic.xml
@@ -0,0 +1,57 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <define>
+ <alias name="onet1" value="192.168.1"/>
+ <alias name="onet2" value="192.168.2"/>
+ <alias name="o6net1" value="2002:1"/>
+ <alias name="o6net2" value="2002:2"/>
+ <alias name="unet" value="192.168.99"/>
+ </define>
+ <network>
+ <host id="machine1">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="A">
+ <addresses>
+ <address value="{$onet1}.33/24" />
+ <address value="{$o6net1}::33/64" />
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="B">
+ <addresses>
+ <address value="{$unet}.2/24" />
+ </addresses>
+ </eth>
+ <dummy id="d1">
+ <addresses>
+ <address value="1.2.3.5/32" />
+ <address value="{$onet2}.33/32" />
+ <address value="{$o6net2}::33/62" />
+ </addresses>
+ </dummy>
+
+ <ipip id="ipip1">
+ <addresses>
+ <address value="{$onet2}.1/32" />
+ </addresses>
+ <options>
+ <option name="local_ip"
value="1.2.3.5"/>
+ <option name="remote_ip"
value="1.2.3.4"/>
+ </options>
+ </ipip>
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="ipip-002-ipip-hier-basic.py" />
+</lnstrecipe>
--
2.4.11