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>
This commit is contained in:
Chirag Shah 2023-05-18 22:43:08 -07:00
parent cd845be6a7
commit ff8bebd2a6

View 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;