Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More connection cleanup #18195

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
bgpd: Call dyanmic peer incoming connection incoming
The bgp_accept code calls the different connections
connection and connection1.  Frankly this is confusing
and hard to keep track of what we are talking about
since they are poorly named.  Let's start naming
these variables things that make logical sense.

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 <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Feb 18, 2025
commit d8d0b244f56d143c821669556afdcd8975b7e6bb
29 changes: 14 additions & 15 deletions bgpd/bgp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,17 @@ static void bgp_accept(struct event *thread)
if (!peer1) {
peer1 = peer_lookup_dynamic_neighbor(bgp, &su);
if (peer1) {
connection1 = peer1->connection;
struct peer_connection *incoming;

incoming = peer1->connection;
/* Dynamic neighbor has been created, let it proceed */
connection1->fd = bgp_sock;
connection1->dir = CONNECTION_INCOMING;
incoming->fd = bgp_sock;
incoming->dir = CONNECTION_INCOMING;

connection1->su_local = sockunion_getsockname(connection1->fd);
connection1->su_remote = sockunion_dup(&su);
incoming->su_local = sockunion_getsockname(incoming->fd);
incoming->su_remote = sockunion_dup(&su);

if (bgp_set_socket_ttl(connection1) < 0) {
if (bgp_set_socket_ttl(incoming) < 0) {
peer1->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,
Expand All @@ -501,21 +503,18 @@ static void bgp_accept(struct event *thread)
sockopt_tcp_mss_set(bgp_sock, peer1->tcp_mss);

frr_with_privs (&bgpd_privs) {
vrf_bind(peer1->bgp->vrf_id, bgp_sock,
bgp_get_bound_name(connection1));
vrf_bind(peer1->bgp->vrf_id, bgp_sock, bgp_get_bound_name(incoming));
}
bgp_peer_reg_with_nht(peer1);
bgp_fsm_change_status(connection1, Active);
EVENT_OFF(connection1->t_start);
bgp_fsm_change_status(incoming, Active);
EVENT_OFF(incoming->t_start);

if (peer_active(peer1->connection)) {
if (peer_active(incoming)) {
if (CHECK_FLAG(peer1->flags,
PEER_FLAG_TIMER_DELAYOPEN))
BGP_EVENT_ADD(connection1,
TCP_connection_open_w_delay);
BGP_EVENT_ADD(incoming, TCP_connection_open_w_delay);
else
BGP_EVENT_ADD(connection1,
TCP_connection_open);
BGP_EVENT_ADD(incoming, TCP_connection_open);
}

return;
Expand Down