summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_fsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_fsm.c')
-rw-r--r--bgpd/bgp_fsm.c198
1 files changed, 99 insertions, 99 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 9e9861310..9118be3a7 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -169,17 +169,17 @@ static struct peer *peer_xfer_conn(struct peer *from_peer)
*/
bgp_keepalives_off(from_peer);
- THREAD_OFF(peer->t_routeadv);
- THREAD_OFF(peer->t_connect);
- THREAD_OFF(peer->t_delayopen);
- THREAD_OFF(peer->t_connect_check_r);
- THREAD_OFF(peer->t_connect_check_w);
- THREAD_OFF(from_peer->t_routeadv);
- THREAD_OFF(from_peer->t_connect);
- THREAD_OFF(from_peer->t_delayopen);
- THREAD_OFF(from_peer->t_connect_check_r);
- THREAD_OFF(from_peer->t_connect_check_w);
- THREAD_OFF(from_peer->t_process_packet);
+ EVENT_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_connect_check_r);
+ EVENT_OFF(peer->t_connect_check_w);
+ EVENT_OFF(from_peer->t_routeadv);
+ EVENT_OFF(from_peer->t_connect);
+ EVENT_OFF(from_peer->t_delayopen);
+ EVENT_OFF(from_peer->t_connect_check_r);
+ EVENT_OFF(from_peer->t_connect_check_w);
+ EVENT_OFF(from_peer->t_process_packet);
/*
* At this point in time, it is possible that there are packets pending
@@ -364,23 +364,23 @@ void bgp_timer_set(struct peer *peer)
inactive. All other timer must be turned off */
if (BGP_PEER_START_SUPPRESSED(peer) || !peer_active(peer)
|| peer->bgp->vrf_id == VRF_UNKNOWN) {
- THREAD_OFF(peer->t_start);
+ EVENT_OFF(peer->t_start);
} else {
BGP_TIMER_ON(peer->t_start, bgp_start_timer,
peer->v_start);
}
- THREAD_OFF(peer->t_connect);
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_holdtime);
bgp_keepalives_off(peer);
- THREAD_OFF(peer->t_routeadv);
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_delayopen);
break;
case Connect:
/* After start timer is expired, the peer moves to Connect
status. Make sure start timer is off and connect timer is
on. */
- THREAD_OFF(peer->t_start);
+ EVENT_OFF(peer->t_start);
if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER_DELAYOPEN))
BGP_TIMER_ON(peer->t_connect, bgp_connect_timer,
(peer->v_delayopen + peer->v_connect));
@@ -388,19 +388,19 @@ void bgp_timer_set(struct peer *peer)
BGP_TIMER_ON(peer->t_connect, bgp_connect_timer,
peer->v_connect);
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
bgp_keepalives_off(peer);
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
break;
case Active:
/* Active is waiting connection from remote peer. And if
connect timer is expired, change status to Connect. */
- THREAD_OFF(peer->t_start);
+ EVENT_OFF(peer->t_start);
/* If peer is passive mode, do not set connect timer. */
if (CHECK_FLAG(peer->flags, PEER_FLAG_PASSIVE)
|| CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT)) {
- THREAD_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_connect);
} else {
if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER_DELAYOPEN))
BGP_TIMER_ON(
@@ -410,30 +410,30 @@ void bgp_timer_set(struct peer *peer)
BGP_TIMER_ON(peer->t_connect, bgp_connect_timer,
peer->v_connect);
}
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
bgp_keepalives_off(peer);
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
break;
case OpenSent:
/* OpenSent status. */
- THREAD_OFF(peer->t_start);
- THREAD_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_start);
+ EVENT_OFF(peer->t_connect);
if (peer->v_holdtime != 0) {
BGP_TIMER_ON(peer->t_holdtime, bgp_holdtime_timer,
peer->v_holdtime);
} else {
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
}
bgp_keepalives_off(peer);
- THREAD_OFF(peer->t_routeadv);
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_delayopen);
break;
case OpenConfirm:
/* OpenConfirm status. */
- THREAD_OFF(peer->t_start);
- THREAD_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_start);
+ EVENT_OFF(peer->t_connect);
/*
* If the negotiated Hold Time value is zero, then the Hold Time
@@ -441,7 +441,7 @@ void bgp_timer_set(struct peer *peer)
* Additionally if a different hold timer has been negotiated
* than we must stop then start the timer again
*/
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
if (peer->v_holdtime == 0)
bgp_keepalives_off(peer);
else {
@@ -449,16 +449,16 @@ void bgp_timer_set(struct peer *peer)
peer->v_holdtime);
bgp_keepalives_on(peer);
}
- THREAD_OFF(peer->t_routeadv);
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_delayopen);
break;
case Established:
/* In Established status start and connect timer is turned
off. */
- THREAD_OFF(peer->t_start);
- THREAD_OFF(peer->t_connect);
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_start);
+ EVENT_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_delayopen);
/*
* Same as OpenConfirm, if holdtime is zero then both holdtime
@@ -466,7 +466,7 @@ void bgp_timer_set(struct peer *peer)
* Additionally if a different hold timer has been negotiated
* then we must stop then start the timer again
*/
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
if (peer->v_holdtime == 0)
bgp_keepalives_off(peer);
else {
@@ -476,22 +476,22 @@ void bgp_timer_set(struct peer *peer)
}
break;
case Deleted:
- THREAD_OFF(peer->t_gr_restart);
- THREAD_OFF(peer->t_gr_stale);
+ EVENT_OFF(peer->t_gr_restart);
+ EVENT_OFF(peer->t_gr_stale);
FOREACH_AFI_SAFI (afi, safi)
- THREAD_OFF(peer->t_llgr_stale[afi][safi]);
+ EVENT_OFF(peer->t_llgr_stale[afi][safi]);
- THREAD_OFF(peer->t_pmax_restart);
- THREAD_OFF(peer->t_refresh_stalepath);
+ EVENT_OFF(peer->t_pmax_restart);
+ EVENT_OFF(peer->t_refresh_stalepath);
/* fallthru */
case Clearing:
- THREAD_OFF(peer->t_start);
- THREAD_OFF(peer->t_connect);
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_start);
+ EVENT_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_holdtime);
bgp_keepalives_off(peer);
- THREAD_OFF(peer->t_routeadv);
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_delayopen);
break;
case BGP_STATUS_MAX:
flog_err(EC_LIB_DEVELOPMENT,
@@ -506,12 +506,12 @@ static void bgp_start_timer(struct event *thread)
{
struct peer *peer;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Timer (start timer expire).", peer->host);
- THREAD_VAL(thread) = BGP_Start;
+ EVENT_VAL(thread) = BGP_Start;
bgp_event(thread); /* bgp_event unlocks peer */
}
@@ -520,10 +520,10 @@ static void bgp_connect_timer(struct event *thread)
{
struct peer *peer;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
/* stop the DelayOpenTimer if it is running */
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_delayopen);
assert(!peer->t_write);
assert(!peer->t_read);
@@ -534,7 +534,7 @@ static void bgp_connect_timer(struct event *thread)
if (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
bgp_stop(peer);
else {
- THREAD_VAL(thread) = ConnectRetry_timer_expired;
+ EVENT_VAL(thread) = ConnectRetry_timer_expired;
bgp_event(thread); /* bgp_event unlocks peer */
}
}
@@ -545,7 +545,7 @@ static void bgp_holdtime_timer(struct event *thread)
atomic_size_t inq_count;
struct peer *peer;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Timer (holdtime timer expire)",
@@ -567,7 +567,7 @@ static void bgp_holdtime_timer(struct event *thread)
BGP_TIMER_ON(peer->t_holdtime, bgp_holdtime_timer,
peer->v_holdtime);
- THREAD_VAL(thread) = Hold_Timer_expired;
+ EVENT_VAL(thread) = Hold_Timer_expired;
bgp_event(thread); /* bgp_event unlocks peer */
}
@@ -575,7 +575,7 @@ void bgp_routeadv_timer(struct event *thread)
{
struct peer *peer;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Timer (routeadv timer expire)",
@@ -596,13 +596,13 @@ void bgp_delayopen_timer(struct event *thread)
{
struct peer *peer;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [FSM] Timer (DelayOpentimer expire)",
peer->host);
- THREAD_VAL(thread) = DelayOpen_timer_expired;
+ EVENT_VAL(thread) = DelayOpen_timer_expired;
bgp_event(thread); /* bgp_event unlocks peer */
}
@@ -655,7 +655,7 @@ static void bgp_graceful_restart_timer_off(struct peer *peer)
return;
UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT);
- THREAD_OFF(peer->t_gr_stale);
+ EVENT_OFF(peer->t_gr_stale);
if (peer_dynamic_neighbor(peer) &&
!(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) {
@@ -675,7 +675,7 @@ static void bgp_llgr_stale_timer_expire(struct event *thread)
afi_t afi;
safi_t safi;
- paf = THREAD_ARG(thread);
+ paf = EVENT_ARG(thread);
peer = paf->peer;
afi = paf->afi;
@@ -778,7 +778,7 @@ static void bgp_graceful_restart_timer_expire(struct event *thread)
afi_t afi;
safi_t safi;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
if (bgp_debug_neighbor_events(peer)) {
zlog_debug("%pBP graceful restart timer expired", peer);
@@ -841,7 +841,7 @@ static void bgp_graceful_stale_timer_expire(struct event *thread)
afi_t afi;
safi_t safi;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%pBP graceful restart stalepath timer expired",
@@ -861,7 +861,7 @@ static void bgp_graceful_deferral_timer_expire(struct event *thread)
safi_t safi;
struct bgp *bgp;
- info = THREAD_ARG(thread);
+ info = EVENT_ARG(thread);
afi = info->afi;
safi = info->safi;
bgp = info->bgp;
@@ -908,8 +908,8 @@ bool bgp_update_delay_configured(struct bgp *bgp)
on ending the update delay. */
void bgp_update_delay_end(struct bgp *bgp)
{
- THREAD_OFF(bgp->t_update_delay);
- THREAD_OFF(bgp->t_establish_wait);
+ EVENT_OFF(bgp->t_update_delay);
+ EVENT_OFF(bgp->t_establish_wait);
/* Reset update-delay related state */
bgp->update_delay_over = 1;
@@ -972,7 +972,7 @@ void bgp_start_routeadv(struct bgp *bgp)
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
if (!peer_established(peer))
continue;
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
}
}
@@ -992,7 +992,7 @@ void bgp_adjust_routeadv(struct peer *peer)
* different
* duration and schedule write thread immediately.
*/
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
peer->synctime = monotime(NULL);
/* If suppress fib pending is enabled, route is advertised to
@@ -1024,7 +1024,7 @@ void bgp_adjust_routeadv(struct peer *peer)
*/
diff = difftime(nowtime, peer->last_update);
if (diff > (double)peer->v_routeadv) {
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
return;
}
@@ -1051,7 +1051,7 @@ void bgp_adjust_routeadv(struct peer *peer)
remain = peer->v_routeadv;
diff = peer->v_routeadv - diff;
if (diff <= (double)remain) {
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, diff);
}
}
@@ -1130,8 +1130,8 @@ static void bgp_maxmed_onstartup_timer(struct event *thread)
zlog_info("Max med on startup ended - timer expired.");
- bgp = THREAD_ARG(thread);
- THREAD_OFF(bgp->t_maxmed_onstartup);
+ bgp = EVENT_ARG(thread);
+ EVENT_OFF(bgp->t_maxmed_onstartup);
bgp->maxmed_onstartup_over = 1;
bgp_maxmed_update(bgp);
@@ -1172,8 +1172,8 @@ static void bgp_update_delay_timer(struct event *thread)
zlog_info("Update delay ended - timer expired.");
- bgp = THREAD_ARG(thread);
- THREAD_OFF(bgp->t_update_delay);
+ bgp = EVENT_ARG(thread);
+ EVENT_OFF(bgp->t_update_delay);
bgp_update_delay_end(bgp);
}
@@ -1184,8 +1184,8 @@ static void bgp_establish_wait_timer(struct event *thread)
zlog_info("Establish wait - timer expired.");
- bgp = THREAD_ARG(thread);
- THREAD_OFF(bgp->t_establish_wait);
+ bgp = EVENT_ARG(thread);
+ EVENT_OFF(bgp->t_establish_wait);
bgp_check_update_delay(bgp);
}
@@ -1412,7 +1412,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
/* graceful restart */
if (peer->t_gr_stale) {
- THREAD_OFF(peer->t_gr_stale);
+ EVENT_OFF(peer->t_gr_stale);
if (bgp_debug_neighbor_events(peer))
zlog_debug(
"%pBP graceful restart stalepath timer stopped",
@@ -1442,7 +1442,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
/* Stop route-refresh stalepath timer */
if (peer->t_refresh_stalepath) {
- THREAD_OFF(peer->t_refresh_stalepath);
+ EVENT_OFF(peer->t_refresh_stalepath);
if (bgp_debug_neighbor_events(peer))
zlog_debug(
@@ -1476,11 +1476,11 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
/* There is no pending EOR message */
if (gr_info->eor_required == 0) {
if (gr_info->t_select_deferral) {
- void *info = THREAD_ARG(
+ void *info = EVENT_ARG(
gr_info->t_select_deferral);
XFREE(MTYPE_TMP, info);
}
- THREAD_OFF(gr_info->t_select_deferral);
+ EVENT_OFF(gr_info->t_select_deferral);
gr_info->eor_received = 0;
}
}
@@ -1505,15 +1505,15 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
bgp_writes_off(peer);
bgp_reads_off(peer);
- THREAD_OFF(peer->t_connect_check_r);
- THREAD_OFF(peer->t_connect_check_w);
+ EVENT_OFF(peer->t_connect_check_r);
+ EVENT_OFF(peer->t_connect_check_w);
/* Stop all timers. */
- THREAD_OFF(peer->t_start);
- THREAD_OFF(peer->t_connect);
- THREAD_OFF(peer->t_holdtime);
- THREAD_OFF(peer->t_routeadv);
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_start);
+ EVENT_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_delayopen);
/* Clear input and output buffer. */
frr_with_mutex (&peer->io_mtx) {
@@ -1660,14 +1660,14 @@ static void bgp_connect_check(struct event *thread)
int ret;
struct peer *peer;
- peer = THREAD_ARG(thread);
+ peer = EVENT_ARG(thread);
assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_READS_ON));
assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON));
assert(!peer->t_read);
assert(!peer->t_write);
- THREAD_OFF(peer->t_connect_check_r);
- THREAD_OFF(peer->t_connect_check_w);
+ EVENT_OFF(peer->t_connect_check_r);
+ EVENT_OFF(peer->t_connect_check_w);
/* Check file descriptor. */
slen = sizeof(status);
@@ -2012,7 +2012,7 @@ static enum bgp_fsm_state_progress
bgp_fsm_delayopen_timer_expire(struct peer *peer)
{
/* Stop the DelayOpenTimer */
- THREAD_OFF(peer->t_delayopen);
+ EVENT_OFF(peer->t_delayopen);
/* Send open message to peer */
bgp_open_send(peer);
@@ -2225,7 +2225,7 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
else {
UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_MODE);
if (peer->t_gr_stale) {
- THREAD_OFF(peer->t_gr_stale);
+ EVENT_OFF(peer->t_gr_stale);
if (bgp_debug_neighbor_events(peer))
zlog_debug(
"%pBP graceful restart stalepath timer stopped",
@@ -2234,7 +2234,7 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
}
if (peer->t_gr_restart) {
- THREAD_OFF(peer->t_gr_restart);
+ EVENT_OFF(peer->t_gr_restart);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%pBP graceful restart timer stopped", peer);
}
@@ -2250,7 +2250,7 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
*/
FOREACH_AFI_SAFI (afi, safi) {
if (peer->t_llgr_stale[afi][safi]) {
- THREAD_OFF(peer->t_llgr_stale[afi][safi]);
+ EVENT_OFF(peer->t_llgr_stale[afi][safi]);
if (bgp_debug_neighbor_events(peer))
zlog_debug(
"%pBP Long-lived stale timer stopped for afi/safi: %d/%d",
@@ -2295,7 +2295,7 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
* of read-only mode.
*/
if (!bgp_update_delay_active(peer->bgp)) {
- THREAD_OFF(peer->t_routeadv);
+ EVENT_OFF(peer->t_routeadv);
BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
}
@@ -2330,14 +2330,14 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
/* Keepalive packet is received. */
static enum bgp_fsm_state_progress bgp_fsm_keepalive(struct peer *peer)
{
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
return BGP_FSM_SUCCESS;
}
/* Update packet is received. */
static enum bgp_fsm_state_progress bgp_fsm_update(struct peer *peer)
{
- THREAD_OFF(peer->t_holdtime);
+ EVENT_OFF(peer->t_holdtime);
return BGP_FSM_SUCCESS;
}
@@ -2379,13 +2379,13 @@ void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops)
break;
case Connect:
if (!has_valid_nexthops) {
- THREAD_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_connect);
BGP_EVENT_ADD(peer, TCP_fatal_error);
}
break;
case Active:
if (has_valid_nexthops) {
- THREAD_OFF(peer->t_connect);
+ EVENT_OFF(peer->t_connect);
BGP_EVENT_ADD(peer, ConnectRetry_timer_expired);
}
break;
@@ -2576,8 +2576,8 @@ void bgp_event(struct event *thread)
enum bgp_fsm_events event;
struct peer *peer;
- peer = THREAD_ARG(thread);
- event = THREAD_VAL(thread);
+ peer = EVENT_ARG(thread);
+ event = EVENT_VAL(thread);
peer_lock(peer);
bgp_event_update(peer, event);