]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #13564 from chiragshah6/fdev1
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 22 May 2023 06:45:54 +0000 (09:45 +0300)
committerGitHub <noreply@github.com>
Mon, 22 May 2023 06:45:54 +0000 (09:45 +0300)
 bgpd: aggregate route best path select and other fixes

bgpd/bgp_attr.c
bgpd/bgp_route.c

index 195298c81518ba455b712096e12ef865fe87688a..d5223a1e6e4a63b86b9648dc4577b61f5ae38498 100644 (file)
@@ -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;
index 2046f741820423a1f1b6c933934d19383adbca0b..eb51bc1fd672333a5ecb3dbb63205af66645e690 100644 (file)
@@ -7418,7 +7418,7 @@ static bool bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
 
        asnotation = bgp_get_asnotation(NULL);
 
-       if (!ae)
+       if (!aspath)
                ae = aspath_empty(asnotation);
 
        if (!pi)
@@ -7477,8 +7477,8 @@ static void bgp_aggregate_install(
                 * If the aggregate information has not changed
                 * no need to re-install it again.
                 */
-               if (bgp_aggregate_info_same(orig, origin, aspath, community,
-                                           ecommunity, lcommunity)) {
+               if (pi && bgp_aggregate_info_same(pi, origin, aspath, community,
+                                                 ecommunity, lcommunity)) {
                        bgp_dest_unlock_node(dest);
 
                        if (aspath)