From fa8663141e2781dc3fc894c0e58c2e3ca69f2be8 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 26 Dec 2024 17:26:42 +0200 Subject: [PATCH] bgpd: Respect `bgp bestpath missing-as-worst` for `table-map` as well Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 2 +- bgpd/bgp_route.h | 1 + bgpd/bgp_zebra.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index bd2fda56fc..14a5358334 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -649,7 +649,7 @@ static bool use_bgp_med_value(struct attr *attr, struct bgp *bgp) /* Get MED value. If MED value is missing and "bgp bestpath missing-as-worst" is specified, treat it as the worst value. */ -static uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp) +uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))) return attr->med; diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index bde0580d6c..235b5732ed 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -1012,4 +1012,5 @@ extern void bgp_meta_queue_free(struct meta_queue *mq); extern int early_route_process(struct bgp *bgp, struct bgp_dest *dest); extern int other_route_process(struct bgp *bgp, struct bgp_dest *dest); extern int eoiu_marker_process(struct bgp *bgp, struct bgp_dest *dest); +extern uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp); #endif /* _QUAGGA_BGP_ROUTE_H */ diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index e3465feda8..7ad9ce4726 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1339,7 +1339,7 @@ static void bgp_zebra_announce_parse_nexthop( * overridden on 1st nexthop */ if (mpinfo == info) { if (metric) - *metric = mpinfo_cp->attr->med; + *metric = bgp_med_value(mpinfo_cp->attr, bgp); if (tag) *tag = mpinfo_cp->attr->tag; }