bgpd: bgp_connect should return an enum connect_result

This function when it is run by bgp_start is expected
to return a `enum connect_result`.  But instead
the function returns a variety of values that are
not really being checked for.  Consolidate to a correct
choice.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-11-20 09:18:39 -05:00
parent bca99119d9
commit 2a94de8af2
3 changed files with 7 additions and 7 deletions

View File

@ -1826,7 +1826,7 @@ static void bgp_connect_in_progress_update_connection(struct peer *peer)
static enum bgp_fsm_state_progress bgp_start(struct peer_connection *connection)
{
struct peer *peer = connection->peer;
int status;
enum connect_result status;
bgp_peer_conf_if_to_su_update(connection);

View File

@ -762,7 +762,7 @@ static int bgp_update_source(struct peer_connection *connection)
}
/* BGP try to connect to the peer. */
int bgp_connect(struct peer_connection *connection)
enum connect_result bgp_connect(struct peer_connection *connection)
{
struct peer *peer = connection->peer;
@ -773,7 +773,7 @@ int bgp_connect(struct peer_connection *connection)
if (peer->conf_if && BGP_CONNECTION_SU_UNSPEC(connection)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug("Peer address not learnt: Returning from connect");
return 0;
return connect_error;
}
frr_with_privs(&bgpd_privs) {
/* Make socket for the peer. */
@ -787,7 +787,7 @@ int bgp_connect(struct peer_connection *connection)
zlog_debug("%s: Failure to create socket for connection to %s, error received: %s(%d)",
__func__, peer->host, safe_strerror(errno),
errno);
return -1;
return connect_error;
}
set_nonblocking(connection->fd);
@ -808,7 +808,7 @@ int bgp_connect(struct peer_connection *connection)
__func__, peer->host, safe_strerror(errno),
errno);
return -1;
return connect_error;
}
sockopt_reuseaddr(connection->fd);
@ -844,7 +844,7 @@ int bgp_connect(struct peer_connection *connection)
/* If the peer is passive mode, force to move to Active mode. */
if (CHECK_FLAG(peer->flags, PEER_FLAG_PASSIVE)) {
BGP_EVENT_ADD(connection, TCP_connection_open_failed);
return BGP_FSM_SUCCESS;
return connect_error;
}
if (peer->conf_if || peer->ifname)

View File

@ -21,7 +21,7 @@ extern int bgp_socket(struct bgp *bgp, unsigned short port,
const char *address);
extern void bgp_close_vrf_socket(struct bgp *bgp);
extern void bgp_close(void);
extern int bgp_connect(struct peer_connection *connection);
extern enum connect_result bgp_connect(struct peer_connection *connection);
extern int bgp_getsockname(struct peer *peer);
extern void bgp_updatesockname(struct peer *peer);