summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorChirag Shah <chirag@nvidia.com>2023-05-19 07:43:08 +0200
committerChirag Shah <chirag@nvidia.com>2023-05-19 23:45:49 +0200
commitff8bebd2a659551ff33a7ee44f3d329001feb022 (patch)
tree03445616e2d395ffbdec8dd5a6feb544b265958b /bgpd
parentbgpd: fix aggregate route best path select (diff)
downloadfrr-ff8bebd2a659551ff33a7ee44f3d329001feb022.tar.xz
frr-ff8bebd2a659551ff33a7ee44f3d329001feb022.zip
bgpd: fix aggregate route display
Based on RFC-4760, if NEXT_HOP attribute is not suppose to be set if MP_REACH_NLRI NLRI is used. for IPv4 aggregate route only NEXT_HOP attribute with ipv4 prefixlen needs to be set. Testing Done: Before fix: ---------- aggregate route: *> 184.123.0.0/16 ::(TORC11) 0 32768 i After fix: --------- aggregate route: *> 184.123.0.0/16 0.0.0.0(TORC11) 0 32768 i * i peerlink-3 0 100 0 i * uplink1 0 4435 5546 i 184.123.1.0/24 0.0.0.0(TORC11) 0 32768 i s> 184.123.8.0/22 0.0.0.0(TORC11) 0 32768 i Signed-off-by: Chirag Shah <chirag@nvidia.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_attr.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 195298c81..d5223a1e6 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1082,9 +1082,6 @@ struct attr *bgp_attr_aggregate_intern(
attr.aspath = aspath_empty(bgp->asnotation);
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_AS_PATH);
- /* Next hop attribute. */
- attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
-
if (community) {
uint32_t gshut = COMMUNITY_GSHUT;
@@ -1121,6 +1118,21 @@ struct attr *bgp_attr_aggregate_intern(
attr.aggregator_as = bgp->as;
attr.aggregator_addr = bgp->router_id;
+ /* Aggregate are done for IPv4/IPv6 so checking ipv4 family,
+ * This should only be set for IPv4 AFI type
+ * based on RFC-4760:
+ * "An UPDATE message that carries no NLRI,
+ * other than the one encoded in
+ * the MP_REACH_NLRI attribute,
+ * SHOULD NOT carry the NEXT_HOP
+ * attribute"
+ */
+ if (p->family == AF_INET) {
+ /* Next hop attribute. */
+ attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
+ attr.mp_nexthop_len = IPV4_MAX_BYTELEN;
+ }
+
/* Apply route-map */
if (aggregate->rmap.name) {
struct attr attr_tmp = attr;