From 4967bf6d729d7dd14dff7b672b2fd4afe78a0d86 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 29 Feb 2024 15:37:53 +0200 Subject: [PATCH] bgpd: Send "Send Hold Timer Expired" on such events notification This is required by the current (latest/-02 draft). IANA has registered code 8 for "Send Hold Timer Expired" in the "BGP Error (Notification) Codes" sub-registry under the "Border Gateway Protocol (BGP) Parameters" registry. https://datatracker.ietf.org/doc/html/draft-ietf-idr-bgp-sendholdtimer Signed-off-by: Donatas Abraitis --- bgpd/bgp_debug.c | 2 ++ bgpd/bgp_fsm.c | 2 +- bgpd/bgp_fsm.h | 3 +++ bgpd/bgp_packet.c | 3 ++- bgpd/bgpd.h | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 3ecdc0d3cf..c1b06a0ae3 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -116,6 +116,7 @@ static const struct message bgp_notify_msg[] = { {BGP_NOTIFY_FSM_ERR, "Neighbor Events Error"}, {BGP_NOTIFY_CEASE, "Cease"}, {BGP_NOTIFY_ROUTE_REFRESH_ERR, "ROUTE-REFRESH Message Error"}, + {BGP_NOTIFY_SEND_HOLD_ERR, "Send Hold Timer Expired"}, {0}}; static const struct message bgp_notify_head_msg[] = { @@ -515,6 +516,7 @@ const char *bgp_notify_subcode_str(char code, char subcode) return lookup_msg(bgp_notify_update_msg, subcode, "Unrecognized Error Subcode"); case BGP_NOTIFY_HOLD_ERR: + case BGP_NOTIFY_SEND_HOLD_ERR: break; case BGP_NOTIFY_FSM_ERR: return lookup_msg(bgp_notify_fsm_msg, subcode, diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 657c7e22d7..a2d3172882 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1589,7 +1589,7 @@ bgp_stop_with_error(struct peer_connection *connection) /* something went wrong, send notify and tear down */ -static enum bgp_fsm_state_progress +enum bgp_fsm_state_progress bgp_stop_with_notify(struct peer_connection *connection, uint8_t code, uint8_t sub_code) { diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index 2e96ac4c10..bcdd49193f 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -122,6 +122,9 @@ extern void bgp_maxmed_update(struct bgp *); extern bool bgp_maxmed_onstartup_configured(struct bgp *); extern bool bgp_maxmed_onstartup_active(struct bgp *); extern int bgp_fsm_error_subcode(int status); +extern enum bgp_fsm_state_progress +bgp_stop_with_notify(struct peer_connection *connection, uint8_t code, + uint8_t sub_code); /** * Start the route advertisement timer (that honors MRAI) for all the diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index da352a8441..55d3efde23 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -148,7 +148,8 @@ static void bgp_packet_add(struct peer_connection *connection, EC_BGP_SENDQ_STUCK_PROPER, "%pBP has not made any SendQ progress for 2 holdtimes (%jds), terminating session", peer, sendholdtime); - BGP_EVENT_ADD(connection, TCP_fatal_error); + bgp_stop_with_notify(connection, + BGP_NOTIFY_SEND_HOLD_ERR, 0); } else if (delta > (intmax_t)holdtime && monotime(NULL) - peer->last_sendq_warn > 5) { flog_warn( diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index cf333e07cc..94bb107253 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1983,6 +1983,7 @@ struct bgp_nlri { #define BGP_NOTIFY_FSM_ERR 5 #define BGP_NOTIFY_CEASE 6 #define BGP_NOTIFY_ROUTE_REFRESH_ERR 7 +#define BGP_NOTIFY_SEND_HOLD_ERR 8 /* Subcodes for BGP Finite State Machine Error */ #define BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC 0