bgpd: move t_gr_restart and _stale into peer_connection

The t_gr_restart and t_gr_stale event pointers belong
into the peer_connection pointer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-08-26 21:16:29 -04:00
parent e79443fcd8
commit 13ae845b94
5 changed files with 54 additions and 46 deletions

View File

@ -472,8 +472,8 @@ void bgp_timer_set(struct peer *peer)
} }
break; break;
case Deleted: case Deleted:
EVENT_OFF(peer->t_gr_restart); EVENT_OFF(peer->connection->t_gr_restart);
EVENT_OFF(peer->t_gr_stale); EVENT_OFF(peer->connection->t_gr_stale);
FOREACH_AFI_SAFI (afi, safi) FOREACH_AFI_SAFI (afi, safi)
EVENT_OFF(peer->t_llgr_stale[afi][safi]); EVENT_OFF(peer->t_llgr_stale[afi][safi]);
@ -651,7 +651,7 @@ static void bgp_graceful_restart_timer_off(struct peer *peer)
return; return;
UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT); UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT);
EVENT_OFF(peer->t_gr_stale); EVENT_OFF(peer->connection->t_gr_stale);
if (peer_dynamic_neighbor(peer) && if (peer_dynamic_neighbor(peer) &&
!(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) { !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) {
@ -1418,8 +1418,8 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection)
} }
/* graceful restart */ /* graceful restart */
if (peer->t_gr_stale) { if (connection->t_gr_stale) {
EVENT_OFF(peer->t_gr_stale); EVENT_OFF(connection->t_gr_stale);
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug( zlog_debug(
"%pBP graceful restart stalepath timer stopped", "%pBP graceful restart stalepath timer stopped",
@ -1434,10 +1434,10 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection)
"%pBP graceful restart stalepath timer started for %d sec", "%pBP graceful restart stalepath timer started for %d sec",
peer, peer->bgp->stalepath_time); peer, peer->bgp->stalepath_time);
} }
BGP_TIMER_ON(peer->t_gr_restart, BGP_TIMER_ON(connection->t_gr_restart,
bgp_graceful_restart_timer_expire, bgp_graceful_restart_timer_expire,
peer->v_gr_restart); peer->v_gr_restart);
BGP_TIMER_ON(peer->t_gr_stale, BGP_TIMER_ON(connection->t_gr_stale,
bgp_graceful_stale_timer_expire, bgp_graceful_stale_timer_expire,
peer->bgp->stalepath_time); peer->bgp->stalepath_time);
} else { } else {
@ -2271,8 +2271,8 @@ bgp_establish(struct peer_connection *connection)
SET_FLAG(peer->sflags, PEER_STATUS_NSF_MODE); SET_FLAG(peer->sflags, PEER_STATUS_NSF_MODE);
else { else {
UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_MODE); UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_MODE);
if (peer->t_gr_stale) { if (connection->t_gr_stale) {
EVENT_OFF(peer->t_gr_stale); EVENT_OFF(connection->t_gr_stale);
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug( zlog_debug(
"%pBP graceful restart stalepath timer stopped", "%pBP graceful restart stalepath timer stopped",
@ -2280,8 +2280,8 @@ bgp_establish(struct peer_connection *connection)
} }
} }
if (peer->t_gr_restart) { if (connection->t_gr_restart) {
EVENT_OFF(peer->t_gr_restart); EVENT_OFF(connection->t_gr_restart);
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug("%pBP graceful restart timer stopped", peer); zlog_debug("%pBP graceful restart timer stopped", peer);
} }

View File

@ -10982,10 +10982,10 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
str, label2vni(&attr->label)); str, label2vni(&attr->label));
} }
if (path->peer->t_gr_restart && if (path->peer->connection->t_gr_restart &&
CHECK_FLAG(path->flags, BGP_PATH_STALE)) { CHECK_FLAG(path->flags, BGP_PATH_STALE)) {
unsigned long gr_remaining = unsigned long gr_remaining = event_timer_remain_second(
event_timer_remain_second(path->peer->t_gr_restart); path->peer->connection->t_gr_restart);
if (json_paths) { if (json_paths) {
json_object_int_add(json_path, json_object_int_add(json_path,

View File

@ -12623,11 +12623,12 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
json_object_int_add(json_timer, "stalePathTimer", json_object_int_add(json_timer, "stalePathTimer",
peer->bgp->stalepath_time); peer->bgp->stalepath_time);
if (peer->t_gr_stale != NULL) { if (peer->connection->t_gr_stale != NULL) {
json_object_int_add(json_timer, json_object_int_add(json_timer,
"stalePathTimerRemaining", "stalePathTimerRemaining",
event_timer_remain_second( event_timer_remain_second(
peer->t_gr_stale)); peer->connection
->t_gr_stale));
} }
/* Display Configured Selection /* Display Configured Selection
@ -12657,11 +12658,11 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
" Configured Stale Path Time(sec): %u\n", " Configured Stale Path Time(sec): %u\n",
peer->bgp->stalepath_time); peer->bgp->stalepath_time);
if (peer->t_gr_stale != NULL) if (peer->connection->t_gr_stale != NULL)
vty_out(vty, vty_out(vty,
" Stale Path Remaining(sec): %ld\n", " Stale Path Remaining(sec): %ld\n",
event_timer_remain_second( event_timer_remain_second(
peer->t_gr_stale)); peer->connection->t_gr_stale));
/* Display Configured Selection /* Display Configured Selection
* Deferral only when when * Deferral only when when
* Gr mode is enabled. * Gr mode is enabled.
@ -12706,10 +12707,10 @@ static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,
json_object_int_add(json_timer, "receivedRestartTimer", json_object_int_add(json_timer, "receivedRestartTimer",
p->v_gr_restart); p->v_gr_restart);
if (p->t_gr_restart != NULL) if (p->connection->t_gr_restart != NULL)
json_object_int_add( json_object_int_add(json_timer, "restartTimerRemaining",
json_timer, "restartTimerRemaining", event_timer_remain_second(
event_timer_remain_second(p->t_gr_restart)); p->connection->t_gr_restart));
json_object_object_add(json, "timers", json_timer); json_object_object_add(json, "timers", json_timer);
} else { } else {
@ -12720,12 +12721,14 @@ static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,
vty_out(vty, " Received Restart Time(sec): %u\n", vty_out(vty, " Received Restart Time(sec): %u\n",
p->v_gr_restart); p->v_gr_restart);
if (p->t_gr_restart != NULL) if (p->connection->t_gr_restart != NULL)
vty_out(vty, " Restart Time Remaining(sec): %ld\n", vty_out(vty, " Restart Time Remaining(sec): %ld\n",
event_timer_remain_second(p->t_gr_restart)); event_timer_remain_second(
if (p->t_gr_restart != NULL) { p->connection->t_gr_restart));
if (p->connection->t_gr_restart != NULL) {
vty_out(vty, " Restart Time Remaining(sec): %ld\n", vty_out(vty, " Restart Time Remaining(sec): %ld\n",
event_timer_remain_second(p->t_gr_restart)); event_timer_remain_second(
p->connection->t_gr_restart));
} }
} }
} }
@ -14682,16 +14685,18 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
json_grace_recv); json_grace_recv);
if (p->t_gr_restart) if (p->connection->t_gr_restart)
json_object_int_add( json_object_int_add(json_grace,
json_grace, "gracefulRestartTimerMsecs", "gracefulRestartTimerMsecs",
event_timer_remain_second(p->t_gr_restart) * event_timer_remain_second(
p->connection->t_gr_restart) *
1000); 1000);
if (p->t_gr_stale) if (p->connection->t_gr_stale)
json_object_int_add( json_object_int_add(json_grace,
json_grace, "gracefulStalepathTimerMsecs", "gracefulStalepathTimerMsecs",
event_timer_remain_second(p->t_gr_stale) * event_timer_remain_second(
p->connection->t_gr_stale) *
1000); 1000);
/* more gr info in new format */ /* more gr info in new format */
BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace); BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace);
@ -14729,15 +14734,17 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
vty_out(vty, "\n"); vty_out(vty, "\n");
} }
if (p->t_gr_restart) if (p->connection->t_gr_restart)
vty_out(vty, vty_out(vty,
" The remaining time of restart timer is %ld\n", " The remaining time of restart timer is %ld\n",
event_timer_remain_second(p->t_gr_restart)); event_timer_remain_second(
p->connection->t_gr_restart));
if (p->t_gr_stale) if (p->connection->t_gr_stale)
vty_out(vty, vty_out(vty,
" The remaining time of stalepath timer is %ld\n", " The remaining time of stalepath timer is %ld\n",
event_timer_remain_second(p->t_gr_stale)); event_timer_remain_second(
p->connection->t_gr_stale));
/* more gr info in new format */ /* more gr info in new format */
BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL); BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL);

View File

@ -2542,13 +2542,13 @@ void peer_nsf_stop(struct peer *peer)
EVENT_OFF(peer->t_llgr_stale[afi][safi]); EVENT_OFF(peer->t_llgr_stale[afi][safi]);
} }
if (peer->t_gr_restart) { if (peer->connection->t_gr_restart) {
EVENT_OFF(peer->t_gr_restart); EVENT_OFF(peer->connection->t_gr_restart);
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug("%pBP graceful restart timer stopped", peer); zlog_debug("%pBP graceful restart timer stopped", peer);
} }
if (peer->t_gr_stale) { if (peer->connection->t_gr_stale) {
EVENT_OFF(peer->t_gr_stale); EVENT_OFF(peer->connection->t_gr_stale);
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug( zlog_debug(
"%pBP graceful restart stalepath timer stopped", "%pBP graceful restart stalepath timer stopped",

View File

@ -1146,6 +1146,9 @@ struct peer_connection {
struct event *t_connect_check_r; struct event *t_connect_check_r;
struct event *t_connect_check_w; struct event *t_connect_check_w;
struct event *t_gr_restart;
struct event *t_gr_stale;
struct event *t_routeadv; struct event *t_routeadv;
struct event *t_process_packet; struct event *t_process_packet;
struct event *t_process_packet_error; struct event *t_process_packet_error;
@ -1557,8 +1560,6 @@ struct peer {
/* Threads. */ /* Threads. */
struct event *t_pmax_restart; struct event *t_pmax_restart;
struct event *t_gr_restart;
struct event *t_gr_stale;
struct event *t_llgr_stale[AFI_MAX][SAFI_MAX]; struct event *t_llgr_stale[AFI_MAX][SAFI_MAX];
struct event *t_revalidate_all[AFI_MAX][SAFI_MAX]; struct event *t_revalidate_all[AFI_MAX][SAFI_MAX];
struct event *t_generate_updgrp_packets; struct event *t_generate_updgrp_packets;