diff options
-rw-r--r-- | bgpd/bgp_bfd.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_fsm.c | 317 | ||||
-rw-r--r-- | bgpd/bgp_fsm.h | 38 | ||||
-rw-r--r-- | bgpd/bgp_io.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_network.c | 18 | ||||
-rw-r--r-- | bgpd/bgp_nexthop.c | 5 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 28 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 13 | ||||
-rw-r--r-- | bgpd/bgp_snmp_bgp4.c | 5 | ||||
-rw-r--r-- | bgpd/bgp_updgrp.c | 5 | ||||
-rw-r--r-- | bgpd/bgp_updgrp_adv.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_zebra.c | 11 | ||||
-rw-r--r-- | bgpd/bgpd.c | 42 |
13 files changed, 232 insertions, 266 deletions
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index 11de3e3e6..e14626f3f 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -60,14 +60,14 @@ static void bfd_session_status_update(struct bfd_session_params *bsp, bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_BFD_DOWN); - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); } if (bss->state == BSS_UP && bss->previous_state != BSS_UP && !peer_established(peer->connection)) { if (!BGP_PEER_START_SUPPRESSED(peer)) { bgp_fsm_nht_update(peer, true); - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Start); } } } diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 10712656d..8cb8165d3 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -116,18 +116,30 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) struct peer *peer; afi_t afi; safi_t safi; - int fd; - enum bgp_fsm_status status, pstatus; enum bgp_fsm_events last_evt, last_maj_evt; + struct peer_connection *keeper, *going_away; assert(from_peer != NULL); + /* + * Keeper is the connection that is staying around + */ + keeper = from_peer->connection; peer = from_peer->doppelganger; if (!peer || !CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) return from_peer; /* + * from_peer is pointing at the non config node and + * at this point peer is pointing at the CONFIG node + * peer ( non incoming connection ). The going_away pointer + * is the connection that is being placed on to + * the non Config node for deletion. + */ + going_away = peer->connection; + + /* * Let's check that we are not going to loose known configuration * state based upon doppelganger rules. */ @@ -146,10 +158,10 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) from_peer->host, from_peer, from_peer->connection->fd, peer, peer->connection->fd); - bgp_writes_off(peer->connection); - bgp_reads_off(peer->connection); - bgp_writes_off(from_peer->connection); - bgp_reads_off(from_peer->connection); + bgp_writes_off(going_away); + bgp_reads_off(going_away); + bgp_writes_off(keeper); + bgp_reads_off(keeper); /* * Before exchanging FD remove doppelganger from @@ -157,70 +169,29 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) * fd is set to -1. If blocked on lock then keepalive * thread can access peer pointer with fd -1. */ - bgp_keepalives_off(from_peer->connection); - - EVENT_OFF(peer->connection->t_routeadv); - EVENT_OFF(peer->connection->t_connect); - EVENT_OFF(peer->connection->t_delayopen); - EVENT_OFF(peer->connection->t_connect_check_r); - EVENT_OFF(peer->connection->t_connect_check_w); - EVENT_OFF(from_peer->connection->t_routeadv); - EVENT_OFF(from_peer->connection->t_connect); - EVENT_OFF(from_peer->connection->t_delayopen); - EVENT_OFF(from_peer->connection->t_connect_check_r); - EVENT_OFF(from_peer->connection->t_connect_check_w); - EVENT_OFF(from_peer->connection->t_process_packet); + bgp_keepalives_off(keeper); + + EVENT_OFF(going_away->t_routeadv); + EVENT_OFF(going_away->t_connect); + EVENT_OFF(going_away->t_delayopen); + EVENT_OFF(going_away->t_connect_check_r); + EVENT_OFF(going_away->t_connect_check_w); + EVENT_OFF(keeper->t_routeadv); + EVENT_OFF(keeper->t_connect); + EVENT_OFF(keeper->t_delayopen); + EVENT_OFF(keeper->t_connect_check_r); + EVENT_OFF(keeper->t_connect_check_w); + EVENT_OFF(keeper->t_process_packet); /* * At this point in time, it is possible that there are packets pending * on various buffers. Those need to be transferred or dropped, * otherwise we'll get spurious failures during session establishment. */ - frr_with_mutex (&peer->connection->io_mtx, - &from_peer->connection->io_mtx) { - fd = peer->connection->fd; - peer->connection->fd = from_peer->connection->fd; - from_peer->connection->fd = fd; - - stream_fifo_clean(peer->connection->ibuf); - stream_fifo_clean(peer->connection->obuf); - - /* - * this should never happen, since bgp_process_packet() is the - * only task that sets and unsets the current packet and it - * runs in our pthread. - */ - if (peer->curr) { - flog_err( - EC_BGP_PKT_PROCESS, - "[%s] Dropping pending packet on connection transfer:", - peer->host); - /* there used to be a bgp_packet_dump call here, but - * that's extremely confusing since there's no way to - * identify the packet in MRT dumps or BMP as dropped - * due to connection transfer. - */ - stream_free(peer->curr); - peer->curr = NULL; - } - - // copy each packet from old peer's output queue to new peer - while (from_peer->connection->obuf->head) - stream_fifo_push(peer->connection->obuf, - stream_fifo_pop( - from_peer->connection->obuf)); - - // copy each packet from old peer's input queue to new peer - while (from_peer->connection->ibuf->head) - stream_fifo_push(peer->connection->ibuf, - stream_fifo_pop( - from_peer->connection->ibuf)); - - ringbuf_wipe(peer->connection->ibuf_work); - ringbuf_copy(peer->connection->ibuf_work, - from_peer->connection->ibuf_work, - ringbuf_remain(from_peer->connection->ibuf_work)); - } + peer->connection = keeper; + keeper->peer = peer; + from_peer->connection = going_away; + going_away->peer = from_peer; peer->as = from_peer->as; peer->v_holdtime = from_peer->v_holdtime; @@ -230,16 +201,10 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) peer->v_gr_restart = from_peer->v_gr_restart; peer->cap = from_peer->cap; peer->remote_role = from_peer->remote_role; - status = peer->connection->status; - pstatus = peer->connection->ostatus; last_evt = peer->last_event; last_maj_evt = peer->last_major_event; - peer->connection->status = from_peer->connection->status; - peer->connection->ostatus = from_peer->connection->ostatus; peer->last_event = from_peer->last_event; peer->last_major_event = from_peer->last_major_event; - from_peer->connection->status = status; - from_peer->connection->ostatus = pstatus; from_peer->last_event = last_evt; from_peer->last_major_event = last_maj_evt; peer->remote_id = from_peer->remote_id; @@ -301,13 +266,12 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER) ? "accept" : ""), - peer->host, peer->connection->fd, - from_peer->connection->fd); - BGP_EVENT_ADD(peer, BGP_Stop); - BGP_EVENT_ADD(from_peer, BGP_Stop); + peer->host, going_away->fd, keeper->fd); + BGP_EVENT_ADD(going_away, BGP_Stop); + BGP_EVENT_ADD(keeper, BGP_Stop); return NULL; } - if (from_peer->connection->status > Active) { + if (going_away->status > Active) { if (bgp_getsockname(from_peer) < 0) { flog_err(EC_LIB_SOCKET, "%%bgp_getsockname() failed for %s from_peer %s fd %d (peer fd %d)", @@ -316,9 +280,8 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) PEER_STATUS_ACCEPT_PEER) ? "accept" : ""), - from_peer->host, from_peer->connection->fd, - peer->connection->fd); - bgp_stop(from_peer->connection); + from_peer->host, going_away->fd, keeper->fd); + bgp_stop(going_away); from_peer = NULL; } } @@ -335,10 +298,10 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) if (from_peer) bgp_replace_nexthop_by_peer(from_peer, peer); - bgp_reads_on(peer->connection); - bgp_writes_on(peer->connection); - event_add_event(bm->master, bgp_process_packet, peer->connection, 0, - &peer->connection->t_process_packet); + bgp_reads_on(keeper); + bgp_writes_on(keeper); + event_add_event(bm->master, bgp_process_packet, keeper, 0, + &keeper->t_process_packet); return (peer); } @@ -500,9 +463,8 @@ void bgp_timer_set(struct peer_connection *connection) and process event. */ static void bgp_start_timer(struct event *thread) { - struct peer *peer; - - peer = EVENT_ARG(thread); + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Timer (start timer expire).", peer->host); @@ -514,21 +476,20 @@ static void bgp_start_timer(struct event *thread) /* BGP connect retry timer. */ static void bgp_connect_timer(struct event *thread) { - struct peer *peer; - - peer = EVENT_ARG(thread); + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; /* stop the DelayOpenTimer if it is running */ - EVENT_OFF(peer->connection->t_delayopen); + EVENT_OFF(connection->t_delayopen); - assert(!peer->connection->t_write); - assert(!peer->connection->t_read); + assert(!connection->t_write); + assert(!connection->t_read); if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Timer (connect timer expire)", peer->host); if (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER)) - bgp_stop(peer->connection); + bgp_stop(connection); else { EVENT_VAL(thread) = ConnectRetry_timer_expired; bgp_event(thread); /* bgp_event unlocks peer */ @@ -539,9 +500,8 @@ static void bgp_connect_timer(struct event *thread) static void bgp_holdtime_timer(struct event *thread) { atomic_size_t inq_count; - struct peer *peer; - - peer = EVENT_ARG(thread); + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Timer (holdtime timer expire)", @@ -557,10 +517,10 @@ static void bgp_holdtime_timer(struct event *thread) * for systems where we are heavily loaded for one * reason or another. */ - inq_count = atomic_load_explicit(&peer->connection->ibuf->count, + inq_count = atomic_load_explicit(&connection->ibuf->count, memory_order_relaxed); if (inq_count) - BGP_TIMER_ON(peer->connection->t_holdtime, bgp_holdtime_timer, + BGP_TIMER_ON(connection->t_holdtime, bgp_holdtime_timer, peer->v_holdtime); EVENT_VAL(thread) = Hold_Timer_expired; @@ -569,18 +529,16 @@ static void bgp_holdtime_timer(struct event *thread) void bgp_routeadv_timer(struct event *thread) { - struct peer *peer; - - peer = EVENT_ARG(thread); + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; if (bgp_debug_neighbor_events(peer)) - zlog_debug("%s [FSM] Timer (routeadv timer expire)", - peer->host); + zlog_debug("%s [FSM] Timer (routeadv timer expire)", peer->host); peer->synctime = monotime(NULL); - event_add_timer_msec(bm->master, bgp_generate_updgrp_packets, peer, 0, - &peer->connection->t_generate_updgrp_packets); + event_add_timer_msec(bm->master, bgp_generate_updgrp_packets, connection, + 0, &connection->t_generate_updgrp_packets); /* MRAI timer will be started again when FIFO is built, no need to * do it here. @@ -590,9 +548,8 @@ void bgp_routeadv_timer(struct event *thread) /* RFC 4271 DelayOpenTimer */ void bgp_delayopen_timer(struct event *thread) { - struct peer *peer; - - peer = EVENT_ARG(thread); + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Timer (DelayOpentimer expire)", @@ -640,7 +597,8 @@ const char *const peer_down_str[] = {"", "Socket Error", "Admin. shutdown (RTT)"}; -static void bgp_graceful_restart_timer_off(struct peer *peer) +static void bgp_graceful_restart_timer_off(struct peer_connection *connection, + struct peer *peer) { afi_t afi; safi_t safi; @@ -651,7 +609,7 @@ static void bgp_graceful_restart_timer_off(struct peer *peer) return; UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT); - EVENT_OFF(peer->connection->t_gr_stale); + EVENT_OFF(connection->t_gr_stale); if (peer_dynamic_neighbor(peer) && !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) { @@ -661,7 +619,7 @@ static void bgp_graceful_restart_timer_off(struct peer *peer) peer_delete(peer); } - bgp_timer_set(peer->connection); + bgp_timer_set(connection); } static void bgp_llgr_stale_timer_expire(struct event *thread) @@ -689,7 +647,7 @@ static void bgp_llgr_stale_timer_expire(struct event *thread) bgp_clear_stale_route(peer, afi, safi); - bgp_graceful_restart_timer_off(peer); + bgp_graceful_restart_timer_off(peer->connection, peer); } static void bgp_set_llgr_stale(struct peer *peer, afi_t afi, safi_t safi) @@ -768,14 +726,14 @@ static void bgp_set_llgr_stale(struct peer *peer, afi_t afi, safi_t safi) static void bgp_graceful_restart_timer_expire(struct event *thread) { - struct peer *peer, *tmp_peer; + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; + struct peer *tmp_peer; struct listnode *node, *nnode; struct peer_af *paf; afi_t afi; safi_t safi; - peer = EVENT_ARG(thread); - if (bgp_debug_neighbor_events(peer)) { zlog_debug("%pBP graceful restart timer expired", peer); zlog_debug("%pBP graceful restart stalepath timer stopped", @@ -828,17 +786,16 @@ static void bgp_graceful_restart_timer_expire(struct event *thread) } } - bgp_graceful_restart_timer_off(peer); + bgp_graceful_restart_timer_off(connection, peer); } static void bgp_graceful_stale_timer_expire(struct event *thread) { - struct peer *peer; + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; afi_t afi; safi_t safi; - peer = EVENT_ARG(thread); - if (bgp_debug_neighbor_events(peer)) zlog_debug("%pBP graceful restart stalepath timer expired", peer); @@ -970,9 +927,9 @@ void bgp_start_routeadv(struct bgp *bgp) if (!peer_established(connection)) continue; - EVENT_OFF(peer->connection->t_routeadv); - BGP_TIMER_ON(peer->connection->t_routeadv, bgp_routeadv_timer, - 0); + + EVENT_OFF(connection->t_routeadv); + BGP_TIMER_ON(connection->t_routeadv, bgp_routeadv_timer, 0); } } @@ -984,6 +941,7 @@ void bgp_adjust_routeadv(struct peer *peer) time_t nowtime = monotime(NULL); double diff; unsigned long remain; + struct peer_connection *connection = peer->connection; /* Bypass checks for special case of MRAI being 0 */ if (peer->v_routeadv == 0) { @@ -991,7 +949,7 @@ void bgp_adjust_routeadv(struct peer *peer) * different * duration and schedule write thread immediately. */ - EVENT_OFF(peer->connection->t_routeadv); + EVENT_OFF(connection->t_routeadv); peer->synctime = monotime(NULL); /* If suppress fib pending is enabled, route is advertised to @@ -999,8 +957,7 @@ void bgp_adjust_routeadv(struct peer *peer) * is added to update group packet generate which will allow * more routes to be sent in the update message */ - BGP_UPDATE_GROUP_TIMER_ON(&peer->connection - ->t_generate_updgrp_packets, + BGP_UPDATE_GROUP_TIMER_ON(&connection->t_generate_updgrp_packets, bgp_generate_updgrp_packets); return; } @@ -1024,9 +981,8 @@ void bgp_adjust_routeadv(struct peer *peer) */ diff = difftime(nowtime, peer->last_update); if (diff > (double)peer->v_routeadv) { - EVENT_OFF(peer->connection->t_routeadv); - BGP_TIMER_ON(peer->connection->t_routeadv, bgp_routeadv_timer, - 0); + EVENT_OFF(connection->t_routeadv); + BGP_TIMER_ON(connection->t_routeadv, bgp_routeadv_timer, 0); return; } @@ -1046,15 +1002,14 @@ void bgp_adjust_routeadv(struct peer *peer) * * (MRAI - m) < r */ - if (peer->connection->t_routeadv) - remain = event_timer_remain_second(peer->connection->t_routeadv); + if (connection->t_routeadv) + remain = event_timer_remain_second(connection->t_routeadv); else remain = peer->v_routeadv; diff = peer->v_routeadv - diff; if (diff <= (double)remain) { - EVENT_OFF(peer->connection->t_routeadv); - BGP_TIMER_ON(peer->connection->t_routeadv, bgp_routeadv_timer, - diff); + EVENT_OFF(connection->t_routeadv); + BGP_TIMER_ON(connection->t_routeadv, bgp_routeadv_timer, diff); } } @@ -1246,17 +1201,18 @@ static void bgp_update_delay_process_status_change(struct peer *peer) /* Called after event occurred, this function change status and reset read/write and timer thread. */ -void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status) +void bgp_fsm_change_status(struct peer_connection *connection, + enum bgp_fsm_status status) { - struct bgp *bgp; + struct peer *peer = connection->peer; + struct bgp *bgp = peer->bgp; uint32_t peer_count; - bgp = peer->bgp; peer_count = bgp->established_peers; if (status == Established) bgp->established_peers++; - else if ((peer_established(peer->connection)) && (status != Established)) + else if ((peer_established(connection)) && (status != Established)) bgp->established_peers--; if (bgp_debug_neighbor_events(peer)) { @@ -1303,19 +1259,19 @@ void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status) */ if (!work_queue_is_scheduled(peer->clear_node_queue) && status != Deleted) - BGP_EVENT_ADD(peer, Clearing_Completed); + BGP_EVENT_ADD(connection, Clearing_Completed); } /* Preserve old status and change into new status. */ - peer->connection->ostatus = peer->connection->status; - peer->connection->status = status; + connection->ostatus = connection->status; + connection->status = status; /* Reset received keepalives counter on every FSM change */ peer->rtt_keepalive_rcv = 0; /* Fire backward transition hook if that's the case */ - if (peer->connection->ostatus == Established && - peer->connection->status != Established) + if (connection->ostatus == Established && + connection->status != Established) hook_call(peer_backward_transition, peer); /* Save event that caused status change. */ @@ -1343,23 +1299,19 @@ void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status) if (bgp_debug_neighbor_events(peer)) zlog_debug("%s fd %d went from %s to %s", peer->host, - peer->connection->fd, - lookup_msg(bgp_status_msg, peer->connection->ostatus, - NULL), - lookup_msg(bgp_status_msg, peer->connection->status, - NULL)); + connection->fd, + lookup_msg(bgp_status_msg, connection->ostatus, NULL), + lookup_msg(bgp_status_msg, connection->status, NULL)); } /* Flush the event queue and ensure the peer is shut down */ static enum bgp_fsm_state_progress bgp_clearing_completed(struct peer_connection *connection) { - struct peer *peer = connection->peer; - enum bgp_fsm_state_progress rc = bgp_stop(connection); if (rc >= BGP_FSM_SUCCESS) - event_cancel_event_ready(bm->master, peer); + event_cancel_event_ready(bm->master, connection); return rc; } @@ -1395,7 +1347,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection) /* Can't do this in Clearing; events are used for state transitions */ if (connection->status != Clearing) { /* Delete all existing events of the peer */ - event_cancel_event_ready(bm->master, peer); + event_cancel_event_ready(bm->master, connection); } /* Increment Dropped count. */ @@ -1695,22 +1647,23 @@ static void bgp_connect_check(struct event *thread) if (ret < 0) { zlog_err("can't get sockopt for nonblocking connect: %d(%s)", errno, safe_strerror(errno)); - BGP_EVENT_ADD(peer, TCP_fatal_error); + BGP_EVENT_ADD(peer->connection, TCP_fatal_error); return; } /* When status is 0 then TCP connection is established. */ if (status == 0) { if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER_DELAYOPEN)) - BGP_EVENT_ADD(peer, TCP_connection_open_w_delay); + BGP_EVENT_ADD(peer->connection, + TCP_connection_open_w_delay); else - BGP_EVENT_ADD(peer, TCP_connection_open); + BGP_EVENT_ADD(peer->connection, TCP_connection_open); return; } else { if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [Event] Connect failed %d(%s)", peer->host, status, safe_strerror(status)); - BGP_EVENT_ADD(peer, TCP_connection_open_failed); + BGP_EVENT_ADD(peer->connection, TCP_connection_open_failed); return; } } @@ -1895,7 +1848,7 @@ static enum bgp_fsm_state_progress bgp_start(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(peer, TCP_connection_open_failed); + BGP_EVENT_ADD(connection, TCP_connection_open_failed); return BGP_FSM_SUCCESS; } @@ -1919,7 +1872,7 @@ static enum bgp_fsm_state_progress bgp_start(struct peer_connection *connection) "%s [FSM] Waiting for NHT, no path to neighbor present", peer->host); peer->last_reset = PEER_DOWN_WAITING_NHT; - BGP_EVENT_ADD(peer, TCP_connection_open_failed); + BGP_EVENT_ADD(connection, TCP_connection_open_failed); return BGP_FSM_SUCCESS; } } @@ -1934,14 +1887,14 @@ static enum bgp_fsm_state_progress bgp_start(struct peer_connection *connection) case connect_error: if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Connect error", peer->host); - BGP_EVENT_ADD(peer, TCP_connection_open_failed); + BGP_EVENT_ADD(connection, TCP_connection_open_failed); break; case connect_success: if (bgp_debug_neighbor_events(peer)) zlog_debug("%s [FSM] Connect immediately success, fd %d", peer->host, connection->fd); - BGP_EVENT_ADD(peer, TCP_connection_open); + BGP_EVENT_ADD(connection, TCP_connection_open); break; case connect_in_progress: /* To check nonblocking connect, we wait until socket is @@ -2171,6 +2124,11 @@ bgp_establish(struct peer_connection *connection) hash_alloc_intern); return BGP_FSM_FAILURE; } + /* + * At this point the connections have been possibly swapped + * let's reset it. + */ + connection = peer->connection; if (other == peer) ret = BGP_FSM_SUCCESS_STATE_TRANSFER; @@ -2184,7 +2142,7 @@ bgp_establish(struct peer_connection *connection) /* Increment established count. */ peer->established++; - bgp_fsm_change_status(peer, Established); + bgp_fsm_change_status(connection, Established); /* bgp log-neighbor-changes of neighbor Up */ if (CHECK_FLAG(peer->bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) { @@ -2426,18 +2384,19 @@ void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops) switch (peer->connection->status) { case Idle: if (has_valid_nexthops) - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Start); break; case Connect: if (!has_valid_nexthops) { EVENT_OFF(peer->connection->t_connect); - BGP_EVENT_ADD(peer, TCP_fatal_error); + BGP_EVENT_ADD(peer->connection, TCP_fatal_error); } break; case Active: if (has_valid_nexthops) { EVENT_OFF(peer->connection->t_connect); - BGP_EVENT_ADD(peer, ConnectRetry_timer_expired); + BGP_EVENT_ADD(peer->connection, + ConnectRetry_timer_expired); } break; case OpenSent: @@ -2446,7 +2405,7 @@ void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops) if (!has_valid_nexthops && (peer->gtsm_hops == BGP_GTSM_HOPS_CONNECTED || peer->bgp->fast_convergence)) - BGP_EVENT_ADD(peer, TCP_fatal_error); + BGP_EVENT_ADD(peer->connection, TCP_fatal_error); case Clearing: case Deleted: case BGP_STATUS_MAX: @@ -2624,48 +2583,48 @@ static const struct { /* Execute event process. */ void bgp_event(struct event *thread) { + struct peer_connection *connection = EVENT_ARG(thread); enum bgp_fsm_events event; - struct peer *peer; + struct peer *peer = connection->peer; - peer = EVENT_ARG(thread); event = EVENT_VAL(thread); peer_lock(peer); - bgp_event_update(peer, event); + bgp_event_update(connection, event); peer_unlock(peer); } -int bgp_event_update(struct peer *peer, enum bgp_fsm_events event) +int bgp_event_update(struct peer_connection *connection, + enum bgp_fsm_events event) { enum bgp_fsm_status next; enum bgp_fsm_state_progress ret = 0; int fsm_result = FSM_PEER_NOOP; int passive_conn = 0; int dyn_nbr; - struct peer_connection *connection = peer->connection; + struct peer *peer = connection->peer; passive_conn = (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER)) ? 1 : 0; dyn_nbr = peer_dynamic_neighbor(peer); /* Logging this event. */ - next = FSM[peer->connection->status - 1][event - 1].next_state; + next = FSM[connection->status - 1][event - 1].next_state; - if (bgp_debug_neighbor_events(peer) && peer->connection->status != next) + if (bgp_debug_neighbor_events(peer) && connection->status != next) zlog_debug("%s [FSM] %s (%s->%s), fd %d", peer->host, bgp_event_str[event], - lookup_msg(bgp_status_msg, peer->connection->status, - NULL), + lookup_msg(bgp_status_msg, connection->status, NULL), lookup_msg(bgp_status_msg, next, NULL), - peer->connection->fd); + connection->fd); peer->last_event = peer->cur_event; peer->cur_event = event; /* Call function. */ - if (FSM[peer->connection->status - 1][event - 1].func) - ret = (*(FSM[peer->connection->status - 1][event - 1].func))( - peer->connection); + if (FSM[connection->status - 1][event - 1].func) + ret = (*(FSM[connection->status - 1][event - 1].func))( + connection); switch (ret) { case BGP_FSM_SUCCESS: @@ -2679,8 +2638,8 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event) } /* If status is changed. */ - if (next != peer->connection->status) { - bgp_fsm_change_status(peer, next); + if (next != connection->status) { + bgp_fsm_change_status(connection, next); /* * If we're going to ESTABLISHED then we executed a @@ -2716,7 +2675,7 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event) connection->fd, peer_down_str[peer->last_reset]); bgp_stop(connection); - bgp_fsm_change_status(peer, Idle); + bgp_fsm_change_status(connection, Idle); bgp_timer_set(connection); } fsm_result = FSM_PEER_STOPPED; diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index 0e2fbb292..7a99623a5 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -17,27 +17,28 @@ enum bgp_fsm_state_progress { /* Macro for BGP read, write and timer thread. */ #define BGP_TIMER_ON(T, F, V) \ do { \ - if ((peer->connection->status != Deleted)) \ - event_add_timer(bm->master, (F), peer, (V), &(T)); \ + if ((connection->status != Deleted)) \ + event_add_timer(bm->master, (F), connection, (V), \ + &(T)); \ } while (0) -#define BGP_EVENT_ADD(P, E) \ +#define BGP_EVENT_ADD(C, E) \ do { \ - if ((P)->connection->status != Deleted) \ - event_add_event(bm->master, bgp_event, (P), (E), NULL); \ + if ((C)->status != Deleted) \ + event_add_event(bm->master, bgp_event, (C), (E), NULL); \ } while (0) -#define BGP_UPDATE_GROUP_TIMER_ON(T, F) \ - do { \ - if (BGP_SUPPRESS_FIB_ENABLED(peer->bgp) && \ - PEER_ROUTE_ADV_DELAY(peer)) \ - event_add_timer_msec( \ - bm->master, (F), peer, \ - (BGP_DEFAULT_UPDATE_ADVERTISEMENT_TIME * \ - 1000), \ - (T)); \ - else \ - event_add_timer_msec(bm->master, (F), peer, 0, (T)); \ +#define BGP_UPDATE_GROUP_TIMER_ON(T, F) \ + do { \ + if (BGP_SUPPRESS_FIB_ENABLED(peer->bgp) && \ + PEER_ROUTE_ADV_DELAY(peer)) \ + event_add_timer_msec(bm->master, (F), connection, \ + (BGP_DEFAULT_UPDATE_ADVERTISEMENT_TIME * \ + 1000), \ + (T)); \ + else \ + event_add_timer_msec(bm->master, (F), connection, 0, \ + (T)); \ } while (0) #define BGP_MSEC_JITTER 10 @@ -107,11 +108,12 @@ enum bgp_fsm_state_progress { */ extern void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops); extern void bgp_event(struct event *event); -extern int bgp_event_update(struct peer *, enum bgp_fsm_events event); +extern int bgp_event_update(struct peer_connection *connection, + enum bgp_fsm_events event); extern enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection); extern void bgp_timer_set(struct peer_connection *connection); extern void bgp_routeadv_timer(struct event *event); -extern void bgp_fsm_change_status(struct peer *peer, +extern void bgp_fsm_change_status(struct peer_connection *connection, enum bgp_fsm_status status); extern const char *const peer_down_str[]; extern void bgp_update_delay_end(struct bgp *); diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 13007872d..b07e69ac3 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -360,7 +360,7 @@ static uint16_t bgp_write(struct peer_connection *connection) if (num < 0) { if (!ERRNO_IO_RETRY(errno)) { - BGP_EVENT_ADD(peer, TCP_fatal_error); + BGP_EVENT_ADD(connection, TCP_fatal_error); SET_FLAG(status, BGP_IO_FATAL_ERR); } else { SET_FLAG(status, BGP_IO_TRANS_ERR); @@ -437,7 +437,7 @@ static uint16_t bgp_write(struct peer_connection *connection) * Handle Graceful Restart case where the state changes * to Connect instead of Idle. */ - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(connection, BGP_Stop); goto done; case BGP_MSG_KEEPALIVE: diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 550407eac..68e5dcc8c 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -435,18 +435,17 @@ static void bgp_accept(struct event *thread) if (CHECK_FLAG(peer1->flags, PEER_FLAG_TCP_MSS)) sockopt_tcp_mss_set(bgp_sock, peer1->tcp_mss); - bgp_fsm_change_status(peer1, Active); + bgp_fsm_change_status(peer1->connection, Active); EVENT_OFF(peer1->connection ->t_start); /* created in peer_create() */ if (peer_active(peer1)) { if (CHECK_FLAG(peer1->flags, PEER_FLAG_TIMER_DELAYOPEN)) - BGP_EVENT_ADD( - peer1, - TCP_connection_open_w_delay); + BGP_EVENT_ADD(peer1->connection, + TCP_connection_open_w_delay); else - BGP_EVENT_ADD(peer1, + BGP_EVENT_ADD(peer1->connection, TCP_connection_open); } @@ -568,7 +567,7 @@ static void bgp_accept(struct event *thread) vrf_bind(peer->bgp->vrf_id, bgp_sock, bgp_get_bound_name(peer)); } bgp_peer_reg_with_nht(peer); - bgp_fsm_change_status(peer, Active); + bgp_fsm_change_status(peer->connection, Active); EVENT_OFF(peer->connection->t_start); /* created in peer_create() */ SET_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER); @@ -588,14 +587,15 @@ static void bgp_accept(struct event *thread) PEER_FLAG_GRACEFUL_RESTART_HELPER)) SET_FLAG(peer1->sflags, PEER_STATUS_NSF_WAIT); - bgp_event_update(peer1, TCP_connection_closed); + bgp_event_update(peer1->connection, TCP_connection_closed); } if (peer_active(peer)) { if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER_DELAYOPEN)) - BGP_EVENT_ADD(peer, TCP_connection_open_w_delay); + BGP_EVENT_ADD(peer->connection, + TCP_connection_open_w_delay); else - BGP_EVENT_ADD(peer, TCP_connection_open); + BGP_EVENT_ADD(peer->connection, TCP_connection_open); } /* diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index b3360cf97..e0f22ad4a 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -414,8 +414,9 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc) !peer_established(peer->connection) && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) { if (peer_active(peer)) - BGP_EVENT_ADD(peer, BGP_Stop); - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, + BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Start); } } } else if (addr->family == AF_INET6) { diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 39e70c59c..ffbf37f2f 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -146,7 +146,7 @@ static void bgp_packet_add(struct peer *peer, struct stream *s) EC_BGP_SENDQ_STUCK_PROPER, "%pBP has not made any SendQ progress for 2 holdtimes (%jds), terminating session", peer, sendholdtime); - BGP_EVENT_ADD(peer, TCP_fatal_error); + BGP_EVENT_ADD(peer->connection, TCP_fatal_error); } else if (delta > (intmax_t)holdtime && monotime(NULL) - peer->last_sendq_warn > 5) { flog_warn( @@ -391,6 +391,7 @@ static void bgp_write_proceed_actions(struct peer *peer) struct bpacket *next_pkt; struct update_subgroup *subgrp; enum bgp_af_index index; + struct peer_connection *connection = peer->connection; for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { paf = peer->peer_af_array[index]; @@ -403,7 +404,7 @@ static void bgp_write_proceed_actions(struct peer *peer) next_pkt = paf->next_pkt_to_send; if (next_pkt && next_pkt->buffer) { - BGP_TIMER_ON(peer->connection->t_generate_updgrp_packets, + BGP_TIMER_ON(connection->t_generate_updgrp_packets, bgp_generate_updgrp_packets, 0); return; } @@ -414,7 +415,7 @@ static void bgp_write_proceed_actions(struct peer *peer) if (bpacket_queue_is_full(SUBGRP_INST(subgrp), SUBGRP_PKTQ(subgrp)) || subgroup_packets_to_build(subgrp)) { - BGP_TIMER_ON(peer->connection->t_generate_updgrp_packets, + BGP_TIMER_ON(connection->t_generate_updgrp_packets, bgp_generate_updgrp_packets, 0); return; } @@ -429,8 +430,7 @@ static void bgp_write_proceed_actions(struct peer *peer) && !CHECK_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_EOR_SEND) && safi != SAFI_MPLS_VPN) { - BGP_TIMER_ON(peer->connection - ->t_generate_updgrp_packets, + BGP_TIMER_ON(connection->t_generate_updgrp_packets, bgp_generate_updgrp_packets, 0); return; } @@ -445,8 +445,8 @@ static void bgp_write_proceed_actions(struct peer *peer) */ void bgp_generate_updgrp_packets(struct event *thread) { - struct peer *peer = EVENT_ARG(thread); - + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; struct stream *s; struct peer_af *paf; struct bpacket *next_pkt; @@ -478,7 +478,7 @@ void bgp_generate_updgrp_packets(struct event *thread) * let's stop adding to the outq if we are * already at the limit. */ - if (peer->connection->obuf->count >= bm->outq_limit) { + if (connection->obuf->count >= bm->outq_limit) { bgp_write_proceed_actions(peer); return; } @@ -606,10 +606,10 @@ void bgp_generate_updgrp_packets(struct event *thread) bpacket_queue_advance_peer(paf); } } while (s && (++generated < wpq) && - (peer->connection->obuf->count <= bm->outq_limit)); + (connection->obuf->count <= bm->outq_limit)); if (generated) - bgp_writes_on(peer->connection); + bgp_writes_on(connection); bgp_write_proceed_actions(peer); } @@ -749,7 +749,7 @@ static void bgp_write_notify(struct peer *peer) */ if (ret <= 0) { stream_free(s); - BGP_EVENT_ADD(peer, TCP_fatal_error); + BGP_EVENT_ADD(peer->connection, TCP_fatal_error); return; } @@ -778,7 +778,7 @@ static void bgp_write_notify(struct peer *peer) * Handle Graceful Restart case where the state changes to * Connect instead of Idle */ - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); stream_free(s); } @@ -3299,7 +3299,7 @@ void bgp_process_packet(struct event *thread) /* Update FSM */ if (mprc != BGP_PACKET_NOOP) - fsm_update_result = bgp_event_update(peer, mprc); + fsm_update_result = bgp_event_update(connection, mprc); else continue; @@ -3366,5 +3366,5 @@ void bgp_packet_process_error(struct event *thread) peer->last_reset = PEER_DOWN_CLOSE_SESSION; } - bgp_event_update(peer, code); + bgp_event_update(connection, code); } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 643dc85de..0ae621071 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3724,9 +3724,8 @@ void bgp_add_eoiu_mark(struct bgp *bgp) static void bgp_maximum_prefix_restart_timer(struct event *thread) { - struct peer *peer; - - peer = EVENT_ARG(thread); + struct peer_connection *connection = EVENT_ARG(thread); + struct peer *peer = connection->peer; if (bgp_debug_neighbor_events(peer)) zlog_debug( @@ -3784,6 +3783,7 @@ bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi, ? bgp_filtered_routes_count(peer, afi, safi) + peer->pcount[afi][safi] : peer->pcount[afi][safi]; + struct peer_connection *connection = peer->connection; if (!CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) return false; @@ -3819,8 +3819,7 @@ bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi, ndata[6] = (peer->pmax[afi][safi]); SET_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); - bgp_notify_send_with_data(peer->connection, - BGP_NOTIFY_CEASE, + bgp_notify_send_with_data(connection, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); } @@ -3839,7 +3838,7 @@ bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi, "%pBP Maximum-prefix restart timer started for %d secs", peer, peer->v_pmax_restart); - BGP_TIMER_ON(peer->connection->t_pmax_restart, + BGP_TIMER_ON(connection->t_pmax_restart, bgp_maximum_prefix_restart_timer, peer->v_pmax_restart); } @@ -5589,7 +5588,7 @@ static void bgp_clear_node_complete(struct work_queue *wq) struct peer *peer = wq->spec.data; /* Tickle FSM to start moving again */ - BGP_EVENT_ADD(peer, Clearing_Completed); + BGP_EVENT_ADD(peer->connection, Clearing_Completed); peer_unlock(peer); /* bgp_clear_route */ } diff --git a/bgpd/bgp_snmp_bgp4.c b/bgpd/bgp_snmp_bgp4.c index 8a1b57f22..0d5b06da1 100644 --- a/bgpd/bgp_snmp_bgp4.c +++ b/bgpd/bgp_snmp_bgp4.c @@ -173,6 +173,7 @@ static int write_bgpPeerTable(int action, uint8_t *var_val, { struct in_addr addr; struct peer *peer; + struct peer_connection *connection; long intval; if (var_val_type != ASN_INTEGER) { @@ -190,6 +191,8 @@ static int write_bgpPeerTable(int action, uint8_t *var_val, if (!peer) return SNMP_ERR_NOSUCHNAME; + connection = peer->connection; + if (action != SNMP_MSG_INTERNAL_SET_COMMIT) return SNMP_ERR_NOERROR; @@ -202,7 +205,7 @@ static int write_bgpPeerTable(int action, uint8_t *var_val, #define BGP_PeerAdmin_start 2 /* When the peer is established, */ if (intval == BGP_PeerAdmin_stop) - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(connection, BGP_Stop); else if (intval == BGP_PeerAdmin_start) ; /* Do nothing. */ else diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 00c7fcd5a..77192b42b 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -2205,9 +2205,8 @@ void subgroup_trigger_write(struct update_subgroup *subgrp) if (peer_established(connection)) event_add_timer_msec(bm->master, bgp_generate_updgrp_packets, - paf->peer, 0, - &paf->peer->connection - ->t_generate_updgrp_packets); + connection, 0, + &connection->t_generate_updgrp_packets); } } diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index ba81f20dc..ccbb23ebb 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -384,9 +384,11 @@ static void subgroup_coalesce_timer(struct event *thread) SUBGRP_FOREACH_PEER (subgrp, paf) { peer = PAF_PEER(paf); - EVENT_OFF(peer->connection->t_routeadv); - BGP_TIMER_ON(peer->connection->t_routeadv, - bgp_routeadv_timer, 0); + struct peer_connection *connection = peer->connection; + + EVENT_OFF(connection->t_routeadv); + BGP_TIMER_ON(connection->t_routeadv, bgp_routeadv_timer, + 0); } } } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 1020e4330..3d993e12c 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -143,8 +143,8 @@ static void bgp_start_interface_nbrs(struct bgp *bgp, struct interface *ifp) if (peer->conf_if && (strcmp(peer->conf_if, ifp->name) == 0) && !peer_established(peer->connection)) { if (peer_active(peer)) - BGP_EVENT_ADD(peer, BGP_Stop); - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Start); } } } @@ -183,7 +183,7 @@ static void bgp_nbr_connected_delete(struct bgp *bgp, struct nbr_connected *ifc, if (peer->conf_if && (strcmp(peer->conf_if, ifc->ifp->name) == 0)) { peer->last_reset = PEER_DOWN_NBR_ADDR_DEL; - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); } } /* Free neighbor also, if we're asked to. */ @@ -279,7 +279,7 @@ static int bgp_ifp_down(struct interface *ifp) continue; if (ifp == peer->nexthop.ifp) { - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); peer->last_reset = PEER_DOWN_IF_DOWN; } } @@ -515,7 +515,8 @@ static int bgp_interface_vrf_update(ZAPI_CALLBACK_ARGS) continue; if (ifp == peer->nexthop.ifp) - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, + BGP_Stop); } } } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 1e83a1fb7..278ab40e1 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -140,7 +140,7 @@ void bgp_session_reset(struct peer *peer) !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE))) peer_delete(peer->doppelganger); - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); } /* @@ -166,7 +166,7 @@ static void bgp_session_reset_safe(struct peer *peer, struct listnode **nnode) peer_delete(peer->doppelganger); } - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); } /* BGP global flag manipulation. */ @@ -1208,12 +1208,12 @@ static void peer_free(struct peer *peer) bgp_timer_set(peer->connection); bgp_reads_off(peer->connection); bgp_writes_off(peer->connection); - event_cancel_event_ready(bm->master, peer); + event_cancel_event_ready(bm->master, peer->connection); FOREACH_AFI_SAFI (afi, safi) EVENT_OFF(peer->t_revalidate_all[afi][safi]); assert(!peer->connection->t_write); assert(!peer->connection->t_read); - event_cancel_event_ready(bm->master, peer); + event_cancel_event_ready(bm->master, peer->connection); /* Free connected nexthop, if present */ if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE) @@ -2591,7 +2591,7 @@ int peer_delete(struct peer *peer) bgp_keepalives_off(peer->connection); bgp_reads_off(peer->connection); bgp_writes_off(peer->connection); - event_cancel_event_ready(bm->master, peer); + event_cancel_event_ready(bm->master, peer->connection); FOREACH_AFI_SAFI (afi, safi) EVENT_OFF(peer->t_revalidate_all[afi][safi]); assert(!CHECK_FLAG(peer->connection->thread_flags, @@ -2637,7 +2637,7 @@ int peer_delete(struct peer *peer) } UNSET_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER); - bgp_fsm_change_status(peer, Deleted); + bgp_fsm_change_status(peer->connection, Deleted); /* Remove from NHT */ if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) @@ -3734,7 +3734,7 @@ void bgp_instance_up(struct bgp *bgp) /* Kick off any peers that may have been configured. */ for (ALL_LIST_ELEMENTS(bgp->peer, node, next, peer)) { if (!BGP_PEER_START_SUPPRESSED(peer)) - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Start); } /* Process any networks that have been configured. */ @@ -4642,7 +4642,7 @@ static void peer_flag_modify_action(struct peer *peer, uint64_t flag) bgp_session_reset(peer); } else { peer->v_start = BGP_INIT_START_TIMER; - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); } } else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status)) { if (flag == PEER_FLAG_DYNAMIC_CAPABILITY) @@ -4706,7 +4706,7 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg) peer->v_start = BGP_INIT_START_TIMER; /* trigger a RFC 4271 ManualStop event */ - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); } /* set the BGP instances shutdown flag */ @@ -5992,8 +5992,8 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect) if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { if (!peer_established(peer->connection)) { if (peer_active(peer)) - BGP_EVENT_ADD(peer, BGP_Stop); - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Start); } return 0; } @@ -6013,8 +6013,8 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect) if (!peer_established(member->connection)) { if (peer_active(member)) - BGP_EVENT_ADD(member, BGP_Stop); - BGP_EVENT_ADD(member, BGP_Start); + BGP_EVENT_ADD(member->connection, BGP_Stop); + BGP_EVENT_ADD(member->connection, BGP_Start); } } @@ -6046,8 +6046,8 @@ int peer_timers_connect_unset(struct peer *peer) if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { if (!peer_established(peer->connection)) { if (peer_active(peer)) - BGP_EVENT_ADD(peer, BGP_Stop); - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Start); } return 0; } @@ -6067,8 +6067,8 @@ int peer_timers_connect_unset(struct peer *peer) if (!peer_established(member->connection)) { if (peer_active(member)) - BGP_EVENT_ADD(member, BGP_Stop); - BGP_EVENT_ADD(member, BGP_Start); + BGP_EVENT_ADD(member->connection, BGP_Stop); + BGP_EVENT_ADD(member->connection, BGP_Start); } } @@ -6505,7 +6505,7 @@ int peer_local_as_unset(struct peer *peer) bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else - BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Stop); /* Skip peer-group mechanics for regular peers. */ return 0; @@ -7554,7 +7554,7 @@ static bool peer_maximum_prefix_clear_overflow(struct peer *peer) "%pBP Maximum-prefix restart timer cancelled", peer); } - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Start); return true; } @@ -8325,8 +8325,8 @@ static int peer_unshut_after_cfg(struct bgp *bgp) if (peer_active(peer) && peer->connection->status != Established) { if (peer->connection->status != Idle) - BGP_EVENT_ADD(peer, BGP_Stop); - BGP_EVENT_ADD(peer, BGP_Start); + BGP_EVENT_ADD(peer->connection, BGP_Stop); + BGP_EVENT_ADD(peer->connection, BGP_Start); } } |