From 677e926eee57cbefa4367fae43e53b4436521e31 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Wed, 11 Jan 2017 02:52:54 +0200 Subject: [PATCH] orchagent: Updating the route next hop ID also sets action to forward (#145) * Enables commit "orchagent: Updating the route next hop ID also sets action to forward" (#138)" This reverts commit 05bac483585dd5e564ed5db43efb1020fa25c703. * 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. --- orchagent/routeorch.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 9100629e9a15..1fa34f7b47bd 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -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 @@ -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) { @@ -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());