Skip to content

Commit 72e5537

Browse files
committed
use IP cmd to setup vlan_filter as a backup method
echo will fail in virtual switch since /sys directory is read-only. need to use ip command to setup the vlan_filtering which is not available in debian 8. Once we move sonic to debian 9, we can use IP command by default.
1 parent 2adb21a commit 72e5537

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cfgmgr/vlanmgr.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
4444

4545
cmd.str("");
4646
cmd << ECHO_CMD << " 1 > /sys/class/net/" << DOT1Q_BRIDGE_NAME << "/bridge/vlan_filtering";
47-
EXEC_WITH_ERROR_THROW(cmd.str(), res);
47+
int ret = swss::exec(cmd.str(), res);
48+
/* echo will fail in virtual switch since /sys directory is read-only.
49+
* need to use ip command to setup the vlan_filtering which is not available in debian 8.
50+
* Once we move sonic to debian 9, we can use IP command by default */
51+
if (ret != 0)
52+
{
53+
cmd.str("");
54+
cmd << IP_CMD << " link set " << DOT1Q_BRIDGE_NAME << " type bridge vlan_filtering 1";
55+
EXEC_WITH_ERROR_THROW(cmd.str(), res);
56+
}
4857

4958
cmd.str("");
5059
cmd << BRIDGE_CMD << " vlan del vid " << DEFAULT_VLAN_ID << " dev " << DOT1Q_BRIDGE_NAME << " self";

0 commit comments

Comments
 (0)