On Mon, Oct 02, 2017 at 04:40:15PM +0300, Yotam Gigi wrote:
The test aims to test the flow of having traffic before the matching
route
is created. The traffic creates an "unresolved route" in the kernel, which
holds the no-cache packets for some time interval. If a matching route is
put at that interval, it "resolves" the route and the stored packets are
forwarded according to it.
Test that that flow is functional by triggering traffic for a route before
the actual route is inserted.
The test algorithm is:
- For 10 random (S,G) routes
- Trigger traffic that would match the route
- Test that a NOTIF_NOCACHE mroute notification was received
- Add the actual route
- Test that the route is functional
Signed-off-by: Yotam Gigi <yotamg(a)mellanox.com>
---
recipes/switchdev/mr-007-nocache-route.py | 87 ++++++++++++++++++++++++++++++
recipes/switchdev/mr-007-nocache-route.xml | 5 ++
2 files changed, 92 insertions(+)
create mode 100644 recipes/switchdev/mr-007-nocache-route.py
create mode 100644 recipes/switchdev/mr-007-nocache-route.xml
diff --git a/recipes/switchdev/mr-007-nocache-route.py
b/recipes/switchdev/mr-007-nocache-route.py
new file mode 100644
index 0000000..0b1c3fb
--- /dev/null
+++ b/recipes/switchdev/mr-007-nocache-route.py
@@ -0,0 +1,87 @@
+"""
+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__ = """
+yotamg(a)mellanox.com (Yotam Gigi)
+"""
+
+from lnst.Controller.Task import ctl
+from lnst.Common.Consts import MROUTE
+from TestLib import TestLib
+from time import sleep
+import random
+from mr_common import MrouteTest
+
+def mcgrp(num):
+ return "239.255.%d.%d" % (num/0x100, num%0x100)
+
+def nocache_route(mt, ivif, group, evifs):
+ mach_source_port = mt.sw_mach_conn[mt.vif2port[ivif]][0]
+
+ mt.send_mc_traffic(group, mach_source_port, 1)
+ mt.expect_mr_notifs(MROUTE.NOTIF_NOCACHE,
+ source_ip = mach_source_port.get_ip(0),
+ source_vif = ivif, group_ip = group)
+ source = str(mach_source_port.get_ip(0))
+ return mt.mroute_create(source, group, ivif, evifs)
+
+def random_ivif(vifs):
+ return random.choice(vifs)
+
+def random_evifs(vifs, ivif):
+ evifs = [evif for evif in vifs
+ if random.choice([True, False]) and evif != ivif]
+ return evifs
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \
+ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces
+
+ sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5]
+
+ tl = TestLib(ctl, aliases)
+ mt = MrouteTest(tl, hosts, ifaces)
+
+ sleep(30)
+ mt.init()
+
+ # add vifs
+ mt.add_vif(sw_if1, 0)
+ mt.add_vif(sw_if2, 1)
+ mt.add_vif(sw_if3, 2)
+ mt.add_vif(sw_if4, 3)
+ mt.add_vif(sw_if5, 4)
+ vifs = [0, 1, 2, 3, 4]
+
+ mroutes = []
+ for i in range(1, 10):
+ ivif = random_ivif(vifs)
+ evifs = random_evifs(vifs, ivif)
+ mroutes.append(nocache_route(mt, ivif, mcgrp(i), evifs))
+
+ for mroute in mroutes:
+ mt.mroute_remove(mroute)
+
^ trailing whitespace, will fix while applying
+ mt.fini()
+
+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("machine1").get_interface("if2"),
+ ctl.get_host("machine2").get_interface("if1"),
+ ctl.get_host("machine2").get_interface("if2"),
+ ctl.get_host("machine2").get_interface("if3"),
+ ctl.get_host("machine2").get_interface("if4"),
+ ctl.get_host("switch").get_interface("if1"),
+ ctl.get_host("switch").get_interface("if2"),
+ ctl.get_host("switch").get_interface("if3"),
+ ctl.get_host("switch").get_interface("if4"),
+ ctl.get_host("switch").get_interface("if5"),
+ ctl.get_host("switch").get_interface("if6"),
+ ctl.get_host("switch").get_interface("br0")],
+ ctl.get_aliases())
diff --git a/recipes/switchdev/mr-007-nocache-route.xml
b/recipes/switchdev/mr-007-nocache-route.xml
new file mode 100644
index 0000000..519b580
--- /dev/null
+++ b/recipes/switchdev/mr-007-nocache-route.xml
@@ -0,0 +1,5 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <xi:include href="mr_common_topology.xml" />
+ <task python="mr-007-nocache-route.py" />
+</lnstrecipe>
--
2.8.4
_______________________________________________
LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org
-Ondrej