Skip to content
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
23 changes: 23 additions & 0 deletions orchagent/mplsrouteorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern sai_object_id_t gSwitchId;
extern CrmOrch *gCrmOrch;
extern NhgOrch *gNhgOrch;
extern CbfNhgOrch *gCbfNhgOrch;
extern PortsOrch *gPortsOrch;

void RouteOrch::doLabelTask(ConsumerBase& consumer)
{
Expand Down Expand Up @@ -876,6 +877,28 @@ bool RouteOrch::removeLabelRoute(LabelRouteBulkContext& ctx)
return true;
}

if (it_route->second.nhg_index.empty())
{
const auto& nexthops = it_route->second.nhg_key.getNextHops();
const auto remote_mpls_nexthop = find_if(nexthops.begin(), nexthops.end(),
[this](const auto& nexthop)
{
return nexthop.isMplsNextHop() &&
m_intfsOrch->isRemoteSystemPortIntf(nexthop.alias);
});

if (remote_mpls_nexthop != nexthops.end())
{
Port inbp;
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote MPLS next hop %s",
remote_mpls_nexthop->to_string().c_str());
return false;
}
}
}

auto& object_statuses = ctx.object_statuses;

object_statuses.emplace_back();
Expand Down
93 changes: 70 additions & 23 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,17 @@ bool NeighOrch::addNextHop(NeighborContext& ctx)
{
//For remote system ports kernel nexthops are always on inband. Change the key
Port inbp;
gPortsOrch->getInbandPort(inbp);
assert(inbp.m_alias.length());
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote next hop %s", nh.to_string().c_str());
return false;
}
Comment thread
Xichen96 marked this conversation as resolved.

nexthop.alias = inbp.m_alias;
}

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

vector<sai_attribute_t> next_hop_attrs;

Expand Down Expand Up @@ -457,7 +460,7 @@ bool NeighOrch::addNextHop(NeighborContext& ctx)
next_hop_entry.nh_flags = 0;
m_syncdNextHops[nexthop] = next_hop_entry;

m_intfsOrch->increaseRouterIntfsRefCount(nh.alias);
m_intfsOrch->increaseRouterIntfsRefCount(nexthop.alias);

if (nexthop.isMplsNextHop())
{
Expand Down Expand Up @@ -516,6 +519,18 @@ bool NeighOrch::processBulkAddNextHop(NeighborContext& ctx)
}

NextHopKey nexthop(nh);
if (m_intfsOrch->isRemoteSystemPortIntf(nh.alias))
{
Port inbp;
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote next hop %s", nh.to_string().c_str());
return false;
}

nexthop.alias = inbp.m_alias;
}

if (ctx.next_hop_id == SAI_NULL_OBJECT_ID)
{
sai_status_t bulker_status = gNextHopBulker.create_status(ctx.next_hop_id);
Expand Down Expand Up @@ -549,7 +564,7 @@ bool NeighOrch::processBulkAddNextHop(NeighborContext& ctx)
next_hop_entry.nh_flags = 0;
m_syncdNextHops[nexthop] = next_hop_entry;

m_intfsOrch->increaseRouterIntfsRefCount(nh.alias);
m_intfsOrch->increaseRouterIntfsRefCount(nexthop.alias);

if (nexthop.isMplsNextHop())
{
Expand Down Expand Up @@ -766,8 +781,11 @@ bool NeighOrch::removeNextHop(const IpAddress &ipAddress, const string &alias)
{
//For remote system ports kernel nexthops are always on inband. Change the key
Port inbp;
gPortsOrch->getInbandPort(inbp);
assert(inbp.m_alias.length());
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote next hop %s", nexthop.to_string().c_str());
return false;
}
Comment thread
Xichen96 marked this conversation as resolved.

nexthop.alias = inbp.m_alias;
}
Expand All @@ -778,13 +796,13 @@ bool NeighOrch::removeNextHop(const IpAddress &ipAddress, const string &alias)

if (m_syncdNextHops[nexthop].ref_count > 0)
{
SWSS_LOG_ERROR("Failed to remove still referenced next hop %s on %s",
ipAddress.to_string().c_str(), alias.c_str());
SWSS_LOG_ERROR("Failed to remove still referenced next hop %s requested on %s, tracked on %s",
ipAddress.to_string().c_str(), alias.c_str(), nexthop.alias.c_str());
return false;
}

Comment thread
Xichen96 marked this conversation as resolved.
m_syncdNextHops.erase(nexthop);
m_intfsOrch->decreaseRouterIntfsRefCount(alias);
m_intfsOrch->decreaseRouterIntfsRefCount(nexthop.alias);
return true;
}

Expand All @@ -797,8 +815,12 @@ bool NeighOrch::removeMplsNextHop(const NextHopKey& nh)
{
//For remote system ports kernel nexthops are always on inband. Change the key
Port inbp;
gPortsOrch->getInbandPort(inbp);
assert(inbp.m_alias.length());
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote MPLS next hop %s",
nexthop.to_string().c_str());
return false;
}

nexthop.alias = inbp.m_alias;
}
Expand Down Expand Up @@ -1483,9 +1505,12 @@ bool NeighOrch::addNeighbor(NeighborContext& ctx)
if (bulk_op)
{
SWSS_LOG_INFO("Adding neighbor entry %s on %s to bulker.", ip_address.to_string().c_str(), alias.c_str());
if (!addNextHop(ctx))
{
return false;
}
object_statuses.emplace_back();
gNeighBulker.create_entry(&object_statuses.back(), &neighbor_entry, (uint32_t)neighbor_attrs.size(), neighbor_attrs.data());
addNextHop(ctx);
return true;
}

Expand Down Expand Up @@ -1611,15 +1636,24 @@ bool NeighOrch::removeNeighbor(NeighborContext& ctx, bool disable)
bool bulk_op = ctx.bulk_op;

NextHopKey nexthop = { ip_address, alias };
auto neighborIt = m_syncdNeighbors.find(neighborEntry);
if (neighborIt == m_syncdNeighbors.end())
{
return true;
}

sai_object_id_t port_vrf_id;
port_vrf_id = gVirtualRouterId;

if(m_intfsOrch->isRemoteSystemPortIntf(alias))
{
//For remote system ports kernel nexthops are always on inband. Change the key
Port inbp;
gPortsOrch->getInbandPort(inbp);
assert(inbp.m_alias.length());
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote neighbor %s", nexthop.to_string().c_str());
return false;
}

nexthop.alias = inbp.m_alias;
}
Expand All @@ -1634,12 +1668,6 @@ bool NeighOrch::removeNeighbor(NeighborContext& ctx, bool disable)
SWSS_LOG_ERROR("Port does not exist for %s!", alias.c_str());
}

auto neighborIt = m_syncdNeighbors.find(neighborEntry);
if (neighborIt == m_syncdNeighbors.end())
{
return true;
}

SWSS_LOG_INFO("Try to remove neighbor %s on %s",
ip_address.to_string().c_str(), alias.c_str());

Expand Down Expand Up @@ -1742,7 +1770,10 @@ bool NeighOrch::removeNeighbor(NeighborContext& ctx, bool disable)
gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_IPV6_NEIGHBOR);
}

removeNextHop(ip_address, alias);
if (!removeNextHop(ip_address, nexthop.alias))
{
return false;
}
m_intfsOrch->decreaseRouterIntfsRefCount(alias);
SWSS_LOG_NOTICE("Removed neighbor %s on %s",
m_syncdNeighbors[neighborEntry].mac.to_string().c_str(), alias.c_str());
Expand Down Expand Up @@ -1891,12 +1922,25 @@ bool NeighOrch::processBulkDisableNeighbor(NeighborContext& ctx)
const NeighborEntry neighborEntry = ctx.neighborEntry;
string alias = neighborEntry.alias;
IpAddress ip_address = neighborEntry.ip_address;
NextHopKey nexthop = { ip_address, alias };

if (m_syncdNeighbors.find(neighborEntry) == m_syncdNeighbors.end())
{
return true;
}

if (m_intfsOrch->isRemoteSystemPortIntf(alias))
{
Port inbp;
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote neighbor %s", nexthop.to_string().c_str());
return false;
}

nexthop.alias = inbp.m_alias;
}

SWSS_LOG_INFO("Checking neighbor remove entry status %s on %s.", ip_address.to_string().c_str(), m_syncdNeighbors[neighborEntry].mac.to_string().c_str());

if (isHwConfigured(neighborEntry))
Expand Down Expand Up @@ -1972,7 +2016,10 @@ bool NeighOrch::processBulkDisableNeighbor(NeighborContext& ctx)
gCrmOrch->decCrmResUsedCounter(CrmResourceType::CRM_IPV6_NEIGHBOR);
}

removeNextHop(ip_address, alias);
if (!removeNextHop(ip_address, nexthop.alias))
{
return false;
}
m_intfsOrch->decreaseRouterIntfsRefCount(alias);
SWSS_LOG_NOTICE("Removed neighbor %s on %s",
m_syncdNeighbors[neighborEntry].mac.to_string().c_str(), alias.c_str());
Expand Down
21 changes: 21 additions & 0 deletions orchagent/nhgorch.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <random>
#include "nhgorch.h"
#include "neighorch.h"
Expand Down Expand Up @@ -878,6 +879,26 @@ bool NextHopGroup::remove()
{
return true;
}

const auto remote_mpls_member = find_if(m_members.begin(), m_members.end(),
[](const auto& member)
{
const auto& nh_key = member.first;
return nh_key.isMplsNextHop() &&
gIntfsOrch->isRemoteSystemPortIntf(nh_key.alias);
});

if (remote_mpls_member != m_members.end())
{
Port inbp;
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote MPLS next hop %s",
remote_mpls_member->first.to_string().c_str());
return false;
}
}

// If the group is temporary or non-recursive, update the neigh or rif ref-count and reset the ID.
if (m_is_temp ||
(!isRecursive() && m_members.size() == 1))
Expand Down
32 changes: 30 additions & 2 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,10 @@ bool RouteOrch::addNextHopGroup(const NextHopGroupKey &nexthops)
m_neighOrch->hasNextHop(NextHopKey(it.ip_address, it.alias)))
{
NeighborContext ctx = NeighborContext(it);
m_neighOrch->addNextHop(ctx);
if (!m_neighOrch->addNextHop(ctx))
{
return false;
}
next_hop_id = m_neighOrch->getNextHopId(it);
}
else
Expand Down Expand Up @@ -2118,7 +2121,10 @@ bool RouteOrch::addRoute(RouteBulkContext& ctx, const NextHopGroupKey &nextHops)
{
/* since IP neighbor NH exists, neighbor is resolved, add MPLS NH */
NeighborContext ctx = NeighborContext(nexthop);
m_neighOrch->addNextHop(ctx);
if (!m_neighOrch->addNextHop(ctx))
{
return false;
}
next_hop_id = m_neighOrch->getNextHopId(nexthop);
}
/* IP neighbor is not yet resolved */
Expand Down Expand Up @@ -2792,6 +2798,28 @@ bool RouteOrch::removeRoute(RouteBulkContext& ctx)
return true;
}

if (it_route != it_route_table->second.end() && it_route->second.nhg_index.empty())
{
const auto& nexthops = it_route->second.nhg_key.getNextHops();
const auto remote_mpls_nexthop = find_if(nexthops.begin(), nexthops.end(),
[this](const auto& nexthop)
{
return nexthop.isMplsNextHop() &&
m_intfsOrch->isRemoteSystemPortIntf(nexthop.alias);
});

if (remote_mpls_nexthop != nexthops.end())
{
Port inbp;
if (!gPortsOrch->getInbandPort(inbp))
{
SWSS_LOG_INFO("Inband port is not available for remote MPLS next hop %s",
remote_mpls_nexthop->to_string().c_str());
return false;
}
}
}

auto& object_statuses = ctx.object_statuses;

// set to blackhole for default route
Expand Down
Loading
Loading