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

Fix for issue: "Failed to set default drop route to a new next hop #139" #145

Merged
merged 2 commits into from
Jan 11, 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
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