Skip to content

Commit 81283fb

Browse files
jipanyangTony Titus
authored and
Tony Titus
committed
Fix VLAN error introduced with new 4.9 kernel behavior (sonic-net#1001)
The change includes two parts: <1> Bring member out of default VLAN 1 upon putting port/lag in a VLAN <2> Second part was done by @tieguoevan ( https://github.com/tieguoevan) and incorporated here to avoid test error that would follow change <1>. Summary: The Bridge interface needs to be up all the time. Otherwise, the command bridge vlan will fail. Not sure it is a kernel bug, but it cause error when clear all vlan members and reconfigure it. create a dummy interface in the Bridge to keep it up all the time Signed-off-by: Jipan Yang <[email protected]>
1 parent 4160813 commit 81283fb

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

cfgmgr/vlanmgr.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
5151
// The command should be generated as:
5252
// /bin/bash -c "/sbin/ip link del Bridge 2>/dev/null ;
5353
// /sbin/ip link add Bridge up type bridge &&
54-
// /sbin/bridge vlan del vid 1 dev Bridge self"
54+
// /sbin/bridge vlan del vid 1 dev Bridge self;
55+
// /sbin/ip link del dummy 2>/dev/null;
56+
// /sbin/ip link add dummy type dummy &&
57+
// sbin/ip link set dummy master Bridge"
5558

5659
const std::string cmds = std::string("")
5760
+ BASH_CMD + " -c \""
5861
+ IP_CMD + " link del " + DOT1Q_BRIDGE_NAME + " 2>/dev/null; "
5962
+ IP_CMD + " link add " + DOT1Q_BRIDGE_NAME + " up type bridge && "
60-
+ BRIDGE_CMD + " vlan del vid " + DEFAULT_VLAN_ID + " dev " + DOT1Q_BRIDGE_NAME + " self\"";
63+
+ BRIDGE_CMD + " vlan del vid " + DEFAULT_VLAN_ID + " dev " + DOT1Q_BRIDGE_NAME + " self; "
64+
+ IP_CMD + " link del dev dummy 2>/dev/null; "
65+
+ IP_CMD + " link add dummy type dummy && "
66+
+ IP_CMD + " link set dummy master " + DOT1Q_BRIDGE_NAME + "\"";
6167

6268
std::string res;
6369
EXEC_WITH_ERROR_THROW(cmds, res);
@@ -169,10 +175,12 @@ bool VlanMgr::addHostVlanMember(int vlan_id, const string &port_alias, const str
169175

170176
// The command should be generated as:
171177
// /bin/bash -c "/sbin/ip link set {{port_alias}} master Bridge &&
178+
// /sbin/bridge vlan del vid 1 dev {{ port_alias }} &&
172179
// /sbin/bridge vlan add vid {{vlan_id}} dev {{port_alias}} {{tagging_mode}}"
173180
const std::string cmds = std::string("")
174181
+ BASH_CMD + " -c \""
175182
+ IP_CMD + " link set " + port_alias + " master " + DOT1Q_BRIDGE_NAME + " && "
183+
+ BRIDGE_CMD + " vlan del vid " + DEFAULT_VLAN_ID + " dev " + port_alias + " && "
176184
+ BRIDGE_CMD + " vlan add vid " + std::to_string(vlan_id) + " dev " + port_alias + " " + tagging_cmd + "\"";
177185

178186
std::string res;

tests/test_vlan.py

+8
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ def test_MultipleVlan(self, dvs, testlog):
155155
vlan_member_entries = tbl.getKeys()
156156
assert len(vlan_member_entries) == 0
157157

158+
# member ports should have been detached from bridge master properly
159+
exitcode, output = dvs.runcmd(['sh', '-c', "ip link show Ethernet20 | grep -w master"])
160+
assert exitcode != 0
161+
exitcode, output = dvs.runcmd(['sh', '-c', "ip link show Ethernet24 | grep -w master"])
162+
assert exitcode != 0
163+
exitcode, output = dvs.runcmd(['sh', '-c', "ip link show Ethernet28 | grep -w master"])
164+
assert exitcode != 0
165+
158166
# remove vlans
159167
dvs.remove_vlan("18")
160168
dvs.remove_vlan("188")

0 commit comments

Comments
 (0)