From fb1f2cc9dfc95cce0422c74570dc3d52d4e255e9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 12 Dec 2023 12:20:29 -0500 Subject: [PATCH] zebra: Prefer local routes when they are the same Currently when a local route directly matches the connected route the connected route is preferred. Modify the code such that the local route is preferred instead. Old: L * 192.168.66.1/32 is directly connected, dummy1, 00:31:47 C>* 192.168.66.1/32 is directly connected, dummy1, 00:31:47 New: C * 192.168.66.1/32 is directly connected, dummy1, 00:00:05 L>* 192.168.66.1/32 is directly connected, dummy1, 00:00:05 Signed-off-by: Donald Sharp --- zebra/connected.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zebra/connected.c b/zebra/connected.c index 404f892f6e5c..66d0561d6c6d 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -282,6 +282,15 @@ void connected_up(struct interface *ifp, struct connected *ifc) return; } + if (install_local) { + rib_add(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_LOCAL, + 0, flags, &plocal, NULL, &nh, 0, zvrf->table_id, 0, 0, + 0, 0, false); + rib_add(afi, SAFI_MULTICAST, zvrf->vrf->vrf_id, + ZEBRA_ROUTE_LOCAL, 0, flags, &plocal, NULL, &nh, 0, + zvrf->table_id, 0, 0, 0, 0, false); + } + if (!CHECK_FLAG(ifc->flags, ZEBRA_IFA_NOPREFIXROUTE)) { rib_add(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_CONNECT, 0, flags, &p, NULL, &nh, 0, @@ -292,15 +301,6 @@ void connected_up(struct interface *ifp, struct connected *ifc) zvrf->table_id, metric, 0, 0, 0, false); } - if (install_local) { - rib_add(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_LOCAL, - 0, flags, &plocal, NULL, &nh, 0, zvrf->table_id, 0, 0, - 0, 0, false); - rib_add(afi, SAFI_MULTICAST, zvrf->vrf->vrf_id, - ZEBRA_ROUTE_LOCAL, 0, flags, &plocal, NULL, &nh, 0, - zvrf->table_id, 0, 0, 0, 0, false); - } - /* Schedule LSP forwarding entries for processing, if appropriate. */ if (zvrf->vrf->vrf_id == VRF_DEFAULT) { if (IS_ZEBRA_DEBUG_MPLS)