summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2023-05-22 08:45:54 +0200
committerGitHub <noreply@github.com>2023-05-22 08:45:54 +0200
commit98378a3546d8d382a2e1c2ab8671788c84ff6c35 (patch)
tree50a02fb63f62be26c2a643a2e903e9a25b8d873b
parentMerge pull request #13563 from donaldsharp/remove_true (diff)
parentbgpd: fix memory leak in aggregate path info (diff)
downloadfrr-98378a3546d8d382a2e1c2ab8671788c84ff6c35.tar.xz
frr-98378a3546d8d382a2e1c2ab8671788c84ff6c35.zip
Merge pull request #13564 from chiragshah6/fdev1
bgpd: aggregate route best path select and other fixes
-rw-r--r--bgpd/bgp_attr.c18
-rw-r--r--bgpd/bgp_route.c6
2 files changed, 18 insertions, 6 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;
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 2046f7418..eb51bc1fd 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -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)