Skip to content
Merged
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
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