Skip to content

Commit

Permalink
[vlanmgr]: use IP cmd to setup vlan_filter as a backup method (sonic-…
Browse files Browse the repository at this point in the history
…net#401)

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.
  • Loading branch information
lguohan authored Nov 30, 2017
1 parent 2adb21a commit 57a98ac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c

cmd.str("");
cmd << ECHO_CMD << " 1 > /sys/class/net/" << DOT1Q_BRIDGE_NAME << "/bridge/vlan_filtering";
EXEC_WITH_ERROR_THROW(cmd.str(), res);
int ret = swss::exec(cmd.str(), res);
/* 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 */
if (ret != 0)
{
cmd.str("");
cmd << IP_CMD << " link set " << DOT1Q_BRIDGE_NAME << " type bridge vlan_filtering 1";
EXEC_WITH_ERROR_THROW(cmd.str(), res);
}

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

0 comments on commit 57a98ac

Please sign in to comment.