Assume a topology with a central switch and two hosts. Each host sends traffic on a different VLAN. The switch translates the VLANs to one another using tc action vlan modify.
Signed-off-by: Petr Machata petrm@mellanox.com --- recipes/switchdev/tc-001-action-vlan-modify.py | 44 +++++++++++++++++++++++++ recipes/switchdev/tc-001-action-vlan-modify.xml | 24 ++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 recipes/switchdev/tc-001-action-vlan-modify.py create mode 100644 recipes/switchdev/tc-001-action-vlan-modify.xml
diff --git a/recipes/switchdev/tc-001-action-vlan-modify.py b/recipes/switchdev/tc-001-action-vlan-modify.py new file mode 100644 index 0000000..a9c0d16 --- /dev/null +++ b/recipes/switchdev/tc-001-action-vlan-modify.py @@ -0,0 +1,44 @@ +""" +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@mellanox.com (Petr Machata) +""" + +from lnst.Controller.Task import ctl +from TestLib import TestLib, Qdisc +from time import sleep + +def do_task(ctl, hosts, ifaces, aliases): + m1, m2, sw = hosts + m1_if1, m2_if1, sw_if1, sw_if2 = ifaces + + m1_if1_85 = m1.create_vlan(m1_if1, 85, ip=["192.168.101.10/24", "2002::1/64"]) + m2_if1_65 = m2.create_vlan(m2_if1, 65, ip=["192.168.101.11/24", "2002::2/64"]) + + sw_br1 = sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1}) + sw_if1.add_br_vlan(85) + sw_if2.add_br_vlan(65) + + q1 = Qdisc(sw_if1, 0xffff, "ingress") + q1.filter_add("protocol all flower skip_sw action vlan modify id 65") + + q2 = Qdisc(sw_if2, 0xffff, "ingress") + q2.filter_add("protocol all flower skip_sw action vlan modify id 85") + + sleep(10) + + tl = TestLib(ctl, aliases) + tl.ping_simple(m1_if1_85, m2_if1_65) + +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/tc-001-action-vlan-modify.xml b/recipes/switchdev/tc-001-action-vlan-modify.xml new file mode 100644 index 0000000..d55658c --- /dev/null +++ b/recipes/switchdev/tc-001-action-vlan-modify.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="tc-001-action-vlan-modify.py" /> +</lnstrecipe>
lnst-developers@lists.fedorahosted.org