Commit 751dec1cd6 for frr
commit 751dec1cd6eb59aa1cd475c6c9c20c39a0dd8bf2
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date: Mon Oct 12 18:54:19 2026 +0200
bgpd: add set aigp-metric none
A route received with the AIGP attribute keeps it, and there is no way
to remove it with a route-map: "no set aigp-metric" only removes the
action from the route-map entry. For instance, a route reflector which
does not change the nexthop cannot remove an AIGP attribute added by an
inbound route-map, or a router cannot remove the AIGP attribute from a
route whose path leads outside the AIGP administrative domain.
RFC 7311 section 3.4.1 forbids to add the AIGP attribute to such routes,
and to routes for which the router does not set itself as nexthop.
Fix this by adding "set aigp-metric none", which removes the AIGP
attribute from the route, like "set community none".
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index ff92a4d532..685a439ecd 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3833,6 +3833,11 @@ route_set_aigp_metric(void *rule, const struct prefix *pfx, void *object)
struct bgp_path_info *path = object;
uint64_t aigp;
+ if (strmatch(aigp_metric, "none")) {
+ bgp_attr_unset_aigp_metric(path->attr);
+ return RMAP_OKAY;
+ }
+
/* 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;
@@ -7919,10 +7924,11 @@ DEFUN_YANG (no_set_atomic_aggregate,
DEFPY_YANG (set_aigp_metric,
set_aigp_metric_cmd,
- "set aigp-metric <igp-metric|(0-4294967295)>$aigp_metric",
+ "set aigp-metric <igp-metric|none|(0-4294967295)>$aigp_metric",
SET_STR
"BGP AIGP attribute (AIGP Metric TLV)\n"
"AIGP Metric value from IGP protocol\n"
+ "Remove the AIGP attribute\n"
"Manual AIGP Metric value (use + for an addition)\n")
{
const char *xpath =
@@ -7939,11 +7945,12 @@ DEFPY_YANG (set_aigp_metric,
DEFPY_YANG (no_set_aigp_metric,
no_set_aigp_metric_cmd,
- "no set aigp-metric [<igp-metric|(0-4294967295)>]",
+ "no set aigp-metric [<igp-metric|none|(0-4294967295)>]",
NO_STR
SET_STR
"BGP AIGP attribute (AIGP Metric TLV)\n"
"AIGP Metric value from IGP protocol\n"
+ "Remove the AIGP attribute\n"
"Manual AIGP Metric value (use + for an addition)\n")
{
const char *xpath =
diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst
index 6a3df0fe40..d258a48589 100644
--- a/doc/user/bgp.rst
+++ b/doc/user/bgp.rst
@@ -2903,10 +2903,11 @@ Capability Negotiation
This command does not add the AIGP attribute to the advertised routes: only
the routes that already carry it are sent with it. A route gets the AIGP
- attribute from :clicmd:`set aigp-metric \<igp-metric|[+](0-4294967295)\>`,
- or from a neighbor with AIGP enabled. When the nexthop is changed to the
- local address, the AIGP metric is increased by the IGP metric to the
- previous nexthop.
+ attribute from
+ :clicmd:`set aigp-metric \<igp-metric|none|[+](0-4294967295)\>`, or from a
+ neighbor with AIGP enabled, and loses it with ``set aigp-metric none``.
+ When the nexthop is changed to the local address, the AIGP metric is
+ increased by the IGP metric to the previous nexthop.
When the previous nexthop is resolved by a static route, the AIGP metric is
increased by the metric of the static route, which is 0 by default, and not
diff --git a/doc/user/routemap.rst b/doc/user/routemap.rst
index 3086cceaf4..70603de4cf 100644
--- a/doc/user/routemap.rst
+++ b/doc/user/routemap.rst
@@ -342,7 +342,7 @@ Route Map Set Command
Set the maximum metric for the route.
-.. clicmd:: set aigp-metric <igp-metric|[+](0-4294967295)>
+.. clicmd:: set aigp-metric <igp-metric|none|[+](0-4294967295)>
Set the BGP attribute AIGP to a specific value. If ``igp-metric`` is specified,
then the value is taken from the IGP protocol, otherwise an arbitrary value.
@@ -356,6 +356,8 @@ Route Map Set Command
link where no IGP is running: for instance, ``set aigp-metric +10`` in the
outbound route-map of an eBGP neighbor provides this increase.
+ If ``none`` is specified, the AIGP attribute is removed from the route.
+
.. clicmd:: set as-path prepend AS_PATH
Set the BGP AS path to prepend.