Skip to content

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
gechiang committed May 26, 2021
2 parents 3522e81 + a44e651 commit 37285d1
Show file tree
Hide file tree
Showing 23 changed files with 1,627 additions and 474 deletions.
134 changes: 67 additions & 67 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,15 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,

string alias(keys[0]);
string vlanId;
string subIntfAlias;
string parentAlias;
size_t found = alias.find(VLAN_SUB_INTERFACE_SEPARATOR);
if (found != string::npos)
{
// This is a sub interface
// subIntfAlias holds the complete sub interface name
// while alias becomes the parent interface
subIntfAlias = alias;
// alias holds the complete sub interface name
// while parentAlias holds the parent port name
vlanId = alias.substr(found + 1);
alias = alias.substr(0, found);
parentAlias = alias.substr(0, found);
}
bool is_lo = !alias.compare(0, strlen(LOOPBACK_PREFIX), LOOPBACK_PREFIX);
string mac = "";
Expand Down Expand Up @@ -482,7 +481,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,

if (op == SET_COMMAND)
{
if (!isIntfStateOk(alias))
if (!isIntfStateOk(parentAlias.empty() ? alias : parentAlias))
{
SWSS_LOG_DEBUG("Interface is not ready, skipping %s", alias.c_str());
return false;
Expand Down Expand Up @@ -520,74 +519,28 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
}
}

if (!vrf_name.empty())
{
setIntfVrf(alias, vrf_name);
}

/*Set the mac of interface*/
if (!mac.empty())
{
setIntfMac(alias, mac);
}
else
{
FieldValueTuple fvTuple("mac_addr", MacAddress().to_string());
data.push_back(fvTuple);
}

if (!proxy_arp.empty())
if (!parentAlias.empty())
{
if (!setIntfProxyArp(alias, proxy_arp))
{
SWSS_LOG_ERROR("Failed to set proxy ARP to \"%s\" state for the \"%s\" interface", proxy_arp.c_str(), alias.c_str());
return false;
}

if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX))
{
FieldValueTuple fvTuple("proxy_arp", proxy_arp);
data.push_back(fvTuple);
}
}

if (!grat_arp.empty())
{
if (!setIntfGratArp(alias, grat_arp))
{
SWSS_LOG_ERROR("Failed to set ARP accept to \"%s\" state for the \"%s\" interface", grat_arp.c_str(), alias.c_str());
return false;
}

if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX))
{
FieldValueTuple fvTuple("grat_arp", grat_arp);
data.push_back(fvTuple);
}
}

if (!subIntfAlias.empty())
{
if (m_subIntfList.find(subIntfAlias) == m_subIntfList.end())
if (m_subIntfList.find(alias) == m_subIntfList.end())
{
try
{
addHostSubIntf(alias, subIntfAlias, vlanId);
addHostSubIntf(parentAlias, alias, vlanId);
}
catch (const std::runtime_error &e)
{
SWSS_LOG_NOTICE("Sub interface ip link add failure. Runtime error: %s", e.what());
return false;
}

m_subIntfList.insert(subIntfAlias);
m_subIntfList.insert(alias);
}

if (!mtu.empty())
{
try
{
setHostSubIntfMtu(subIntfAlias, mtu);
setHostSubIntfMtu(alias, mtu);
}
catch (const std::runtime_error &e)
{
Expand All @@ -609,7 +562,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
}
try
{
setHostSubIntfAdminStatus(subIntfAlias, adminStatus);
setHostSubIntfAdminStatus(alias, adminStatus);
}
catch (const std::runtime_error &e)
{
Expand All @@ -618,10 +571,57 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
}

// set STATE_DB port state
setSubIntfStateOk(subIntfAlias);
setSubIntfStateOk(alias);
}
m_appIntfTableProducer.set(subIntfAlias.empty() ? alias : subIntfAlias, data);
m_stateIntfTable.hset(subIntfAlias.empty() ? alias : subIntfAlias, "vrf", vrf_name);

if (!vrf_name.empty())
{
setIntfVrf(alias, vrf_name);
}

/*Set the mac of interface*/
if (!mac.empty())
{
setIntfMac(alias, mac);
}
else
{
FieldValueTuple fvTuple("mac_addr", MacAddress().to_string());
data.push_back(fvTuple);
}

if (!proxy_arp.empty())
{
if (!setIntfProxyArp(alias, proxy_arp))
{
SWSS_LOG_ERROR("Failed to set proxy ARP to \"%s\" state for the \"%s\" interface", proxy_arp.c_str(), alias.c_str());
return false;
}

if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX))
{
FieldValueTuple fvTuple("proxy_arp", proxy_arp);
data.push_back(fvTuple);
}
}

if (!grat_arp.empty())
{
if (!setIntfGratArp(alias, grat_arp))
{
SWSS_LOG_ERROR("Failed to set ARP accept to \"%s\" state for the \"%s\" interface", grat_arp.c_str(), alias.c_str());
return false;
}

if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX))
{
FieldValueTuple fvTuple("grat_arp", grat_arp);
data.push_back(fvTuple);
}
}

m_appIntfTableProducer.set(alias, data);
m_stateIntfTable.hset(alias, "vrf", vrf_name);
}
else if (op == DEL_COMMAND)
{
Expand All @@ -640,16 +640,16 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
m_loopbackIntfList.erase(alias);
}

if (!subIntfAlias.empty())
if (!parentAlias.empty())
{
removeHostSubIntf(subIntfAlias);
m_subIntfList.erase(subIntfAlias);
removeHostSubIntf(alias);
m_subIntfList.erase(alias);

removeSubIntfState(subIntfAlias);
removeSubIntfState(alias);
}

m_appIntfTableProducer.del(subIntfAlias.empty() ? alias : subIntfAlias);
m_stateIntfTable.del(subIntfAlias.empty() ? alias : subIntfAlias);
m_appIntfTableProducer.del(alias);
m_stateIntfTable.del(alias);
}
else
{
Expand Down
39 changes: 39 additions & 0 deletions fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)
/* Get nexthop lists */
string nexthops = getNextHopGw(route_obj);
string ifnames = getNextHopIf(route_obj);
string weights = getNextHopWt(route_obj);

vector<string> alsv = tokenize(ifnames, ',');
for (auto alias : alsv)
Expand All @@ -722,6 +723,11 @@ void RouteSync::onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf)

fvVector.push_back(nh);
fvVector.push_back(idx);
if (!weights.empty())
{
FieldValueTuple wt("weight", weights);
fvVector.push_back(wt);
}

if (!warmRestartInProgress)
{
Expand Down Expand Up @@ -962,3 +968,36 @@ string RouteSync::getNextHopIf(struct rtnl_route *route_obj)

return result;
}

/*
* Get next hop weights
* @arg route_obj route object
*
* Return concatenation of interface names: wt0 + "," + wt1 + .... + "," + wtN
*/
string RouteSync::getNextHopWt(struct rtnl_route *route_obj)
{
string result = "";

for (int i = 0; i < rtnl_route_get_nnexthops(route_obj); i++)
{
struct rtnl_nexthop *nexthop = rtnl_route_nexthop_n(route_obj, i);
/* Get the weight of next hop */
uint8_t weight = rtnl_route_nh_get_weight(nexthop);
if (weight)
{
result += to_string(weight + 1);
}
else
{
return "";
}

if (i + 1 < rtnl_route_get_nnexthops(route_obj))
{
result += string(",");
}
}

return result;
}
3 changes: 3 additions & 0 deletions fpmsyncd/routesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class RouteSync : public NetMsg

/* Get next hop interfaces */
string getNextHopIf(struct rtnl_route *route_obj);

/* Get next hop weights*/
string getNextHopWt(struct rtnl_route *route_obj);
};

}
Expand Down
Loading

0 comments on commit 37285d1

Please sign in to comment.