The basic L3 recipe add a simple route on a switch and check ping.
Signed-off-by: Elad Raz <eladr(a)mellanox.com>
---
recipes/switchdev/l3-000-minimal.py | 54 ++++++++++++++++++++++++++
recipes/switchdev/l3-000-minimal.xml | 24 ++++++++++++
recipes/switchdev/l3-001-router-port.py | 51 ++++++++++++++++++++++++
recipes/switchdev/l3-001-router-port.xml | 24 ++++++++++++
recipes/switchdev/l3-002-vlan-interface.py | 54 ++++++++++++++++++++++++++
recipes/switchdev/l3-002-vlan-interface.xml | 24 ++++++++++++
recipes/switchdev/l3-003-bond-interface.py | 60 +++++++++++++++++++++++++++++
recipes/switchdev/l3-003-bond-interface.xml | 26 +++++++++++++
recipes/switchdev/l3-004-team-interface.py | 60 +++++++++++++++++++++++++++++
recipes/switchdev/l3-004-team-interface.xml | 26 +++++++++++++
10 files changed, 403 insertions(+)
create mode 100644 recipes/switchdev/l3-000-minimal.py
create mode 100644 recipes/switchdev/l3-000-minimal.xml
create mode 100644 recipes/switchdev/l3-001-router-port.py
create mode 100644 recipes/switchdev/l3-001-router-port.xml
create mode 100644 recipes/switchdev/l3-002-vlan-interface.py
create mode 100644 recipes/switchdev/l3-002-vlan-interface.xml
create mode 100644 recipes/switchdev/l3-003-bond-interface.py
create mode 100644 recipes/switchdev/l3-003-bond-interface.xml
create mode 100644 recipes/switchdev/l3-004-team-interface.py
create mode 100644 recipes/switchdev/l3-004-team-interface.xml
diff --git a/recipes/switchdev/l3-000-minimal.py b/recipes/switchdev/l3-000-minimal.py
new file mode 100644
index 0000000..f2a9b2c
--- /dev/null
+++ b/recipes/switchdev/l3-000-minimal.py
@@ -0,0 +1,54 @@
+"""
+Copyright 2016 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__ = """
+eladr(a)mellanox.com (Elad Raz)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib
+from time import sleep
+
+def test_ip(major, minor, prefix=[24,64]):
+ return ["192.168.10%d.%d%s" % (major, minor,
+ "/" + str(prefix[0]) if len(prefix) > 0 else ""),
+ "2002:%d::%d%s" % (major, minor,
+ "/" + str(prefix[1]) if len(prefix) > 1 else "")]
+
+def ipv4(test_ip):
+ return test_ip[0]
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m2_if1, sw_if1, sw_if2 = ifaces
+
+ m1_if1.reset(ip=test_ip(1,1))
+ m2_if1.reset(ip=test_ip(2,1))
+
+ sw_if1.reset(ip=test_ip(1,2))
+ sw_if2.reset(ip=test_ip(2,2))
+
+ m1_if1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
+ m2_if1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);
+
+ sleep(30)
+
+ tl = TestLib(ctl, aliases)
+ tl.ping_simple(m1_if1, m2_if1)
+
+ # Remove route and check that traffic is not passing
+ sw_if1.set_addresses(ips=[])
+ sw_if2.set_addresses(ips=[])
+ tl.ping_simple(m1_if1, m2_if1, fail_expected=True)
+
+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/l3-000-minimal.xml b/recipes/switchdev/l3-000-minimal.xml
new file mode 100644
index 0000000..2674cde
--- /dev/null
+++ b/recipes/switchdev/l3-000-minimal.xml
@@ -0,0 +1,24 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <network>
+ <host id="machine1">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="A" />
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="B" />
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="l3-000-minimal.py" />
+</lnstrecipe>
diff --git a/recipes/switchdev/l3-001-router-port.py
b/recipes/switchdev/l3-001-router-port.py
new file mode 100644
index 0000000..18038c4
--- /dev/null
+++ b/recipes/switchdev/l3-001-router-port.py
@@ -0,0 +1,51 @@
+"""
+Copyright 2016 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__ = """
+eladr(a)mellanox.com (Elad Raz)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib
+from time import sleep
+
+def test_ip(major, minor, prefix=[24,64]):
+ return ["192.168.10%d.%d%s" % (major, minor,
+ "/" + str(prefix[0]) if len(prefix) > 0 else ""),
+ "2002:%d::%d%s" % (major, minor,
+ "/" + str(prefix[1]) if len(prefix) > 1 else "")]
+
+def ipv4(test_ip):
+ return test_ip[0]
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m2_if1, sw_if1, sw_if2 = ifaces
+
+ m1_if1.reset(ip=test_ip(1,1))
+ m2_if1.reset(ip=test_ip(2,1))
+
+ sw_if1.reset(ip=test_ip(1,2))
+ sw_if2.reset(ip=test_ip(2,2))
+
+ m1_if1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
+ m2_if1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);
+
+ sleep(30)
+
+ tl = TestLib(ctl, aliases)
+ tl.ping_simple(m1_if1, m2_if1)
+ tl.netperf_tcp(m1_if1, m2_if1)
+ tl.netperf_udp(m1_if1, m2_if1)
+
+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/l3-001-router-port.xml
b/recipes/switchdev/l3-001-router-port.xml
new file mode 100644
index 0000000..e476b03
--- /dev/null
+++ b/recipes/switchdev/l3-001-router-port.xml
@@ -0,0 +1,24 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <network>
+ <host id="machine1">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="A" />
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="B" />
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="l3-001-router-port.py" />
+</lnstrecipe>
diff --git a/recipes/switchdev/l3-002-vlan-interface.py
b/recipes/switchdev/l3-002-vlan-interface.py
new file mode 100644
index 0000000..3fb6398
--- /dev/null
+++ b/recipes/switchdev/l3-002-vlan-interface.py
@@ -0,0 +1,54 @@
+"""
+Copyright 2016 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__ = """
+eladr(a)mellanox.com (Elad Raz)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib
+from time import sleep
+
+def test_ip(major, minor, prefix=[24,64]):
+ return ["192.168.10%d.%d%s" % (major, minor,
+ "/" + str(prefix[0]) if len(prefix) > 0 else ""),
+ "2002:%d::%d%s" % (major, minor,
+ "/" + str(prefix[1]) if len(prefix) > 1 else "")]
+
+def ipv4(test_ip):
+ return test_ip[0]
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m2_if1, sw_if1, sw_if2 = ifaces
+
+ m1_if1.reset()
+ m2_if1.reset()
+
+ m1_if1_10 = m1.create_vlan(m1_if1, 10, ip=test_ip(1,1))
+ m2_if1_10 = m2.create_vlan(m2_if1, 10, ip=test_ip(2,1))
+
+ sw_if1_10 = sw.create_vlan(sw_if1, 10, ip=test_ip(1,2))
+ sw_if2_10 = sw.create_vlan(sw_if2, 10, ip=test_ip(2,2))
+
+ m1_if1_10.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
+ m2_if1_10.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);
+
+ sleep(30)
+
+ tl = TestLib(ctl, aliases)
+ tl.ping_simple(m1_if1_10, m2_if1_10)
+ tl.netperf_tcp(m1_if1_10, m2_if1_10)
+ tl.netperf_udp(m1_if1_10, m2_if1_10)
+
+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/l3-002-vlan-interface.xml
b/recipes/switchdev/l3-002-vlan-interface.xml
new file mode 100644
index 0000000..6f6f40f
--- /dev/null
+++ b/recipes/switchdev/l3-002-vlan-interface.xml
@@ -0,0 +1,24 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <network>
+ <host id="machine1">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="A" />
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <params/>
+ <interfaces>
+ <eth id="if1" label="B" />
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="l3-002-vlan-interface.py" />
+</lnstrecipe>
diff --git a/recipes/switchdev/l3-003-bond-interface.py
b/recipes/switchdev/l3-003-bond-interface.py
new file mode 100644
index 0000000..9538897
--- /dev/null
+++ b/recipes/switchdev/l3-003-bond-interface.py
@@ -0,0 +1,60 @@
+"""
+Copyright 2016 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__ = """
+eladr(a)mellanox.com (Elad Raz)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib
+from time import sleep
+
+def test_ip(major, minor, prefix=[24,64]):
+ return ["192.168.10%d.%d%s" % (major, minor,
+ "/" + str(prefix[0]) if len(prefix) > 0 else ""),
+ "2002:%d::%d%s" % (major, minor,
+ "/" + str(prefix[1]) if len(prefix) > 1 else "")]
+
+def ipv4(test_ip):
+ return test_ip[0]
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces
+
+ bond_options = {"mode": "802.3ad", "miimon":
"100"}
+ m1_lag1 = m1.create_bond(slaves=[m1_if1, m1_if2], options=bond_options,
+ ip=test_ip(1,1))
+ m2_lag1 = m2.create_bond(slaves=[m2_if1, m2_if2], options=bond_options,
+ ip=test_ip(2,1))
+
+ m1_lag1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
+ m2_lag1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);
+
+ sw_lag1 = sw.create_bond(slaves=[sw_if1, sw_if2], options=bond_options,
+ ip=test_ip(1,2))
+ sw_lag2 = sw.create_bond(slaves=[sw_if3, sw_if4], options=bond_options,
+ ip=test_ip(2,2))
+
+ sleep(30)
+
+ tl = TestLib(ctl, aliases)
+ tl.ping_simple(m1_lag1, m2_lag1)
+ tl.netperf_tcp(m1_lag1, m2_lag1)
+ tl.netperf_udp(m1_lag1, m2_lag1)
+
+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("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_aliases())
diff --git a/recipes/switchdev/l3-003-bond-interface.xml
b/recipes/switchdev/l3-003-bond-interface.xml
new file mode 100644
index 0000000..ee1f7bd
--- /dev/null
+++ b/recipes/switchdev/l3-003-bond-interface.xml
@@ -0,0 +1,26 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="if1" label="C" />
+ <eth id="if2" label="D" />
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ <eth id="if3" label="C" />
+ <eth id="if4" label="D" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="l3-003-bond-interface.py" />
+</lnstrecipe>
diff --git a/recipes/switchdev/l3-004-team-interface.py
b/recipes/switchdev/l3-004-team-interface.py
new file mode 100644
index 0000000..efc255d
--- /dev/null
+++ b/recipes/switchdev/l3-004-team-interface.py
@@ -0,0 +1,60 @@
+"""
+Copyright 2016 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__ = """
+eladr(a)mellanox.com (Elad Raz)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib
+from time import sleep
+
+def test_ip(major, minor, prefix=[24,64]):
+ return ["192.168.10%d.%d%s" % (major, minor,
+ "/" + str(prefix[0]) if len(prefix) > 0 else ""),
+ "2002:%d::%d%s" % (major, minor,
+ "/" + str(prefix[1]) if len(prefix) > 1 else "")]
+
+def ipv4(test_ip):
+ return test_ip[0]
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m1_if2, m2_if1, m2_if2, sw_if1, sw_if2, sw_if3, sw_if4 = ifaces
+
+ team_config = '{"runner" : {"name" : "lacp"}}'
+ m1_lag1 = m1.create_team(slaves=[m1_if1, m1_if2], config=team_config,
+ ip=test_ip(1,1))
+ m2_lag1 = m2.create_team(slaves=[m2_if1, m2_if2], config=team_config,
+ ip=test_ip(2,1))
+
+ m1_lag1.add_nhs_route(ipv4(test_ip(2,0)), [ipv4(test_ip(1,2,[]))]);
+ m2_lag1.add_nhs_route(ipv4(test_ip(1,0)), [ipv4(test_ip(2,2,[]))]);
+
+ sw_lag1 = sw.create_team(slaves=[sw_if1, sw_if2], config=team_config,
+ ip=test_ip(1,2))
+ sw_lag2 = sw.create_team(slaves=[sw_if3, sw_if4], config=team_config,
+ ip=test_ip(2,2))
+
+ sleep(30)
+
+ tl = TestLib(ctl, aliases)
+ tl.ping_simple(m1_lag1, m2_lag1)
+ tl.netperf_tcp(m1_lag1, m2_lag1)
+ tl.netperf_udp(m1_lag1, m2_lag1)
+
+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("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_aliases())
diff --git a/recipes/switchdev/l3-004-team-interface.xml
b/recipes/switchdev/l3-004-team-interface.xml
new file mode 100644
index 0000000..e5f19cc
--- /dev/null
+++ b/recipes/switchdev/l3-004-team-interface.xml
@@ -0,0 +1,26 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="if1" label="C" />
+ <eth id="if2" label="D" />
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ <eth id="if3" label="C" />
+ <eth id="if4" label="D" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="l3-004-team-interface.py" />
+</lnstrecipe>
--
2.4.3