From b4e13db0699915aca1ee6b1ba7fe7a53dccca378 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 15 Feb 2025 19:43:36 -0500 Subject: [PATCH] bgpd: Call newly created dynamic_peer appropriately The dynamic peer being created is being called peer1 let's call it dynamic_peer instead. This will make what is being done clearer for future developers. Author's Note: I am changing the bgp_accept function in this manner because I find it incredibly confusing remembering what is what direction and all my other attempts at getting this straight has caused real problems. So I am resorting to doing really small transformational changes at a time. Signed-off-by: Donald Sharp --- bgpd/bgp_network.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index f457c44db6..1b663f542f 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -478,9 +478,10 @@ static void bgp_accept(struct event *thread) peer1 = peer_lookup(bgp, &su); if (!peer1) { - peer1 = peer_lookup_dynamic_neighbor(bgp, &su); - if (peer1) { - incoming = peer1->connection; + struct peer *dynamic_peer = peer_lookup_dynamic_neighbor(bgp, &su); + + if (dynamic_peer) { + incoming = dynamic_peer->connection; /* Dynamic neighbor has been created, let it proceed */ incoming->fd = bgp_sock; incoming->dir = CONNECTION_INCOMING; @@ -489,27 +490,26 @@ static void bgp_accept(struct event *thread) incoming->su_remote = sockunion_dup(&su); if (bgp_set_socket_ttl(incoming) < 0) { - peer1->last_reset = PEER_DOWN_SOCKET_ERROR; + dynamic_peer->last_reset = PEER_DOWN_SOCKET_ERROR; zlog_err("%s: Unable to set min/max TTL on peer %s (dynamic), error received: %s(%d)", - __func__, peer1->host, - safe_strerror(errno), errno); + __func__, dynamic_peer->host, safe_strerror(errno), errno); return; } /* Set the user configured MSS to TCP socket */ - if (CHECK_FLAG(peer1->flags, PEER_FLAG_TCP_MSS)) - sockopt_tcp_mss_set(bgp_sock, peer1->tcp_mss); + if (CHECK_FLAG(dynamic_peer->flags, PEER_FLAG_TCP_MSS)) + sockopt_tcp_mss_set(bgp_sock, dynamic_peer->tcp_mss); frr_with_privs (&bgpd_privs) { - vrf_bind(peer1->bgp->vrf_id, bgp_sock, bgp_get_bound_name(incoming)); + vrf_bind(dynamic_peer->bgp->vrf_id, bgp_sock, + bgp_get_bound_name(incoming)); } - bgp_peer_reg_with_nht(peer1); + bgp_peer_reg_with_nht(dynamic_peer); bgp_fsm_change_status(incoming, Active); EVENT_OFF(incoming->t_start); if (peer_active(incoming)) { - if (CHECK_FLAG(peer1->flags, - PEER_FLAG_TIMER_DELAYOPEN)) + if (CHECK_FLAG(dynamic_peer->flags, PEER_FLAG_TIMER_DELAYOPEN)) BGP_EVENT_ADD(incoming, TCP_connection_open_w_delay); else BGP_EVENT_ADD(incoming, TCP_connection_open); -- 2.39.5