From 04c14268240904203d37c969133b729858c4572e Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Mon, 19 Jun 2023 09:10:57 +0800 Subject: [PATCH] zebra: Remove unnecessary condition check for kernel routes There are relaxed nexthop requirements for kernel routes because we trust kernel routes. Two minor changes for kernel routes: 1. `if_is_up()` is one of the necessary conditions for `if_is_operative()`. Here, we can remove this unnecessary check for clarity. 2. Since `nexthop_active()` doesn't distinguish whether it is kernel route, modified the corresponding comment in it. Signed-off-by: anlan_cs (cherry picked from commit caf896d6ef18d917a9b9cee9cb48719ea9757e37) --- zebra/zebra_nhg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 96e021292b..fb474b1add 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2181,11 +2181,7 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, case NEXTHOP_TYPE_IFINDEX: ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); - /* - * If the interface exists and its operative or its a kernel - * route and interface is up, its active. We trust kernel routes - * to be good. - */ + /* If the interface exists and its operative, it's active */ if (ifp && (if_is_operative(ifp))) return 1; else @@ -2595,7 +2591,7 @@ static unsigned nexthop_active_check(struct route_node *rn, ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); - if (ifp && (if_is_operative(ifp) || if_is_up(ifp))) { + if (ifp && if_is_up(ifp)) { SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); goto skip_check; } -- 2.39.5