Skip to content

Commit

Permalink
[bgpd]: Set GSUT community attr when neighbor GSHUT
Browse files Browse the repository at this point in the history
When bgp neighbor GSHUT is done, advertise routes recivied from this
neighbor with GSHUT attribute.

Ticket: #3948080
Testing:
mlx-4600ca1-01(config-router)# neighbor 210.2.0.2 graceful-shutdown
logs:
2024/06/18 00:11:34 BGP: [MS8ZT-QEXJ8] u2:s4 210.2.0.2 announcing routes
2024/06/18 00:11:35 BGP: [TN0HX-6G1RR] u1:s3 send UPDATE w/ attr: nexthop 0.0.0.0, origin ?, localpref 0, community graceful-shutdown, path 201 200
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 20.10.10.2/32 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.0.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.1.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.2.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.3.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.4.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.5.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.2.6.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 210.3.1.0/24 IPv4 unicast
2024/06/18 00:11:35 BGP: [WEV7K-2GAQ5] u1:s3 send UPDATE len 96 (max message len: 65535) numpfx 9
2024/06/18 00:11:35 BGP: [MBFVT-8GSC6] u1:s3 210.2.0.2 send UPDATE w/ nexthop 210.2.0.1
2024/06/18 00:11:35 BGP: [TN0HX-6G1RR] u1:s3 send UPDATE w/ attr: nexthop 0.0.0.0, localpref 0, metric 0, community graceful-shutdown, path
2024/06/18 00:11:35 BGP: [HVRWP-5R9NQ] u1:s3 send UPDATE 133.133.133.133/32 IPv4 unicast

mlx-4600ca1-01(config-router)#no neighbor 210.2.0.2 graceful-shutdown
logs:
024/06/18 00:12:59 BGP: [MS8ZT-QEXJ8] u2:s6 210.2.0.2 announcing routes
2024/06/18 00:13:00 BGP: [TN0HX-6G1RR] u1:s5 send UPDATE w/ attr: nexthop 0.0.0.0, origin ?, path 201 200
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 20.10.10.2/32 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.0.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.1.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.2.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.3.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.4.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.5.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.2.6.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 210.3.1.0/24 IPv4 unicast
2024/06/18 00:13:00 BGP: [WEV7K-2GAQ5] u1:s5 send UPDATE len 89 (max message len: 65535) numpfx 9
2024/06/18 00:13:00 BGP: [MBFVT-8GSC6] u1:s5 210.2.0.2 send UPDATE w/ nexthop 210.2.0.1
2024/06/18 00:13:00 BGP: [TN0HX-6G1RR] u1:s5 send UPDATE w/ attr: nexthop 0.0.0.0, metric 0, path
2024/06/18 00:13:00 BGP: [HVRWP-5R9NQ] u1:s5 send UPDATE 133.133.133.133/32 IPv4 unicast
2024/06/18 00:13:00 BGP: [WEV7K-2GAQ5] u1:s5 send UPDATE len 56 (max message len: 65535) numpfx 1

default route:
n2# show ip bgp 0.0.0.0/0
BGP routing table entry for 0.0.0.0/0, version 70
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  mlx-4600ca1-01(210.2.0.1) n3(210.3.1.3) n3(2210:210:3:1::3)
  201 100
    210.2.0.1 (mlx-4600ca1-01) from mlx-4600ca1-01(210.2.0.1) (20.0.0.1)
      Origin IGP, metric 0, localpref 0, valid, external, bestpath-from-AS 201, best (First path received)
      Community: graceful-shutdown
      Last update: Wed Jun 26 20:20:29 2024

Signed-off-by: Vijayalaxmi Basavaraj <vbasavaraj@nvidia.com>
  • Loading branch information
vijayalaxmi-basavaraj committed Jun 26, 2024
1 parent b4e4900 commit 2dbdf03
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2499,7 +2499,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
if (aspath_check_as_zero(attr->aspath))
return false;

if (bgp_in_graceful_shutdown(bgp)) {
if ((bgp_in_graceful_shutdown(bgp)) ||
(CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_SHUTDOWN))) {
if (peer->sort == BGP_PEER_IBGP
|| peer->sort == BGP_PEER_CONFED) {
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
Expand Down
6 changes: 6 additions & 0 deletions bgpd/bgp_updgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ static unsigned int updgrp_hash_key_make(const void *p)

#define SEED1 999331
#define SEED2 2147483647
#define SEED3 4258594758

updgrp = p;
peer = updgrp->conf;
Expand Down Expand Up @@ -432,6 +433,11 @@ static unsigned int updgrp_hash_key_make(const void *p)
|| CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT))
key = jhash_1word(jhash(peer->host, strlen(peer->host), SEED2),
key);

if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_SHUTDOWN))
key = jhash_1word(jhash(peer->host, strlen(peer->host), SEED3),
key);

/*
* Multiple sessions with the same neighbor should get their own
* update-group if they have different roles.
Expand Down
4 changes: 3 additions & 1 deletion bgpd/bgp_updgrp_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,9 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
}

/* Advertise the default route */
if (bgp_in_graceful_shutdown(bgp))
if (bgp_in_graceful_shutdown(bgp) ||
(CHECK_FLAG(peer->flags,
PEER_FLAG_GRACEFUL_SHUTDOWN)))
bgp_attr_add_gshut_community(new_attr);

SET_FLAG(subgrp->sflags,
Expand Down
6 changes: 6 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -3590,6 +3590,7 @@ DEFPY (neighbor_graceful_shutdown,
struct peer *peer;
VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct peer_af *paf;

peer = peer_and_group_lookup_vty(vty, neighbor);
if (!peer)
Expand All @@ -3608,6 +3609,11 @@ DEFPY (neighbor_graceful_shutdown,

bgp_clear(vty, bgp, afi, safi, clear_peer, BGP_CLEAR_SOFT_IN,
neighbor);
paf = peer_af_find(peer, afi, safi);
if (paf) {
update_group_adjust_peer(paf);
bgp_announce_route(peer, afi, safi, false);
}
}

return ret;
Expand Down

0 comments on commit 2dbdf03

Please sign in to comment.