Skip to content

Commit

Permalink
orchagent: Updating the route next hop ID also sets action to forward (
Browse files Browse the repository at this point in the history
…sonic-net#145)

* Enables commit "orchagent: Updating the route next hop ID also sets action to forward" (sonic-net#138)"
This reverts commit 05bac48.

* Change route attribute order during route modification.
Based on Mellanox SAI implementation to change route action
from drop to forward packet action attribute should be set before
next hop.
  • Loading branch information
oleksandrivantsiv authored and Shuotian Cheng committed Jan 11, 2017
1 parent 3681cd2 commit 677e926
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,6 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
copy(route_entry.destination, ipPrefix);

sai_attribute_t route_attr;
route_attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID;
route_attr.value.oid = next_hop_id;

/* If the prefix is not in m_syncdRoutes, then we need to create the route
* for this prefix with the new next hop (group) id. If the prefix is already
Expand All @@ -554,6 +552,9 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
*/
if (it_route == m_syncdRoutes.end())
{
route_attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID;
route_attr.value.oid = next_hop_id;

sai_status_t status = sai_route_api->create_route(&route_entry, 1, &route_attr);
if (status != SAI_STATUS_SUCCESS)
{
Expand All @@ -574,8 +575,24 @@ 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_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;
route_attr.value.oid = next_hop_id;

/* Set the next hop ID to a new value */
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 next hop(s) %s",
ipPrefix.to_string().c_str(), nextHops.to_string().c_str());
Expand Down

0 comments on commit 677e926

Please sign in to comment.