From aea74842e0475441d8df834f2dcd8cbc21fa253d Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 22 Jun 2023 13:15:23 +0200 Subject: [PATCH] test/case: new test, basic bridge vlan filtering Signed-off-by: Joachim Wiberg --- test/case/infix_interfaces/all.yaml | 1 + test/case/infix_interfaces/bridge_vlan.py | 92 +++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100755 test/case/infix_interfaces/bridge_vlan.py diff --git a/test/case/infix_interfaces/all.yaml b/test/case/infix_interfaces/all.yaml index 10f592a8..a8a69bc0 100644 --- a/test/case/infix_interfaces/all.yaml +++ b/test/case/infix_interfaces/all.yaml @@ -2,3 +2,4 @@ - case: bridge_basic.py - case: bridge_veth.py - case: dual_bridge.py +- case: bridge_vlan.py diff --git a/test/case/infix_interfaces/bridge_vlan.py b/test/case/infix_interfaces/bridge_vlan.py new file mode 100755 index 00000000..494c2b0c --- /dev/null +++ b/test/case/infix_interfaces/bridge_vlan.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +# +# vlan10 IP:10.0.0.2 +# / +# PING --> br0 <-- VLAN filtering enabled +# / +# PC ---- e0 +# + +import infamy + +with infamy.Test() as test: + with test.step("Initialize"): + env = infamy.Env(infamy.std_topology("1x2")) + target = env.attach("target", "mgmt") + + with test.step("Configure single vlan-filtering bridge with vlan10 subinterface @ IP 10.0.0.2"): + _, tport = env.ltop.xlate("target", "data") + + target.put_config_dict("ietf-interfaces", { + "interfaces": { + "interface": [ + { + "name": "br0", + "type": "iana-if-type:bridge", + "enabled": True, + "bridge": { + "vlans": { + "pvid": 4094, + "vlan": [ + { + "vid": 10, + "untagged": [ tport ], + "tagged": [ "br0" ] + } + ] + } + } + }, + { + "name": "vlan10", + "type": "iana-if-type:l2vlan", + "enabled": True, + "parent-interface": "br0", + "encapsulation": { + "dot1q-vlan": { + "outer-tag": { + "tag-type": "ieee802-dot1q-types:c-vlan", + "vlan-id": 10, + } + } + }, + "ipv4": { + "address": [ + { + "ip": "10.0.0.2", + "prefix-length": 24, + } + ] + } + }, + { + "name": tport, + "type": "iana-if-type:ethernetCsmacd", + "enabled": True, + "infix-interfaces:bridge-port": { + "pvid": 10, + "bridge": "br0" + } + }, + ] + } + }) + + with test.step("Ping vlan10 subinterface 10.0.0.2 from host:data with IP 10.0.0.1"): + _, hport = env.ltop.xlate("host", "data") + + with infamy.IsolatedMacVlan(hport) as ns: + pingtest = ns.runsh(""" + set -ex + + ip link set iface up + ip addr add 10.0.0.1/24 dev iface + + ping -c1 -w5 10.0.0.2 || exit 1 + """) + + if pingtest.returncode: + print(pingtest.stdout) + test.fail() + + test.succeed()