From 2cd1d00dde83427bd812d7205b59f612a13161c9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 16 Feb 2025 13:00:43 -0500 Subject: [PATCH] bgpd: Convert bgp_keepalive_send to use a connection The peer is going to eventually have a incoming and outgoing connection. Let's send the data based upon the connection not the peer. Signed-off-by: Donald Sharp --- bgpd/bgp_fsm.c | 4 +--- bgpd/bgp_keepalives.c | 2 +- bgpd/bgp_packet.c | 10 +++++----- bgpd/bgp_packet.h | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index b6025ea29f..764b6b8716 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1974,14 +1974,12 @@ bgp_reconnect(struct peer_connection *connection) static enum bgp_fsm_state_progress bgp_fsm_open(struct peer_connection *connection) { - struct peer *peer = connection->peer; - /* If DelayOpen is active, we may still need to send an open message */ if ((connection->status == Connect) || (connection->status == Active)) bgp_open_send(connection); /* Send keepalive and make keepalive timer */ - bgp_keepalive_send(peer); + bgp_keepalive_send(connection); return BGP_FSM_SUCCESS; } diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c index 92123c2cd9..eda563fe60 100644 --- a/bgpd/bgp_keepalives.c +++ b/bgpd/bgp_keepalives.c @@ -108,7 +108,7 @@ static void peer_process(struct hash_bucket *hb, void *arg) zlog_debug("%s [FSM] Timer (keepalive timer expire)", pkat->peer->host); - bgp_keepalive_send(pkat->peer); + bgp_keepalive_send(pkat->peer->connection); monotime(&pkat->last); memset(&elapsed, 0, sizeof(elapsed)); diff = ka; diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 54cd1250cb..ec8cc0465b 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -613,7 +613,7 @@ void bgp_generate_updgrp_packets(struct event *thread) /* * Creates a BGP Keepalive packet and appends it to the peer's output queue. */ -void bgp_keepalive_send(struct peer *peer) +void bgp_keepalive_send(struct peer_connection *connection) { struct stream *s; @@ -628,13 +628,13 @@ void bgp_keepalive_send(struct peer *peer) /* Dump packet if debug option is set. */ /* bgp_packet_dump (s); */ - if (bgp_debug_keepalive(peer)) - zlog_debug("%s sending KEEPALIVE", peer->host); + if (bgp_debug_keepalive(connection->peer)) + zlog_debug("%s sending KEEPALIVE", connection->peer->host); /* Add packet to the peer. */ - bgp_packet_add(peer->connection, peer, s); + bgp_packet_add(connection, connection->peer, s); - bgp_writes_on(peer->connection); + bgp_writes_on(connection); } struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t local_as, diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h index ae81aade70..9ecbdc8b87 100644 --- a/bgpd/bgp_packet.h +++ b/bgpd/bgp_packet.h @@ -48,7 +48,7 @@ DECLARE_HOOK(bgp_packet_send, } while (0) /* Packet send and receive function prototypes. */ -extern void bgp_keepalive_send(struct peer *peer); +extern void bgp_keepalive_send(struct peer_connection *connection); extern struct stream *bgp_open_make(struct peer *peer, uint16_t send_holdtime, as_t local_as, struct in_addr *id); extern void bgp_open_send(struct peer_connection *connection); -- 2.39.5