Skip to content

Commit

Permalink
Merge remote-tracking branch 'public/master' into dot1p_master
Browse files Browse the repository at this point in the history
  • Loading branch information
wendani committed Aug 3, 2019
2 parents b969a1c + 8fcf43d commit 8695fce
Show file tree
Hide file tree
Showing 35 changed files with 6,008 additions and 3,489 deletions.
24 changes: 16 additions & 8 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,27 @@ IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
}

void IntfMgr::setIntfIp(const string &alias, const string &opCmd,
const string &ipPrefixStr, const bool ipv4)
const IpPrefix &ipPrefix)
{
stringstream cmd;
string res;
stringstream cmd;
string res;
string ipPrefixStr = ipPrefix.to_string();
string broadcastIpStr = ipPrefix.getBroadcastIp().to_string();
int prefixLen = ipPrefix.getMaskLength();

if (ipv4)
if (ipPrefix.isV4())
{
cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " dev " << alias;
(prefixLen < 31) ?
(cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " broadcast " << broadcastIpStr <<" dev " << alias) :
(cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " dev " << alias);
}
else
{
cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " dev " << alias;
(prefixLen < 127) ?
(cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " broadcast " << broadcastIpStr << " dev " << alias) :
(cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " dev " << alias);
}

int ret = swss::exec(cmd.str(), res);
if (ret)
{
Expand Down Expand Up @@ -202,7 +210,7 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys,
// Set Interface IP except for lo
if (!is_lo)
{
setIntfIp(alias, "add", ip_prefix.to_string(), ip_prefix.isV4());
setIntfIp(alias, "add", ip_prefix);
}

std::vector<FieldValueTuple> fvVector;
Expand All @@ -219,7 +227,7 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys,
// Set Interface IP except for lo
if (!is_lo)
{
setIntfIp(alias, "del", ip_prefix.to_string(), ip_prefix.isV4());
setIntfIp(alias, "del", ip_prefix);
}
m_appIntfTableProducer.del(appKey);
m_stateIntfTable.del(keys[0] + state_db_key_delimiter + keys[1]);
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/intfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IntfMgr : public Orch
Table m_cfgIntfTable, m_cfgVlanIntfTable;
Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateVrfTable, m_stateIntfTable;

void setIntfIp(const string &alias, const string &opCmd, const string &ipPrefixStr, const bool ipv4 = true);
void setIntfIp(const string &alias, const string &opCmd, const IpPrefix &ipPrefix);
void setIntfVrf(const string &alias, const string vrfName);
bool doIntfGeneralTask(const vector<string>& keys, const vector<FieldValueTuple>& data, const string& op);
bool doIntfAddrTask(const vector<string>& keys, const vector<FieldValueTuple>& data, const string& op);
Expand Down
12 changes: 10 additions & 2 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
// The command should be generated as:
// /bin/bash -c "/sbin/ip link del Bridge 2>/dev/null ;
// /sbin/ip link add Bridge up type bridge &&
// /sbin/bridge vlan del vid 1 dev Bridge self"
// /sbin/bridge vlan del vid 1 dev Bridge self;
// /sbin/ip link del dummy 2>/dev/null;
// /sbin/ip link add dummy type dummy &&
// sbin/ip link set dummy master Bridge"

const std::string cmds = std::string("")
+ BASH_CMD + " -c \""
+ IP_CMD + " link del " + DOT1Q_BRIDGE_NAME + " 2>/dev/null; "
+ IP_CMD + " link add " + DOT1Q_BRIDGE_NAME + " up type bridge && "
+ BRIDGE_CMD + " vlan del vid " + DEFAULT_VLAN_ID + " dev " + DOT1Q_BRIDGE_NAME + " self\"";
+ BRIDGE_CMD + " vlan del vid " + DEFAULT_VLAN_ID + " dev " + DOT1Q_BRIDGE_NAME + " self; "
+ IP_CMD + " link del dev dummy 2>/dev/null; "
+ IP_CMD + " link add dummy type dummy && "
+ IP_CMD + " link set dummy master " + DOT1Q_BRIDGE_NAME + "\"";

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

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

std::string res;
Expand Down
1 change: 1 addition & 0 deletions debian/swss.install
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
swssconfig/sample/netbouncer.json etc/swss/config.d
swssconfig/sample/00-copp.config.json etc/swss/config.d
neighsyncd/restore_neighbors.py usr/bin
fpmsyncd/bgp_eoiu_marker.py usr/bin
Loading

0 comments on commit 8695fce

Please sign in to comment.