Skip to content

Commit

Permalink
bgpd: Modify bgp_udpatesockname to pass in a connection
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Nov 7, 2024
1 parent f30103e commit 30d5d1d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ bgp_connect_fail(struct peer_connection *connection)
*/
static void bgp_connect_in_progress_update_connection(struct peer *peer)
{
bgp_updatesockname(peer);
bgp_updatesockname(peer, peer->connection);
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);
Expand Down
8 changes: 4 additions & 4 deletions bgpd/bgp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ int bgp_connect(struct peer_connection *connection)
htons(peer->port), ifindex);
}

void bgp_updatesockname(struct peer *peer)
void bgp_updatesockname(struct peer *peer, struct peer_connection *connection)
{
if (peer->su_local) {
sockunion_free(peer->su_local);
Expand All @@ -873,14 +873,14 @@ void bgp_updatesockname(struct peer *peer)
peer->su_remote = NULL;
}

peer->su_local = sockunion_getsockname(peer->connection->fd);
peer->su_remote = sockunion_getpeername(peer->connection->fd);
peer->su_local = sockunion_getsockname(connection->fd);
peer->su_remote = sockunion_getpeername(connection->fd);
}

/* After TCP connection is established. Get local address and port. */
int bgp_getsockname(struct peer *peer)
{
bgp_updatesockname(peer);
bgp_updatesockname(peer, peer->connection);

if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
&peer->nexthop, peer)) {
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern void bgp_close_vrf_socket(struct bgp *bgp);
extern void bgp_close(void);
extern int bgp_connect(struct peer_connection *connection);
extern int bgp_getsockname(struct peer *peer);
extern void bgp_updatesockname(struct peer *peer);
extern void bgp_updatesockname(struct peer *peer, struct peer_connection *connection);

extern int bgp_md5_set_prefix(struct bgp *bgp, struct prefix *p,
const char *password);
Expand Down

0 comments on commit 30d5d1d

Please sign in to comment.