mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-31 04:53:01 +02:00
This implements the new model infix-if-vlan. The new CLI is: root@infix-00-00-00:/config/interfaces/interface/vlan10/> set vlan id 10 lower-layer-if eth0 with an possible extra option for tag-type, default tag-type is c-vlan.
88 lines
2.8 KiB
Python
Executable File
88 lines
2.8 KiB
Python
Executable File
#!/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": "infix-if-type:bridge",
|
|
"enabled": True,
|
|
"bridge": {
|
|
"vlans": {
|
|
"pvid": 4094,
|
|
"vlan": [
|
|
{
|
|
"vid": 10,
|
|
"untagged": [ tport ],
|
|
"tagged": [ "br0" ]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "vlan10",
|
|
"type": "infix-if-type:vlan",
|
|
"enabled": True,
|
|
"vlan": {
|
|
"lower-layer-if": "br0",
|
|
"id": 10,
|
|
},
|
|
"ipv4": {
|
|
"address": [
|
|
{
|
|
"ip": "10.0.0.2",
|
|
"prefix-length": 24,
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": tport,
|
|
"type": "infix-if-type:ethernet",
|
|
"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()
|