Skip to content

Commit

Permalink
Merge pull request #16782 from pguibert6WIND/fix_nexthop_set_failed_m…
Browse files Browse the repository at this point in the history
…essage

bgpd: fix 'nexthop_set failed' error message often displayed
  • Loading branch information
ton31337 authored Sep 19, 2024
2 parents 2302e29 + 37702ca commit b5e266b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
20 changes: 8 additions & 12 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,18 +1799,14 @@ bgp_connect_fail(struct peer_connection *connection)
*/
static void bgp_connect_in_progress_update_connection(struct peer *peer)
{
if (bgp_getsockname(peer) < 0) {
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);
}
bgp_updatesockname(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);
}
}

Expand Down
9 changes: 7 additions & 2 deletions bgpd/bgp_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,7 @@ int bgp_connect(struct peer_connection *connection)
htons(peer->port), ifindex);
}

/* After TCP connection is established. Get local address and port. */
int bgp_getsockname(struct peer *peer)
void bgp_updatesockname(struct peer *peer)
{
if (peer->su_local) {
sockunion_free(peer->su_local);
Expand All @@ -876,6 +875,12 @@ int bgp_getsockname(struct peer *peer)

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

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

if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
&peer->nexthop, peer)) {
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +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 int bgp_md5_set_prefix(struct bgp *bgp, struct prefix *p,
const char *password);
Expand Down

0 comments on commit b5e266b

Please sign in to comment.