From 38566b8fbdec60b1601ed127fd759c85802909e9 Mon Sep 17 00:00:00 2001 From: jack9603301 Date: Sat, 9 Jan 2021 21:32:19 +0800 Subject: bridge: T3137: Let VLAN aware bridge approach the behavior of professional equipment According to the consensus, the specific behavior of a VLAN aware bridge should conform to the behavior of professional equipment. This commit makes a significant change to the behavior of VLAN aware bridge, and has the following behaviors: 1. Disable `vif 1` configuration 2. When the VLAN aware bridge is enabled, the parent interface is always VLAN 1 3. When `native-vlan` is not configured, the default behavior of the device is `native-vlan 1` 4. The VLAN ids forwarded by the bridge are determined by `vif` 5. It has an `enable-vlan` node to enable VLAN awareness 6. VLAN configuration is allowed only when VLAN aware bridge is activated --- smoketest/scripts/cli/test_interfaces_bridge.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'smoketest/scripts') diff --git a/smoketest/scripts/cli/test_interfaces_bridge.py b/smoketest/scripts/cli/test_interfaces_bridge.py index 464226b6f..c1e98cc67 100755 --- a/smoketest/scripts/cli/test_interfaces_bridge.py +++ b/smoketest/scripts/cli/test_interfaces_bridge.py @@ -25,14 +25,13 @@ from netifaces import interfaces from vyos.ifconfig import Section from vyos.util import cmd from vyos.util import read_file +from vyos.validate import is_intf_addr_assigned class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): def setUp(self): self._test_ip = True self._test_ipv6 = True self._test_ipv6_pd = True - self._test_vlan = True - self._test_qinq = True self._base_path = ['interfaces', 'bridge'] self._mirror_interfaces = ['dum21354'] self._members = [] @@ -52,6 +51,12 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): self._interfaces = list(self._options) super().setUp() + + def tearDown(self): + for intf in self._interfaces: + self.session.delete(self._base_path + [intf]) + + super().tearDown() def test_add_remove_bridge_member(self): # Add member interfaces to bridge and set STP cost/priority @@ -88,11 +93,15 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): self.session.commit() def test_bridge_vlan_filter(self): + + vif_vlan = 2 # Add member interface to bridge and set VLAN filter for interface in self._interfaces: base = self._base_path + [interface] - self.session.set(base + ['vif', '1', 'address', '192.0.2.1/24']) - self.session.set(base + ['vif', '2', 'address', '192.0.3.1/24']) + self.session.set(base + ['enable-vlan']) + self.session.set(base + ['address', '192.0.2.1/24']) + self.session.set(base + ['vif', str(vif_vlan), 'address', '192.0.3.1/24']) + self.session.set(base + ['vif', str(vif_vlan), 'mtu', self._mtu]) vlan_id = 101 allowed_vlan = 2 @@ -159,7 +168,13 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): for member in self._members: self.assertIn(member, bridge_members) - + + # Check VLAN sub interface + for intf in self._interfaces: + vif = f'{intf}.{vif_vlan}' + tmp = read_file(f'/sys/class/net/{vif}/mtu') + self.assertEqual(tmp, self._mtu) + # delete all members for interface in self._interfaces: self.session.delete(self._base_path + [interface, 'member']) -- cgit v1.2.3