From 33b4a69737152eabc63991b29cdc3a1eb415f231 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 19 Dec 2016 17:17:53 +0200 Subject: [PATCH 1/2] Enables commit "orchagent: Updating the route next hop ID also sets action to forward" (#138)" This reverts commit 05bac483585dd5e564ed5db43efb1020fa25c703. --- orchagent/routeorch.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index b1b2387530..238688cf90 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -574,6 +574,7 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops) } else { + /* Set the next hop ID to a new value */ sai_status_t status = sai_route_api->set_route_attribute(&route_entry, &route_attr); if (status != SAI_STATUS_SUCCESS) { @@ -582,6 +583,18 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops) return false; } + /* Set the packet action to forward */ + 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; + } + /* Increase the ref_count for the next hop (group) entry */ increaseNextHopRefCount(nextHops); From 948c7a7bf6236de5c107ed8b6f781c95fa4ad90f Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 19 Dec 2016 17:21:37 +0200 Subject: [PATCH 2/2] Change route attrs order during used duing route modification. Based on Mellanox SAI implementation to change route action from drop to forward packet action attr should be set before next hop. --- orchagent/routeorch.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 238688cf90..01507be188 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,24 +575,27 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops) } else { - /* Set the next hop ID to a new value */ + /* 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 next hop(s) %s", - ipPrefix.to_string().c_str(), nextHops.to_string().c_str()); + SWSS_LOG_ERROR("Failed to set route %s with packet action forward, %d", + ipPrefix.to_string().c_str(), status); return false; } - /* Set the packet action to forward */ - route_attr.id = SAI_ROUTE_ATTR_PACKET_ACTION; - route_attr.value.s32 = SAI_PACKET_ACTION_FORWARD; + 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 packet action forward, %d", - ipPrefix.to_string().c_str(), status); + SWSS_LOG_ERROR("Failed to set route %s with next hop(s) %s", + ipPrefix.to_string().c_str(), nextHops.to_string().c_str()); return false; }