From 68ff69fa27180b7e662916f4c7d45f83f833d986 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Jan 2023 14:27:28 -0500 Subject: [PATCH] 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 */