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

BGP TCP non established : get port and ip (backport #15686) #17407

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,22 @@ static enum bgp_fsm_state_progress bgp_connect_fail(struct peer *peer)
return bgp_stop(peer);
}

/* after connect is called(), getpeername is able to return
* port and address on non established streams
*/
static void bgp_connect_in_progress_update_connection(struct peer *peer)
{
bgp_getsockname(peer);
if (!peer->su_remote && !BGP_CONNECTION_SU_UNSPEC(peer->connection)) {
/* if connect initiated, then dest port and dest addresses are well known */
peer->su_remote = sockunion_dup(&peer->connection->su);
if (sockunion_family(peer->su_remote) == AF_INET)
peer->su_remote->sin.sin_port = htons(peer->port);
else if (sockunion_family(peer->su_remote) == AF_INET6)
peer->su_remote->sin6.sin6_port = htons(peer->port);
}
}

/* This function is the first starting point of all BGP connection. It
* try to connect to remote peer with non-blocking IO.
*/
Expand Down Expand Up @@ -1925,6 +1941,8 @@ enum bgp_fsm_state_progress bgp_start(struct peer *peer)
peer->fd);
return BGP_FSM_FAILURE;
}
bgp_connect_in_progress_update_connection(peer);

/*
* - when the socket becomes ready, poll() will signify POLLOUT
* - if it fails to connect, poll() will signify POLLHUP
Expand Down
5 changes: 5 additions & 0 deletions bgpd/bgp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,17 @@ int bgp_getsockname(struct peer *peer)
peer->su_remote = NULL;
}

<<<<<<< HEAD
peer->su_local = sockunion_getsockname(peer->fd);
if (!peer->su_local)
return -1;
peer->su_remote = sockunion_getpeername(peer->fd);
if (!peer->su_remote)
return -1;
=======
peer->su_local = sockunion_getsockname(peer->connection->fd);
peer->su_remote = sockunion_getpeername(peer->connection->fd);
>>>>>>> ba71303099 (bgpd: remove useless control checks about TCP connection)

if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
&peer->nexthop, peer)) {
Expand Down
Loading