From c1d5b7bb9b358d9c1a73f36aaec65be6121a2bd0 Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Fri, 15 Dec 2023 18:27:39 +0800 Subject: [PATCH] bgpd: "default-originate" shouldn't withdraw non-default routes Prevent "default-originate" from withdrawing non-default routes like 0.0.0.0/1 by checking prefix length. Signed-off-by: Xiao Liang (cherry picked from commit 4d74ba929daa6e6b2fe15f9df6e61d5e4808b64c) --- bgpd/bgp_route.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2cd61b94b0..9c6b5c6fac 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2101,9 +2101,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi, * configured for default-originate */ if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) { - if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) - return false; - else if (p->family == AF_INET6 && p->prefixlen == 0) + if ((p->family == AF_INET || p->family == AF_INET6) && p->prefixlen == 0) return false; } -- 2.39.5