Skip to content

Commit d8b898f

Browse files
committed
bgpd: Restoring GR functionality for unplanned BGP restart
Previous changes were breaking GR kicking in on bgpd crash (i.e, on unplanned restart). So restored the behavior. Signed-off-by: Pooja Jagadeesh Doijode <[email protected]>
1 parent 721c393 commit d8b898f

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

bgpd/bgp_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ static void bgp_peer_send_gr_capability(struct stream *s, struct peer *peer,
15981598
rcapp = stream_get_endp(s);
15991599
stream_putc(s, 0);
16001600
restart_time = bgp->restart_time;
1601-
if (bgp_in_graceful_restart()) {
1601+
if (peer->bgp->t_startup || bgp_in_graceful_restart()) {
16021602
SET_FLAG(restart_time, GRACEFUL_RESTART_R_BIT);
16031603
SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV);
16041604
}

bgpd/bgp_packet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ void bgp_capability_send(struct peer *peer, afi_t afi, safi_t safi,
12951295
stream_putc(s, 0);
12961296
gr_restart_time = peer->bgp->restart_time;
12971297

1298-
if (bgp_in_graceful_restart()) {
1298+
if (peer->bgp->t_startup || bgp_in_graceful_restart()) {
12991299
SET_FLAG(gr_restart_time, GRACEFUL_RESTART_R_BIT);
13001300
SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV);
13011301
}

bgpd/bgp_vty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3652,7 +3652,7 @@ DEFUN (bgp_neighbor_graceful_restart_disable_set,
36523652

36533653
ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD);
36543654
if (ret == BGP_GR_SUCCESS) {
3655-
if (bgp_in_graceful_restart())
3655+
if (peer->bgp->t_startup || bgp_in_graceful_restart())
36563656
bgp_peer_gr_flags_update(peer);
36573657

36583658
VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer);

bgpd/bgp_vty.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ struct bgp;
6060

6161
#define VTY_BGP_GR_ROUTER_DETECT(_bgp, _peer, _peer_list) \
6262
do { \
63+
if (_peer->bgp->t_startup) \
64+
bgp_peer_gr_flags_update(_peer); \
6365
for (ALL_LIST_ELEMENTS(_peer_list, node, nnode, peer_loop)) { \
6466
if (CHECK_FLAG(peer_loop->flags, \
6567
PEER_FLAG_GRACEFUL_RESTART)) \
@@ -90,6 +92,8 @@ struct bgp;
9092
struct listnode *node = { 0 }; \
9193
struct listnode *nnode = { 0 }; \
9294
for (ALL_LIST_ELEMENTS(_peer_list, node, nnode, peer_loop)) { \
95+
if (peer_loop->bgp->t_startup) \
96+
bgp_peer_gr_flags_update(peer_loop); \
9397
if (CHECK_FLAG(peer_loop->flags, \
9498
PEER_FLAG_GRACEFUL_RESTART)) \
9599
gr_router_detected = true; \

bgpd/bgpd.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,6 +3389,14 @@ int peer_group_bind(struct bgp *bgp, union sockunion *su, struct peer *peer,
33893389
return 0;
33903390
}
33913391

3392+
static void bgp_startup_timer_expire(struct event *thread)
3393+
{
3394+
struct bgp *bgp;
3395+
3396+
bgp = EVENT_ARG(thread);
3397+
bgp->t_startup = NULL;
3398+
}
3399+
33923400
/*
33933401
* On shutdown we call the cleanup function which
33943402
* does a free of the link list nodes, free up
@@ -3547,6 +3555,9 @@ static struct bgp *bgp_create(as_t *as, const char *name,
35473555
if (name)
35483556
bgp->name = XSTRDUP(MTYPE_BGP_NAME, name);
35493557

3558+
event_add_timer(bm->master, bgp_startup_timer_expire, bgp,
3559+
bgp->restart_time, &bgp->t_startup);
3560+
35503561
/* printable name we can use in debug messages */
35513562
if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
35523563
bgp->name_pretty = XSTRDUP(MTYPE_BGP_NAME, "VRF default");
@@ -3953,6 +3964,7 @@ int bgp_delete(struct bgp *bgp)
39533964
EVENT_OFF(bgp->t_revalidate[afi][safi]);
39543965

39553966
EVENT_OFF(bgp->t_condition_check);
3967+
EVENT_OFF(bgp->t_startup);
39563968
EVENT_OFF(bgp->t_maxmed_onstartup);
39573969
EVENT_OFF(bgp->t_update_delay);
39583970
EVENT_OFF(bgp->t_establish_wait);

bgpd/bgpd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ struct bgp {
447447
struct as_confed *confed_peers;
448448
int confed_peers_cnt;
449449

450+
/* start-up timer on only once at the beginning */
451+
struct event *t_startup;
452+
450453
uint32_t v_maxmed_onstartup; /* Duration of max-med on start-up */
451454
#define BGP_MAXMED_ONSTARTUP_UNCONFIGURED 0 /* 0 means off, its the default */
452455
uint32_t maxmed_onstartup_value; /* Max-med value when active on

0 commit comments

Comments
 (0)