Skip to content

Commit

Permalink
updates for MPLS
Browse files Browse the repository at this point in the history
  • Loading branch information
qbdwlr committed Apr 21, 2021
1 parent 757318b commit ca3ca22
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
1 change: 0 additions & 1 deletion fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ void RouteSync::onLabelRouteMsg(int nlmsg_type, struct nl_object *obj)

fvVector.push_back(nh);
fvVector.push_back(idx);
fvVector.push_back(wt);

m_label_routeTable.set(destaddr, fvVector);
SWSS_LOG_INFO("LabelRouteTable set msg: %s %s %s",
Expand Down
23 changes: 13 additions & 10 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,29 @@ bool NeighOrch::hasNextHop(const NextHopKey &nexthop)
return m_syncdNextHops.find(nexthop) != m_syncdNextHops.end();
}

bool NeighOrch::addNextHop(const NextHopKey &nexthop)
bool NeighOrch::addNextHop(const NextHopKey &nh)
{
SWSS_LOG_ENTER();

Port p;
if (!gPortsOrch->getPort(nexthop.alias, p))
if (!gPortsOrch->getPort(nh.alias, p))
{
SWSS_LOG_ERROR("Neighbor %s seen on port %s which doesn't exist",
nexthop.ip_address.to_string().c_str(), nexthop.alias.c_str());
nh.ip_address.to_string().c_str(), nh.alias.c_str());
return false;
}
if (p.m_type == Port::SUBPORT)
{
if (!gPortsOrch->getPort(p.m_parent_port_id, p))
{
SWSS_LOG_ERROR("Neighbor %s seen on sub interface %s whose parent port doesn't exist",
nexthop.ip_address.to_string().c_str(), nexthop.alias.c_str());
nh.ip_address.to_string().c_str(), nh.alias.c_str());
return false;
}
}

if(m_intfsOrch->isRemoteSystemPortIntf(nexthop.alias))
NextHopKey nexthop(nh);
if (m_intfsOrch->isRemoteSystemPortIntf(nexthop.alias))
{
//For remote system ports kernel nexthops are always on inband. Change the key
Port inbp;
Expand All @@ -199,6 +200,7 @@ bool NeighOrch::addNextHop(const NextHopKey &nexthop)

nexthop.alias = inbp.m_alias;
}

assert(!hasNextHop(nexthop));
sai_object_id_t rif_id = m_intfsOrch->getRouterIntfsId(nexthop.alias);

Expand All @@ -213,7 +215,7 @@ bool NeighOrch::addNextHop(const NextHopKey &nexthop)
next_hop_attrs.push_back(next_hop_attr);

next_hop_attr.id = SAI_NEXT_HOP_ATTR_LABELSTACK;
set<Label> label_set = nexthop.label_stack.getLabelStack();
vector<Label> label_set = nexthop.label_stack.getLabelStack();
int i = 0;
for (auto it : label_set)
{
Expand Down Expand Up @@ -407,11 +409,12 @@ bool NeighOrch::ifChangeInformNextHop(const string &alias, bool if_up)
return rc;
}

bool NeighOrch::removeNextHop(const NextHopKey& nexthop)
bool NeighOrch::removeNextHop(const NextHopKey& nh)
{
SWSS_LOG_ENTER();

if(m_intfsOrch->isRemoteSystemPortIntf(alias))
NextHopKey nexthop(nh);
if (m_intfsOrch->isRemoteSystemPortIntf(nexthop.alias))
{
//For remote system ports kernel nexthops are always on inband. Change the key
Port inbp;
Expand Down Expand Up @@ -447,12 +450,12 @@ bool NeighOrch::removeNextHop(const NextHopKey& nexthop)
if (status == SAI_STATUS_ITEM_NOT_FOUND)
{
SWSS_LOG_ERROR("Failed to locate next hop %s, rv:%d",
nexthop.to_string().c_str(), alias.c_str(), status);
nexthop.to_string().c_str(), status);
}
else
{
SWSS_LOG_ERROR("Failed to remove next hop %s, rv:%d",
nexthop.to_string().c_str(), alias.c_str(), status);
nexthop.to_string().c_str(), status);
task_process_status handle_status = handleSaiRemoveStatus(SAI_API_NEXT_HOP, status);
if (handle_status != task_success)
{
Expand Down
8 changes: 4 additions & 4 deletions orchagent/nexthopkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct NextHopKey
std::string err = "Error converting " + str + " to NextHop";
throw std::invalid_argument(err);
}
std::size_t label_delimiter = str.find(LABELSTACK_DELIMITER);
std::size_t label_delimiter = str.find(LABEL_DELIMITER);
std::string ip_str;
if (label_delimiter != std::string::npos)
{
Expand Down Expand Up @@ -69,7 +69,7 @@ struct NextHopKey
std::string err = "Error converting " + str + " to NextHop";
throw std::invalid_argument(err);
}
std::size_t label_delimiter = str.find(LABELSTACK_DELIMITER);
std::size_t label_delimiter = str.find(LABEL_DELIMITER);
std::string ip_str;
if (label_delimiter != std::string::npos)
{
Expand Down Expand Up @@ -98,7 +98,7 @@ struct NextHopKey
if (!label_stack.empty())
{
str += label_stack.to_string();
str += LABELSTACK_DELIMITER;
str += LABEL_DELIMITER;
}
str += ip_address.to_string() + NH_DELIMITER + alias;
return str;
Expand All @@ -110,7 +110,7 @@ struct NextHopKey
if (!label_stack.empty())
{
str += label_stack.to_string();
str += LABELSTACK_DELIMITER;
str += LABEL_DELIMITER;
}
str += (ip_address.to_string() + NH_DELIMITER + alias + NH_DELIMITER +
std::to_string(vni) + NH_DELIMITER + mac_address.to_string());
Expand Down
2 changes: 1 addition & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,6 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
continue;
}

sai_object_id_t next_hop_id = m_neighOrch->getNextHopId(it);
next_hop_ids.push_back(next_hop_id);
if (nhopgroup_members_set.find(next_hop_id) == nhopgroup_members_set.end())
{
Expand All @@ -1088,6 +1087,7 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
nhg_attr.value.s32 = SAI_NEXT_HOP_GROUP_TYPE_ECMP;
nhg_attrs.push_back(nhg_attr);

sai_object_id_t next_hop_group_id;
sai_status_t status = sai_next_hop_group_api->create_next_hop_group(&next_hop_group_id,
gSwitchId,
(uint32_t)nhg_attrs.size(),
Expand Down

0 comments on commit ca3ca22

Please sign in to comment.