From 1cd8bd054c6eafdcda1f5b1626f89622d170f536 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Jan 2023 14:23:51 -0500 Subject: [PATCH 1/2] zebra: Fix distance being set incorrectly on kernel offload update When we are notified about the kernel about a route being offloaded or not correctly set the distance. Ticket: CM-33097 Signed-off-by: Donald Sharp --- zebra/zebra_rib.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 9551f26d80..03f2591cfe 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2711,10 +2711,6 @@ static void process_subq_early_route_add(struct zebra_early_route *ere) if (ere->src_p_provided) apply_mask_ipv6(&ere->src_p); - /* Set default distance by route type. */ - if (re->distance == 0) - re->distance = route_distance(re->type); - /* Lookup route node.*/ rn = srcdest_rnode_get(table, &ere->p, ere->src_p_provided ? &ere->src_p : NULL); @@ -2761,6 +2757,14 @@ static void process_subq_early_route_add(struct zebra_early_route *ere) } } + /* Set default distance by route type. */ + if (re->distance == 0) { + if (same && !zebra_router_notify_on_ack()) + re->distance = same->distance; + else + re->distance = route_distance(re->type); + } + /* If this route is kernel/connected route, notify the dataplane. */ if (RIB_SYSTEM_ROUTE(re)) { /* Notify dataplane */ From 68ff69fa27180b7e662916f4c7d45f83f833d986 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Jan 2023 14:27:28 -0500 Subject: [PATCH 2/2] zebra: Set metric appropriately on route offload to asic When FRR receives a route from the kernel about the route offload success/failure. The metric being reported is not going to be correct since we may not know it appropriately at this point in time. If we can set the metric to something appropriate. Signed-off-by: Donald Sharp --- zebra/rt.h | 2 ++ zebra/rt_netlink.c | 2 +- zebra/rt_netlink.h | 1 - zebra/zebra_rib.c | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/zebra/rt.h b/zebra/rt.h index d8a22d2cfc..4cf4c9d780 100644 --- a/zebra/rt.h +++ b/zebra/rt.h @@ -35,6 +35,8 @@ extern "C" { #endif +#define ROUTE_INSTALLATION_METRIC 20 + #define RKERNEL_ROUTE(type) ((type) == ZEBRA_ROUTE_KERNEL) #define RSYSTEM_ROUTE(type) \ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 33fe8db99e..206ab12895 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2077,7 +2077,7 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, * by the routing protocol and for communicating with protocol peers. */ if (!nl_attr_put32(&req->n, datalen, RTA_PRIORITY, - NL_DEFAULT_ROUTE_METRIC)) + ROUTE_INSTALLATION_METRIC)) return 0; #if defined(SUPPORT_REALMS) diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h index fd2b79a2bf..d36fe82afe 100644 --- a/zebra/rt_netlink.h +++ b/zebra/rt_netlink.h @@ -30,7 +30,6 @@ extern "C" { #endif -#define NL_DEFAULT_ROUTE_METRIC 20 /* * Additional protocol strings to push into routes diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 03f2591cfe..73aa57c986 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2765,6 +2765,14 @@ static void process_subq_early_route_add(struct zebra_early_route *ere) re->distance = route_distance(re->type); } + if (re->metric == ROUTE_INSTALLATION_METRIC && + CHECK_FLAG(re->flags, ZEBRA_FLAG_SELFROUTE)) { + if (same && !zebra_router_notify_on_ack()) + re->metric = same->metric; + else + re->metric = 0; + } + /* If this route is kernel/connected route, notify the dataplane. */ if (RIB_SYSTEM_ROUTE(re)) { /* Notify dataplane */