- Test reseating a tunnel to a new bound device
- Test bound device up/down events. This test is split among two test
files: ipip-010-gre-hier-changes, where the end-to-end is confirmed to
be down when bound device is down. And ipip-006-gre-decap, where the
decap-only flow is confirmed to still work despite bound device being
down.
- Test that when a tunnel is created over a down bound device, that it's
created in the same state as if it was created over an up bound device
that is later downed.
Signed-off-by: Petr Machata <petrm(a)mellanox.com>
---
recipes/switchdev/ipip-006-gre-decap.py | 52 ++++++++++++----
recipes/switchdev/ipip-010-gre-hier-change.py | 87 +++++++++++++++++++++++++++
2 files changed, 127 insertions(+), 12 deletions(-)
diff --git a/recipes/switchdev/ipip-006-gre-decap.py b/recipes/switchdev/ipip-006-gre-decap.py
index 4beec67..217709a 100644
--- a/recipes/switchdev/ipip-006-gre-decap.py
+++ b/recipes/switchdev/ipip-006-gre-decap.py
@@ -28,7 +28,8 @@ def do_task(ctl, hosts, ifaces, aliases):
vrf_None = None
tl = TestLib(ctl, aliases)
- logging.info("=== Decap-only flow in default VRF")
+ logging.info("=== Decap-only flow tests")
+ logging.info("--- default VRF")
with encap_route(m2, vrf_None, 1, "gre1",
ip=ipv4, src=ipv4(test_ip(2, 33, []))), \
encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \
@@ -44,24 +45,51 @@ def do_task(ctl, hosts, ifaces, aliases):
ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True)
ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g)
- logging.info("=== Decap-only flow in hierarchical configuration")
- with encap_route(m2, vrf_None, 1, "gre1",
- ip=ipv4, src=ipv4(test_ip(2, 33, []))), \
- encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \
- vrf(sw) as vrf_u, \
+ with vrf(sw) as vrf_u, \
vrf(sw) as vrf_o, \
dummy(sw, vrf_u, ip=["1.2.3.4/32"]) as d, \
- gre(sw, d, vrf_o,
- tos="inherit",
- local_ip="1.2.3.4",
- remote_ip="1.2.3.5") as g:
+ encap_route(m2, vrf_None, 1, "gre1",
+ ip=ipv4, src=ipv4(test_ip(2, 33, []))), \
+ encap_route(m2, vrf_None, 1, "gre1", ip=ipv6):
connect_host_ifaces(sw, sw_if1_10, vrf_o, sw_if2_10, vrf_u)
refresh_addrs(sw, sw_if1_10)
add_forward_route(sw, vrf_u, "1.2.3.5")
- ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True)
- ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g)
+ with gre(sw, d, vrf_o,
+ tos="inherit",
+ local_ip="1.2.3.4",
+ remote_ip="1.2.3.5") as g:
+
+ logging.info("--- hierarchical configuration")
+ sleep(15)
+
+ ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True)
+ ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g)
+
+ # Make sure that downing an underlay device doesn't make the decap flow
+ # stop working. There is a complementary test in ipip-010 to test that
+ # encap stops working.
+ logging.info("--- set an underlay down")
+ d.set_link_down()
+ sleep(5)
+
+ ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True)
+ ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g)
+
+ # Make sure that when a newly-created tunnel has a down underlay, decap
+ # still works. There's a complementary test in ipip-010 to test that
+ # encap doesn't work in that scenario.
+ logging.info("--- create tunnel with a down underlay")
+ d.set_link_down() # Should be down already, but make this robust against
+ # later coding changes.
+ with gre(sw, d, vrf_o,
+ tos="inherit",
+ local_ip="1.2.3.4",
+ remote_ip="1.2.3.5") as g:
+
+ ping_test(tl, m2, sw, ipv6(test_ip(1, 33, [])), m2_if1_10, g, ipv6=True)
+ ping_test(tl, m2, sw, ipv4(test_ip(1, 33, [])), m2_if1_10, g)
do_task(ctl, [ctl.get_host("machine1"),
ctl.get_host("machine2"),
diff --git a/recipes/switchdev/ipip-010-gre-hier-change.py b/recipes/switchdev/ipip-010-gre-hier-change.py
index 1552daf..d709360 100644
--- a/recipes/switchdev/ipip-010-gre-hier-change.py
+++ b/recipes/switchdev/ipip-010-gre-hier-change.py
@@ -32,12 +32,99 @@ def do_task(ctl, hosts, ifaces, aliases):
logging.info("=== Hierarchical configuration, 'ip t change'")
with vrf(sw) as vrf_u, \
vrf(sw) as vrf_o, \
+ vrf(sw) as vrf3, \
dummy(sw, vrf_u, ip=["1.2.3.4/32"]) as d:
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")
+ logging.info("--- create tunnel with a down underlay")
+ d.set_link_down()
+ with encap_route(m2, vrf_None, 1, "gre1", ip=ipv4), \
+ encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \
+ gre(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, ip=ipv4), \
+ encap_route(sw, vrf_o, 2, g, ip=ipv6):
+
+ sleep(15)
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ count=100, fail_expected=True, ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g,
+ count=100, fail_expected=True)
+
+ d.set_link_up()
+ with encap_route(m2, vrf_None, 1, "gre1", ip=ipv4), \
+ encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \
+ dummy(sw, vrf3, ip=["1.2.3.4/32"]) as d2, \
+ gre(sw, d2, 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, ip=ipv4), \
+ encap_route(sw, vrf_o, 2, g, ip=ipv6):
+
+ sleep(15)
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ count=25, fail_expected=True, ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g,
+ count=25, fail_expected=True)
+
+ logging.info("--- change of bound device")
+ sw.run("ip t change name %s dev %s"
+ % (g.get_devname(), d.get_devname()))
+
+ sleep(5)
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g)
+
+ logging.info("--- bound device up/down")
+ # Now change back to `d2', set `d' down and change to it again.
+ # Traffic shouldn't flow.
+ # There's a complementary test in ipip-006 to make sure that
+ # decap-only flow still works even if bound device is down.
+ sw.run("ip t change name %s dev %s"
+ % (g.get_devname(), d2.get_devname()))
+ d.set_link_down()
+ sleep(5)
+
+ sw.run("ip t change name %s dev %s"
+ % (g.get_devname(), d.get_devname()))
+
+ sleep(5)
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ count=25, fail_expected=True, ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g,
+ count=25, fail_expected=True)
+
+ # Set `d' up while it's the bound device. Traffic should flow again.
+ d.set_link_up()
+ sleep(5)
+
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g)
+
+ # Do some more of flip-flopping to make sure it's stable.
+ d.set_link_down()
+ sleep(5)
+
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ count=25, fail_expected=True, ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g,
+ count=25, fail_expected=True)
+
+ d.set_link_up()
+ sleep(5)
+
+ ping_test(tl, m1, sw, ipv6(test_ip(2, 33, [])), m1_if1, g,
+ ipv6=True)
+ ping_test(tl, m1, sw, ipv4(test_ip(2, 33, [])), m1_if1, g)
+
logging.info("--- remote change")
with encap_route(m2, vrf_None, 1, "gre1", ip=ipv4), \
encap_route(m2, vrf_None, 1, "gre1", ip=ipv6), \
--
2.4.11