DEFINE_HOOK(peer_backward_transition, (struct peer * peer), (peer));
DEFINE_HOOK(peer_status_changed, (struct peer * peer), (peer));
+enum bgp_fsm_state_progress {
+ BGP_FSM_FAILURE_AND_DELETE = -2,
+ BGP_FSM_FAILURE = -1,
+ BGP_FSM_SUCCESS = 0,
+ BGP_FSM_SUCCESS_STATE_TRANSFER = 1,
+};
+
/* Definition of display strings corresponding to FSM events. This should be
* kept consistent with the events defined in bgpd.h
*/
static void bgp_delayopen_timer(struct thread *);
/* BGP FSM functions. */
-static int bgp_start(struct peer *);
+static enum bgp_fsm_state_progress bgp_start(struct peer *);
/* Register peer with NHT */
int bgp_peer_reg_with_nht(struct peer *peer)
}
/* Flush the event queue and ensure the peer is shut down */
-static int bgp_clearing_completed(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_clearing_completed(struct peer *peer)
{
- int rc = bgp_stop(peer);
+ enum bgp_fsm_state_progress rc = bgp_stop(peer);
- if (rc >= 0)
+ if (rc >= BGP_FSM_SUCCESS)
BGP_EVENT_FLUSH(peer);
return rc;
/* Administrative BGP peer stop event. */
/* May be called multiple times for the same peer */
-int bgp_stop(struct peer *peer)
+enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
{
afi_t afi;
safi_t safi;
char orf_name[BUFSIZ];
- int ret = 0;
+ enum bgp_fsm_state_progress ret = BGP_FSM_SUCCESS;
struct bgp *bgp = peer->bgp;
struct graceful_restart_info *gr_info = NULL;
zlog_debug("%s (dynamic neighbor) deleted (%s)",
peer->host, __func__);
peer_delete(peer);
- return -2;
+ return BGP_FSM_FAILURE_AND_DELETE;
}
/* Can't do this in Clearing; events are used for state transitions */
if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)
&& !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) {
peer_delete(peer);
- ret = -2;
+ ret = BGP_FSM_FAILURE_AND_DELETE;
} else {
bgp_peer_conf_if_to_su_update(peer);
}
}
/* BGP peer is stoped by the error. */
-static int bgp_stop_with_error(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_stop_with_error(struct peer *peer)
{
/* Double start timer. */
peer->v_start *= 2;
zlog_debug("%s (dynamic neighbor) deleted (%s)",
peer->host, __func__);
peer_delete(peer);
- return -1;
+ return BGP_FSM_FAILURE;
}
- return (bgp_stop(peer));
+ return bgp_stop(peer);
}
/* something went wrong, send notify and tear down */
-static int bgp_stop_with_notify(struct peer *peer, uint8_t code,
- uint8_t sub_code)
+static enum bgp_fsm_state_progress
+bgp_stop_with_notify(struct peer *peer, uint8_t code, uint8_t sub_code)
{
/* Send notify to remote peer */
bgp_notify_send(peer, code, sub_code);
zlog_debug("%s (dynamic neighbor) deleted (%s)",
peer->host, __func__);
peer_delete(peer);
- return -1;
+ return BGP_FSM_FAILURE;
}
/* Clear start timer value to default. */
peer->v_start = BGP_INIT_START_TIMER;
- return (bgp_stop(peer));
+ return bgp_stop(peer);
}
/**
/* TCP connection open. Next we send open message to remote peer. And
add read thread for reading open message. */
-static int bgp_connect_success(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_connect_success(struct peer *peer)
{
if (peer->fd < 0) {
flog_err(EC_BGP_CONNECT, "%s peer's fd is negative value %d",
__func__, peer->fd);
- bgp_stop(peer);
- return -1;
+ return bgp_stop(peer);
}
if (bgp_getsockname(peer) < 0) {
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
bgp_fsm_error_subcode(peer->status));
bgp_writes_on(peer);
- return -1;
+ return BGP_FSM_FAILURE;
}
/*
/* Send an open message */
bgp_open_send(peer);
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* TCP connection open with RFC 4271 optional session attribute DelayOpen flag
* set.
*/
-static int bgp_connect_success_w_delayopen(struct peer *peer)
+static enum bgp_fsm_state_progress
+bgp_connect_success_w_delayopen(struct peer *peer)
{
if (peer->fd < 0) {
flog_err(EC_BGP_CONNECT, "%s: peer's fd is negative value %d",
__func__, peer->fd);
- bgp_stop(peer);
- return -1;
+ return bgp_stop(peer);
}
if (bgp_getsockname(peer) < 0) {
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
bgp_fsm_error_subcode(peer->status));
bgp_writes_on(peer);
- return -1;
+ return BGP_FSM_FAILURE;
}
/*
zlog_debug("%s [FSM] BGP OPEN message delayed for %d seconds",
peer->host, peer->delayopen);
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* TCP connect fail */
-static int bgp_connect_fail(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_connect_fail(struct peer *peer)
{
if (peer_dynamic_neighbor_no_nsf(peer)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s (dynamic neighbor) deleted (%s)",
peer->host, __func__);
peer_delete(peer);
- return -1;
+ return BGP_FSM_FAILURE_AND_DELETE;
}
/*
*/
bgp_nht_interface_events(peer);
- return (bgp_stop(peer));
+ return bgp_stop(peer);
}
/* This function is the first starting point of all BGP connection. It
* try to connect to remote peer with non-blocking IO.
*/
-int bgp_start(struct peer *peer)
+enum bgp_fsm_state_progress bgp_start(struct peer *peer)
{
int status;
"%s [FSM] Unable to get neighbor's IP address, waiting...",
peer->host);
peer->last_reset = PEER_DOWN_NBR_ADDR;
- return -1;
+ return BGP_FSM_FAILURE;
}
if (BGP_PEER_START_SUPPRESSED(peer)) {
peer->last_reset = PEER_DOWN_USER_SHUTDOWN;
else if (CHECK_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
peer->last_reset = PEER_DOWN_PFX_COUNT;
- return -1;
+ return BGP_FSM_FAILURE;
}
/* Scrub some information that might be left over from a previous,
/* If the peer is passive mode, force to move to Active mode. */
if (CHECK_FLAG(peer->flags, PEER_FLAG_PASSIVE)) {
BGP_EVENT_ADD(peer, TCP_connection_open_failed);
- return 0;
+ return BGP_FSM_SUCCESS;
}
if (peer->bgp->vrf_id == VRF_UNKNOWN) {
"%s [FSM] In a VRF that is not initialised yet",
peer->host);
peer->last_reset = PEER_DOWN_VRF_UNINIT;
- return -1;
+ return BGP_FSM_FAILURE;
}
/* Register peer for NHT. If next hop is already resolved, proceed
peer->host);
peer->last_reset = PEER_DOWN_WAITING_NHT;
BGP_EVENT_ADD(peer, TCP_connection_open_failed);
- return 0;
+ return BGP_FSM_SUCCESS;
}
}
flog_err(EC_BGP_FSM,
"%s peer's fd is negative value %d", __func__,
peer->fd);
- return -1;
+ return BGP_FSM_FAILURE;
}
/*
* - when the socket becomes ready, poll() will signify POLLOUT
&peer->t_connect_check_w);
break;
}
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* Connect retry timer is expired when the peer status is Connect. */
-static int bgp_reconnect(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_reconnect(struct peer *peer)
{
- if (bgp_stop(peer) < 0)
- return -1;
+ enum bgp_fsm_state_progress ret;
+
+ ret = bgp_stop(peer);
+ if (ret < BGP_FSM_SUCCESS)
+ return ret;
/* Send graceful restart capabilty */
BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(peer->bgp,
peer->bgp->peer);
- bgp_start(peer);
- return 0;
+ return bgp_start(peer);
}
-static int bgp_fsm_open(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_fsm_open(struct peer *peer)
{
/* If DelayOpen is active, we may still need to send an open message */
if ((peer->status == Connect) || (peer->status == Active))
/* Send keepalive and make keepalive timer */
bgp_keepalive_send(peer);
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* FSM error, unexpected event. This is error of BGP connection. So cut the
peer and change to Idle status. */
-static int bgp_fsm_event_error(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_fsm_event_error(struct peer *peer)
{
flog_err(EC_BGP_FSM, "%s [FSM] unexpected packet received in state %s",
peer->host, lookup_msg(bgp_status_msg, peer->status, NULL));
/* Hold timer expire. This is error of BGP connection. So cut the
peer and change to Idle status. */
-static int bgp_fsm_holdtime_expire(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_fsm_holdtime_expire(struct peer *peer)
{
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Hold timer expire", peer->host);
}
/* RFC 4271 DelayOpenTimer_Expires event */
-static int bgp_fsm_delayopen_timer_expire(struct peer *peer)
+static enum bgp_fsm_state_progress
+bgp_fsm_delayopen_timer_expire(struct peer *peer)
{
/* Stop the DelayOpenTimer */
THREAD_OFF(peer->t_delayopen);
/* Set the HoldTimer to a large value (4 minutes) */
peer->v_holdtime = 245;
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* Start the selection deferral timer thread for the specified AFI, SAFI */
* Convert peer from stub to full fledged peer, set some timers, and generate
* initial updates.
*/
-static int bgp_establish(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
{
afi_t afi;
safi_t safi;
int nsf_af_count = 0;
- int ret = 0;
+ enum bgp_fsm_state_progress ret = BGP_FSM_SUCCESS;
struct peer *other;
int status;
peer = peer_xfer_conn(peer);
if (!peer) {
flog_err(EC_BGP_CONNECT, "%%Neighbor failed in xfer_conn");
- return -1;
+ return BGP_FSM_FAILURE;
}
if (other == peer)
- ret = 1; /* bgp_establish specific code when xfer_conn
- happens. */
+ ret = BGP_FSM_SUCCESS_STATE_TRANSFER;
/* Reset capability open status flag. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN))
}
/* Keepalive packet is received. */
-static int bgp_fsm_keepalive(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_fsm_keepalive(struct peer *peer)
{
THREAD_OFF(peer->t_holdtime);
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* Update packet is received. */
-static int bgp_fsm_update(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_fsm_update(struct peer *peer)
{
THREAD_OFF(peer->t_holdtime);
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* This is empty event. */
-static int bgp_ignore(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_ignore(struct peer *peer)
{
flog_err(
EC_BGP_FSM,
lookup_msg(bgp_status_msg, peer->status, NULL),
bgp_event_str[peer->last_event],
bgp_event_str[peer->last_major_event], peer->fd);
- return 0;
+ return BGP_FSM_SUCCESS;
}
/* This is to handle unexpected events.. */
-static int bgp_fsm_exeption(struct peer *peer)
+static enum bgp_fsm_state_progress bgp_fsm_exception(struct peer *peer)
{
flog_err(
EC_BGP_FSM,
lookup_msg(bgp_status_msg, peer->status, NULL),
bgp_event_str[peer->last_event],
bgp_event_str[peer->last_major_event], peer->fd);
- return (bgp_stop(peer));
+ return bgp_stop(peer);
}
void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops)
/* Finite State Machine structure */
static const struct {
- int (*func)(struct peer *);
+ enum bgp_fsm_state_progress (*func)(struct peer *);
enum bgp_fsm_status next_state;
} FSM[BGP_STATUS_MAX - 1][BGP_EVENTS_MAX - 1] = {
{
{bgp_connect_success, OpenSent}, /* TCP_connection_open */
{bgp_connect_success_w_delayopen,
Connect}, /* TCP_connection_open_w_delay */
- {bgp_stop, Idle}, /* TCP_connection_closed */
+ {bgp_stop, Idle}, /* TCP_connection_closed */
{bgp_connect_fail, Active}, /* TCP_connection_open_failed */
{bgp_connect_fail, Idle}, /* TCP_fatal_error */
{bgp_reconnect, Connect}, /* ConnectRetry_timer_expired */
- {bgp_fsm_exeption, Idle}, /* Hold_Timer_expired */
- {bgp_fsm_exeption, Idle}, /* KeepAlive_timer_expired */
+ {bgp_fsm_exception, Idle}, /* Hold_Timer_expired */
+ {bgp_fsm_exception, Idle}, /* KeepAlive_timer_expired */
{bgp_fsm_delayopen_timer_expire,
OpenSent}, /* DelayOpen_timer_expired */
{bgp_fsm_open, OpenConfirm}, /* Receive_OPEN_message */
- {bgp_fsm_exeption, Idle}, /* Receive_KEEPALIVE_message */
- {bgp_fsm_exeption, Idle}, /* Receive_UPDATE_message */
- {bgp_stop, Idle}, /* Receive_NOTIFICATION_message */
- {bgp_fsm_exeption, Idle}, /* Clearing_Completed */
+ {bgp_fsm_exception, Idle}, /* Receive_KEEPALIVE_message */
+ {bgp_fsm_exception, Idle}, /* Receive_UPDATE_message */
+ {bgp_stop, Idle}, /* Receive_NOTIFICATION_message */
+ {bgp_fsm_exception, Idle}, /* Clearing_Completed */
},
{
/* Active, */
{bgp_stop, Idle}, /* BGP_Stop */
{bgp_connect_success, OpenSent}, /* TCP_connection_open */
{bgp_connect_success_w_delayopen,
- Active}, /* TCP_connection_open_w_delay */
- {bgp_stop, Idle}, /* TCP_connection_closed */
- {bgp_ignore, Active}, /* TCP_connection_open_failed */
- {bgp_fsm_exeption, Idle}, /* TCP_fatal_error */
- {bgp_start, Connect}, /* ConnectRetry_timer_expired */
- {bgp_fsm_exeption, Idle}, /* Hold_Timer_expired */
- {bgp_fsm_exeption, Idle}, /* KeepAlive_timer_expired */
+ Active}, /* TCP_connection_open_w_delay */
+ {bgp_stop, Idle}, /* TCP_connection_closed */
+ {bgp_ignore, Active}, /* TCP_connection_open_failed */
+ {bgp_fsm_exception, Idle}, /* TCP_fatal_error */
+ {bgp_start, Connect}, /* ConnectRetry_timer_expired */
+ {bgp_fsm_exception, Idle}, /* Hold_Timer_expired */
+ {bgp_fsm_exception, Idle}, /* KeepAlive_timer_expired */
{bgp_fsm_delayopen_timer_expire,
OpenSent}, /* DelayOpen_timer_expired */
{bgp_fsm_open, OpenConfirm}, /* Receive_OPEN_message */
- {bgp_fsm_exeption, Idle}, /* Receive_KEEPALIVE_message */
- {bgp_fsm_exeption, Idle}, /* Receive_UPDATE_message */
- {bgp_fsm_exeption, Idle}, /* Receive_NOTIFICATION_message */
- {bgp_fsm_exeption, Idle}, /* Clearing_Completed */
+ {bgp_fsm_exception, Idle}, /* Receive_KEEPALIVE_message */
+ {bgp_fsm_exception, Idle}, /* Receive_UPDATE_message */
+ {bgp_fsm_exception, Idle}, /* Receive_NOTIFICATION_message */
+ {bgp_fsm_exception, Idle}, /* Clearing_Completed */
},
{
/* OpenSent, */
- {bgp_ignore, OpenSent}, /* BGP_Start */
- {bgp_stop, Idle}, /* BGP_Stop */
- {bgp_stop, Active}, /* TCP_connection_open */
- {bgp_fsm_exeption, Idle}, /* TCP_connection_open_w_delay */
- {bgp_stop, Active}, /* TCP_connection_closed */
- {bgp_stop, Active}, /* TCP_connection_open_failed */
- {bgp_stop, Active}, /* TCP_fatal_error */
- {bgp_fsm_exeption, Idle}, /* ConnectRetry_timer_expired */
+ {bgp_ignore, OpenSent}, /* BGP_Start */
+ {bgp_stop, Idle}, /* BGP_Stop */
+ {bgp_stop, Active}, /* TCP_connection_open */
+ {bgp_fsm_exception, Idle}, /* TCP_connection_open_w_delay */
+ {bgp_stop, Active}, /* TCP_connection_closed */
+ {bgp_stop, Active}, /* TCP_connection_open_failed */
+ {bgp_stop, Active}, /* TCP_fatal_error */
+ {bgp_fsm_exception, Idle}, /* ConnectRetry_timer_expired */
{bgp_fsm_holdtime_expire, Idle}, /* Hold_Timer_expired */
- {bgp_fsm_exeption, Idle}, /* KeepAlive_timer_expired */
- {bgp_fsm_exeption, Idle}, /* DelayOpen_timer_expired */
+ {bgp_fsm_exception, Idle}, /* KeepAlive_timer_expired */
+ {bgp_fsm_exception, Idle}, /* DelayOpen_timer_expired */
{bgp_fsm_open, OpenConfirm}, /* Receive_OPEN_message */
{bgp_fsm_event_error, Idle}, /* Receive_KEEPALIVE_message */
{bgp_fsm_event_error, Idle}, /* Receive_UPDATE_message */
{bgp_fsm_event_error, Idle}, /* Receive_NOTIFICATION_message */
- {bgp_fsm_exeption, Idle}, /* Clearing_Completed */
+ {bgp_fsm_exception, Idle}, /* Clearing_Completed */
},
{
/* OpenConfirm, */
{bgp_ignore, OpenConfirm}, /* BGP_Start */
- {bgp_stop, Idle}, /* BGP_Stop */
- {bgp_stop, Idle}, /* TCP_connection_open */
- {bgp_fsm_exeption, Idle}, /* TCP_connection_open_w_delay */
- {bgp_stop, Idle}, /* TCP_connection_closed */
- {bgp_stop, Idle}, /* TCP_connection_open_failed */
- {bgp_stop, Idle}, /* TCP_fatal_error */
- {bgp_fsm_exeption, Idle}, /* ConnectRetry_timer_expired */
+ {bgp_stop, Idle}, /* BGP_Stop */
+ {bgp_stop, Idle}, /* TCP_connection_open */
+ {bgp_fsm_exception, Idle}, /* TCP_connection_open_w_delay */
+ {bgp_stop, Idle}, /* TCP_connection_closed */
+ {bgp_stop, Idle}, /* TCP_connection_open_failed */
+ {bgp_stop, Idle}, /* TCP_fatal_error */
+ {bgp_fsm_exception, Idle}, /* ConnectRetry_timer_expired */
{bgp_fsm_holdtime_expire, Idle}, /* Hold_Timer_expired */
{bgp_ignore, OpenConfirm}, /* KeepAlive_timer_expired */
- {bgp_fsm_exeption, Idle}, /* DelayOpen_timer_expired */
- {bgp_fsm_exeption, Idle}, /* Receive_OPEN_message */
+ {bgp_fsm_exception, Idle}, /* DelayOpen_timer_expired */
+ {bgp_fsm_exception, Idle}, /* Receive_OPEN_message */
{bgp_establish, Established}, /* Receive_KEEPALIVE_message */
- {bgp_fsm_exeption, Idle}, /* Receive_UPDATE_message */
+ {bgp_fsm_exception, Idle}, /* Receive_UPDATE_message */
{bgp_stop_with_error, Idle}, /* Receive_NOTIFICATION_message */
- {bgp_fsm_exeption, Idle}, /* Clearing_Completed */
+ {bgp_fsm_exception, Idle}, /* Clearing_Completed */
},
{
/* Established, */
{bgp_ignore, Established}, /* BGP_Start */
- {bgp_stop, Clearing}, /* BGP_Stop */
- {bgp_stop, Clearing}, /* TCP_connection_open */
- {bgp_fsm_exeption, Idle}, /* TCP_connection_open_w_delay */
- {bgp_stop, Clearing}, /* TCP_connection_closed */
- {bgp_stop, Clearing}, /* TCP_connection_open_failed */
- {bgp_stop, Clearing}, /* TCP_fatal_error */
- {bgp_stop, Clearing}, /* ConnectRetry_timer_expired */
+ {bgp_stop, Clearing}, /* BGP_Stop */
+ {bgp_stop, Clearing}, /* TCP_connection_open */
+ {bgp_fsm_exception, Idle}, /* TCP_connection_open_w_delay */
+ {bgp_stop, Clearing}, /* TCP_connection_closed */
+ {bgp_stop, Clearing}, /* TCP_connection_open_failed */
+ {bgp_stop, Clearing}, /* TCP_fatal_error */
+ {bgp_stop, Clearing}, /* ConnectRetry_timer_expired */
{bgp_fsm_holdtime_expire, Clearing}, /* Hold_Timer_expired */
{bgp_ignore, Established}, /* KeepAlive_timer_expired */
- {bgp_fsm_exeption, Idle}, /* DelayOpen_timer_expired */
- {bgp_stop, Clearing}, /* Receive_OPEN_message */
+ {bgp_fsm_exception, Idle}, /* DelayOpen_timer_expired */
+ {bgp_stop, Clearing}, /* Receive_OPEN_message */
{bgp_fsm_keepalive,
Established}, /* Receive_KEEPALIVE_message */
{bgp_fsm_update, Established}, /* Receive_UPDATE_message */
{bgp_stop_with_error,
- Clearing}, /* Receive_NOTIFICATION_message */
- {bgp_fsm_exeption, Idle}, /* Clearing_Completed */
+ Clearing}, /* Receive_NOTIFICATION_message */
+ {bgp_fsm_exception, Idle}, /* Clearing_Completed */
},
{
/* Clearing, */
{bgp_ignore, Clearing}, /* BGP_Start */
- {bgp_stop, Clearing}, /* BGP_Stop */
- {bgp_stop, Clearing}, /* TCP_connection_open */
- {bgp_stop, Clearing}, /* TCP_connection_open_w_delay */
- {bgp_stop, Clearing}, /* TCP_connection_closed */
- {bgp_stop, Clearing}, /* TCP_connection_open_failed */
- {bgp_stop, Clearing}, /* TCP_fatal_error */
- {bgp_stop, Clearing}, /* ConnectRetry_timer_expired */
- {bgp_stop, Clearing}, /* Hold_Timer_expired */
- {bgp_stop, Clearing}, /* KeepAlive_timer_expired */
- {bgp_stop, Clearing}, /* DelayOpen_timer_expired */
- {bgp_stop, Clearing}, /* Receive_OPEN_message */
- {bgp_stop, Clearing}, /* Receive_KEEPALIVE_message */
- {bgp_stop, Clearing}, /* Receive_UPDATE_message */
- {bgp_stop, Clearing}, /* Receive_NOTIFICATION_message */
+ {bgp_stop, Clearing}, /* BGP_Stop */
+ {bgp_stop, Clearing}, /* TCP_connection_open */
+ {bgp_stop, Clearing}, /* TCP_connection_open_w_delay */
+ {bgp_stop, Clearing}, /* TCP_connection_closed */
+ {bgp_stop, Clearing}, /* TCP_connection_open_failed */
+ {bgp_stop, Clearing}, /* TCP_fatal_error */
+ {bgp_stop, Clearing}, /* ConnectRetry_timer_expired */
+ {bgp_stop, Clearing}, /* Hold_Timer_expired */
+ {bgp_stop, Clearing}, /* KeepAlive_timer_expired */
+ {bgp_stop, Clearing}, /* DelayOpen_timer_expired */
+ {bgp_stop, Clearing}, /* Receive_OPEN_message */
+ {bgp_stop, Clearing}, /* Receive_KEEPALIVE_message */
+ {bgp_stop, Clearing}, /* Receive_UPDATE_message */
+ {bgp_stop, Clearing}, /* Receive_NOTIFICATION_message */
{bgp_clearing_completed, Idle}, /* Clearing_Completed */
},
{
int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)
{
enum bgp_fsm_status next;
- int ret = 0;
+ enum bgp_fsm_state_progress ret = 0;
struct peer *other;
int passive_conn = 0;
int dyn_nbr;
if (FSM[peer->status - 1][event - 1].func)
ret = (*(FSM[peer->status - 1][event - 1].func))(peer);
- if (ret >= 0) {
- if (ret == 1 && next == Established) {
+ if (ret >= BGP_FSM_SUCCESS) {
+ if (ret == BGP_FSM_SUCCESS_STATE_TRANSFER &&
+ next == Established) {
/* The case when doppelganger swap accurred in
bgp_establish.
Update the peer pointer accordingly */
* we need to indicate that the peer was stopped in the return
* code.
*/
- if (!dyn_nbr && !passive_conn && peer->bgp && ret != -2) {
+ if (!dyn_nbr && !passive_conn && peer->bgp &&
+ ret != BGP_FSM_FAILURE_AND_DELETE) {
flog_err(
EC_BGP_FSM,
"%s [FSM] Failure handling event %s in state %s, prior events %s, %s, fd %d",