Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port is not adding to portchannel when the port is removed from participating VLAN and not member of any VLAN. #886

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cfgmgr/shellcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define ECHO_CMD "/bin/echo"
#define BASH_CMD "/bin/bash"
#define GREP_CMD "/bin/grep"
#define SED_CMD "/bin/sed"
#define TEAMD_CMD "/usr/bin/teamd"
#define TEAMDCTL_CMD "/usr/bin/teamdctl"

Expand Down
47 changes: 45 additions & 2 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,48 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c

EXEC_WITH_ERROR_THROW(echo_cmd_backup, res);
}

// Create dummy interface
const std::string dummy_cmds = std::string("")
+ IP_CMD + " link show dummy 2>/dev/null";

ret = swss::exec(dummy_cmds, res);
if (ret == 0)
{
// Don't create dummy interface as it already exists.
SWSS_LOG_DEBUG("vlanmgrd dummy interface already exists.");
}
else
{
// Create Linux dot1q bridge dummy interface.
// The command should be generated as:
// /bin/bash -c "/sbin/ip link add dummy type dummy"
//
const std::string dummy_if_cmds = std::string("")
+ BASH_CMD + " -c \""
+ IP_CMD + " link add dummy type dummy\"";

ret = swss::exec(dummy_if_cmds, res);
if (ret != 0)
{
SWSS_LOG_INFO("vlanmgrd failed to create dummy interface.");
return;
}
}

// dot1q bridge dummy interface - to make the Bridge interface UP all the time.
// The command should be generated as:
// /bin/bash -c "/sbin/ip link set dummy master Bridge"
//
const std::string dummy_ifup_cmds = std::string("")
+ BASH_CMD + " -c \""
+ IP_CMD + " link set dummy up master Bridge\"";

ret = swss::exec(dummy_ifup_cmds, res);
if (ret != 0)
{
SWSS_LOG_INFO("vlanmgrd failed to set dummy interface to make the Bridge interface always UP.");
}
}

bool VlanMgr::addHostVlan(int vlan_id)
Expand Down Expand Up @@ -187,7 +229,7 @@ bool VlanMgr::removeHostVlanMember(int vlan_id, const string &port_alias)

// The command should be generated as:
// /bin/bash -c '/sbin/bridge vlan del vid {{vlan_id}} dev {{port_alias}} &&
// ( /sbin/bridge vlan show dev {{port_alias}} | /bin/grep -q None;
// ( /sbin/bridge vlan show dev {{port_alias}} | /bin/sed -n '/^$/=' | /bin/grep -q -c ^3$;
// ret=$?; if [ $ret -eq 0 ]; then
// /sbin/ip link set {{port_alias}} nomaster;
// elif [ $ret -eq 1 ]; then exit 0;
Expand All @@ -198,7 +240,8 @@ bool VlanMgr::removeHostVlanMember(int vlan_id, const string &port_alias)
+ BASH_CMD + " -c \'"
+ BRIDGE_CMD + " vlan del vid " + std::to_string(vlan_id) + " dev " + port_alias + " && ( "
+ BRIDGE_CMD + " vlan show dev " + port_alias + " | "
+ GREP_CMD + " -q None; ret=$?; if [ $ret -eq 0 ]; then "
+ SED_CMD + " -n \'/^$/=\' " + " | "
+ GREP_CMD + " -q -c ^3$; ret=$?; if [ $ret -eq 0 ]; then "
+ IP_CMD + " link set " + port_alias + " nomaster; "
+ "elif [ $ret -eq 1 ]; then exit 0; "
+ "else exit $ret; fi )\'";
Expand Down