Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[routeorch]: Do not set packet action for updating next hop ID #200

Merged
merged 1 commit into from
Apr 28, 2017
Merged
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
54 changes: 32 additions & 22 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) :
throw runtime_error("Failed to create v4 default route with packet action drop");
}

// add default v4 route into the m_syncdRoutes
m_syncdRoutes[default_ip_prefix] = IpAddresses("0.0.0.0");
/* Add default IPv4 route into the m_syncdRoutes */
m_syncdRoutes[default_ip_prefix] = IpAddresses();

SWSS_LOG_NOTICE("Create v4 default route with packet action drop");
SWSS_LOG_NOTICE("Create IPv4 default route with packet action drop");

IpPrefix v6_default_ip_prefix("::/0");

Expand All @@ -89,10 +89,10 @@ RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) :
throw runtime_error("Failed to create v6 default route with packet action drop");
}

// add default v6 route into the m_syncdRoutes
m_syncdRoutes[v6_default_ip_prefix] = IpAddresses("::");
/* Add default IPv6 route into the m_syncdRoutes */
m_syncdRoutes[v6_default_ip_prefix] = IpAddresses();

SWSS_LOG_NOTICE("Create v6 default route with packet action drop");
SWSS_LOG_NOTICE("Create IPv6 default route with packet action drop");
}

bool RouteOrch::hasNextHopGroup(IpAddresses ipAddresses)
Expand Down Expand Up @@ -359,7 +359,12 @@ void RouteOrch::notifyNextHopChangeObservers(IpPrefix prefix, IpAddresses nextho

void RouteOrch::increaseNextHopRefCount(IpAddresses ipAddresses)
{
if (ipAddresses.getSize() == 1)
/* Return when there is no next hop (dropped) */
if (ipAddresses.getSize() == 0)
{
return;
}
else if (ipAddresses.getSize() == 1)
{
IpAddress ip_address(ipAddresses.to_string());
m_neighOrch->increaseNextHopRefCount(ip_address);
Expand All @@ -371,16 +376,15 @@ void RouteOrch::increaseNextHopRefCount(IpAddresses ipAddresses)
}
void RouteOrch::decreaseNextHopRefCount(IpAddresses ipAddresses)
{
if (ipAddresses.getSize() == 1)
/* Return when there is no next hop (dropped) */
if (ipAddresses.getSize() == 0)
{
return;
}
else if (ipAddresses.getSize() == 1)
{
IpAddress ip_address(ipAddresses.to_string());

// skip blackhole route
if (ip_address.isZero())
{
return;
}

m_neighOrch->decreaseNextHopRefCount(ip_address);
}
else
Expand Down Expand Up @@ -580,6 +584,7 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
route_attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID;
route_attr.value.oid = next_hop_id;

/* Default SAI_ROUTE_ATTR_PACKET_ACTION is SAI_PACKET_ACTION_FORWARD */
sai_status_t status = sai_route_api->create_route(&route_entry, 1, &route_attr);
if (status != SAI_STATUS_SUCCESS)
{
Expand All @@ -600,16 +605,21 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
}
else
{
/* Set the packet action to forward */
route_attr.id = SAI_ROUTE_ATTR_PACKET_ACTION;
route_attr.value.s32 = SAI_PACKET_ACTION_FORWARD;
sai_status_t status;

sai_status_t status = sai_route_api->set_route_attribute(&route_entry, &route_attr);
if (status != SAI_STATUS_SUCCESS)
/* Set the packet action to forward when there was no next hop (dropped) */
if (it_route->second.getSize() == 0)
{
SWSS_LOG_ERROR("Failed to set route %s with packet action forward, %d",
ipPrefix.to_string().c_str(), status);
return false;
route_attr.id = SAI_ROUTE_ATTR_PACKET_ACTION;
route_attr.value.s32 = SAI_PACKET_ACTION_FORWARD;

status = sai_route_api->set_route_attribute(&route_entry, &route_attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set route %s with packet action forward, %d",
ipPrefix.to_string().c_str(), status);
return false;
}
}

route_attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID;
Expand Down