summaryrefslogtreecommitdiff
path: root/bgpd/bgp_routemap.c
diff options
context:
space:
mode:
authorEnke Chen <enchen@paloaltonetworks.com>2024-10-16 11:15:28 -0700
committerEnke Chen <enchen@paloaltonetworks.com>2024-10-16 11:15:28 -0700
commitf65356d8bb9a43b1725fafdbd30aba0de9d214fa (patch)
treef7eb4ee6c9d51bfe17419820eac0b56b83c02601 /bgpd/bgp_routemap.c
parent75e34c032b97016d623e4e3c3b8a600c3890d4af (diff)
bgpd: fix several issues in sourcing AIGP attribute
Fix several issues in sourcing AIGP attribute: 1) AIGP should not be set as default for a redistributed route or a static network. It should be set by config instead. 2) AIGP sourced by "set aigp-metric igp-metric" in a route-map does not set the correct value for a redistributed route. 3) When redistribute a connected route like loopback, the AGIP (with value 0) is sourced by "set aigp-metric igp-metric", but the attribute is not propagated as the attribute flag is not set. Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r--bgpd/bgp_routemap.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index e5d6992d1b..8dd48575e5 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3524,19 +3524,15 @@ route_set_aigp_metric(void *rule, const struct prefix *pfx, void *object)
{
const char *aigp_metric = rule;
struct bgp_path_info *path = object;
- uint32_t aigp = 0;
+ uint32_t aigp;
- if (strmatch(aigp_metric, "igp-metric")) {
- if (!path->nexthop)
- return RMAP_NOMATCH;
-
- bgp_attr_set_aigp_metric(path->attr, path->nexthop->metric);
- } else {
+ /* Note: the metric is stored as MED for a locally redistributed. */
+ if (strmatch(aigp_metric, "igp-metric"))
+ aigp = path->nexthop ? path->nexthop->metric : path->attr->med;
+ else
aigp = atoi(aigp_metric);
- bgp_attr_set_aigp_metric(path->attr, aigp);
- }
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AIGP);
+ bgp_attr_set_aigp_metric(path->attr, aigp);
return RMAP_OKAY;
}