diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2021-06-03 17:13:52 -0400 | 
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2023-08-18 09:29:04 -0400 | 
| commit | e20c23fa5b06f1dcef4e99df5099e55251d9d9bd (patch) | |
| tree | 778b6c5e4e80c6970f0a1973ae7c597c20631552 /bgpd | |
| parent | 71d72c4998d6984e43411535eaa2a5b8c0e33d06 (diff) | |
bgpd: Move status and ostatus to `struct peer_connection`
The status and ostatus are a function of the `struct peer_connection`
move it into that data structure.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bgpd')
| -rw-r--r-- | bgpd/bgp_bfd.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_bmp.c | 8 | ||||
| -rw-r--r-- | bgpd/bgp_dump.c | 4 | ||||
| -rw-r--r-- | bgpd/bgp_evpn.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_fsm.c | 79 | ||||
| -rw-r--r-- | bgpd/bgp_fsm.h | 11 | ||||
| -rw-r--r-- | bgpd/bgp_io.c | 4 | ||||
| -rw-r--r-- | bgpd/bgp_network.c | 12 | ||||
| -rw-r--r-- | bgpd/bgp_packet.c | 39 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 12 | ||||
| -rw-r--r-- | bgpd/bgp_script.c | 3 | ||||
| -rw-r--r-- | bgpd/bgp_snmp_bgp4.c | 5 | ||||
| -rw-r--r-- | bgpd/bgp_snmp_bgp4v2.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_vty.c | 36 | ||||
| -rw-r--r-- | bgpd/bgpd.c | 134 | ||||
| -rw-r--r-- | bgpd/bgpd.h | 10 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 2 | 
18 files changed, 195 insertions, 172 deletions
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index d1ddfd0460..598368ae66 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -56,7 +56,7 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,  		peer->last_reset = PEER_DOWN_BFD_DOWN;  		/* rfc9384 */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_BFD_DOWN); diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index baf164679c..4d604addda 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -703,7 +703,7 @@ static int bmp_peer_status_changed(struct peer *peer)  	if (!bmpbgp)  		return 0; -	if (peer->status == Deleted) { +	if (peer->connection.status == Deleted) {  		bbpeer = bmp_bgp_peer_find(peer->qobj_node.nid);  		if (bbpeer) {  			XFREE(MTYPE_BMP_OPEN, bbpeer->open_rx); @@ -715,10 +715,12 @@ static int bmp_peer_status_changed(struct peer *peer)  	}  	/* Check if this peer just went to Established */ -	if ((peer->ostatus != OpenConfirm) || !(peer_established(peer))) +	if ((peer->connection.ostatus != OpenConfirm) || +	    !(peer_established(peer)))  		return 0; -	if (peer->doppelganger && (peer->doppelganger->status != Deleted)) { +	if (peer->doppelganger && +	    (peer->doppelganger->connection.status != Deleted)) {  		bbpeer = bmp_bgp_peer_get(peer);  		bbdopp = bmp_bgp_peer_find(peer->doppelganger->qobj_node.nid);  		if (bbdopp) { diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index fe77e7e250..489b3c6587 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -512,8 +512,8 @@ int bgp_dump_state(struct peer *peer)  			bgp_dump_all.type);  	bgp_dump_common(obuf, peer, 1); /* force this in as4speak*/ -	stream_putw(obuf, peer->ostatus); -	stream_putw(obuf, peer->status); +	stream_putw(obuf, peer->connection.ostatus); +	stream_putw(obuf, peer->connection.status);  	/* Set length. */  	bgp_dump_set_size(obuf, MSG_PROTOCOL_BGP4MP); diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 3442eee1e1..ef62799940 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -6462,7 +6462,7 @@ void bgp_reimport_evpn_routes_upon_martian_change(  		if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))  			continue; -		if (peer->status != Established) +		if (peer->connection.status != Established)  			continue;  		if (CHECK_FLAG(peer->af_flags[afi][safi], diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 20a5c4ce33..b951ada196 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -233,16 +233,16 @@ 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->status; -	pstatus = peer->ostatus; +	status = peer->connection.status; +	pstatus = peer->connection.ostatus;  	last_evt = peer->last_event;  	last_maj_evt = peer->last_major_event; -	peer->status = from_peer->status; -	peer->ostatus = from_peer->ostatus; +	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->status = status; -	from_peer->ostatus = pstatus; +	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; @@ -310,7 +310,7 @@ static struct peer *peer_xfer_conn(struct peer *from_peer)  		BGP_EVENT_ADD(from_peer, BGP_Stop);  		return NULL;  	} -	if (from_peer->status > Active) { +	if (from_peer->connection.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)", @@ -354,7 +354,7 @@ void bgp_timer_set(struct peer *peer)  	afi_t afi;  	safi_t safi; -	switch (peer->status) { +	switch (peer->connection.status) {  	case Idle:  		/* First entry point of peer's finite state machine.  In Idle  		   status start timer is on unless peer is shutdown or peer is @@ -1225,8 +1225,8 @@ static void bgp_update_delay_process_status_change(struct peer *peer)  		if (CHECK_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV))  			bgp_update_restarted_peers(peer);  	} -	if (peer->ostatus == Established -	    && bgp_update_delay_active(peer->bgp)) { +	if (peer->connection.ostatus == Established && +	    bgp_update_delay_active(peer->bgp)) {  		/* Adjust the update-delay state to account for this flap.  		   NOTE: Intentionally skipping adjusting implicit_eors or  		   explicit_eors @@ -1302,14 +1302,15 @@ void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status)  	}  	/* Preserve old status and change into new status. */ -	peer->ostatus = peer->status; -	peer->status = status; +	peer->connection.ostatus = peer->connection.status; +	peer->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->ostatus == Established && peer->status != Established) +	if (peer->connection.ostatus == Established && +	    peer->connection.status != Established)  		hook_call(peer_backward_transition, peer);  	/* Save event that caused status change. */ @@ -1338,8 +1339,10 @@ 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->ostatus, NULL), -			   lookup_msg(bgp_status_msg, peer->status, NULL)); +			   lookup_msg(bgp_status_msg, peer->connection.ostatus, +				      NULL), +			   lookup_msg(bgp_status_msg, peer->connection.status, +				      NULL));  }  /* Flush the event queue and ensure the peer is shut down */ @@ -1381,7 +1384,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)  	}  	/* Can't do this in Clearing; events are used for state transitions */ -	if (peer->status != Clearing) { +	if (peer->connection.status != Clearing) {  		/* Delete all existing events of the peer */  		BGP_EVENT_FLUSH(peer);  	} @@ -1556,7 +1559,8 @@ enum bgp_fsm_state_progress bgp_stop(struct peer *peer)  		/* Received ORF prefix-filter */  		peer->orf_plist[afi][safi] = NULL; -		if ((peer->status == OpenConfirm) || (peer_established(peer))) { +		if ((peer->connection.status == OpenConfirm) || +		    peer_established(peer)) {  			/* ORF received prefix-filter pnt */  			snprintf(orf_name, sizeof(orf_name), "%s.%d.%d",  				 peer->host, afi, safi); @@ -1711,7 +1715,7 @@ static enum bgp_fsm_state_progress bgp_connect_success(struct peer *peer)  			     "%s: bgp_getsockname(): failed for peer %s, fd %d",  			     __func__, peer->host, peer->connection.fd);  		bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, -				bgp_fsm_error_subcode(peer->status)); +				bgp_fsm_error_subcode(peer->connection.status));  		bgp_writes_on(&peer->connection);  		return BGP_FSM_FAILURE;  	} @@ -1755,7 +1759,7 @@ bgp_connect_success_w_delayopen(struct peer *peer)  			     "%s: bgp_getsockname(): failed for peer %s, fd %d",  			     __func__, peer->host, peer->connection.fd);  		bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, -				bgp_fsm_error_subcode(peer->status)); +				bgp_fsm_error_subcode(peer->connection.status));  		bgp_writes_on(&peer->connection);  		return BGP_FSM_FAILURE;  	} @@ -1965,7 +1969,8 @@ static enum bgp_fsm_state_progress bgp_reconnect(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)) +	if ((peer->connection.status == Connect) || +	    (peer->connection.status == Active))  		bgp_open_send(peer);  	/* Send keepalive and make keepalive timer */ @@ -1979,10 +1984,12 @@ static enum bgp_fsm_state_progress bgp_fsm_open(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)); +		 peer->host, +		 lookup_msg(bgp_status_msg, peer->connection.status, NULL));  	return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR, -				    bgp_fsm_error_subcode(peer->status)); +				    bgp_fsm_error_subcode( +					    peer->connection.status));  }  /* Hold timer expire.  This is error of BGP connection. So cut the @@ -2288,13 +2295,14 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)  		BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);  	} -	if (peer->doppelganger && (peer->doppelganger->status != Deleted)) { +	if (peer->doppelganger && +	    (peer->doppelganger->connection.status != Deleted)) {  		if (bgp_debug_neighbor_events(peer))  			zlog_debug(  				"[Event] Deleting stub connection for peer %s",  				peer->host); -		if (peer->doppelganger->status > Active) +		if (peer->doppelganger->connection.status > Active)  			bgp_notify_send(peer->doppelganger, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);  		else @@ -2336,7 +2344,7 @@ static enum bgp_fsm_state_progress bgp_ignore(struct peer *peer)  	flog_err(EC_BGP_FSM,  		 "%s [FSM] Ignoring event %s in state %s, prior events %s, %s, fd %d",  		 peer->host, bgp_event_str[peer->cur_event], -		 lookup_msg(bgp_status_msg, peer->status, NULL), +		 lookup_msg(bgp_status_msg, peer->connection.status, NULL),  		 bgp_event_str[peer->last_event],  		 bgp_event_str[peer->last_major_event], peer->connection.fd);  	return BGP_FSM_SUCCESS; @@ -2348,7 +2356,7 @@ static enum bgp_fsm_state_progress bgp_fsm_exception(struct peer *peer)  	flog_err(EC_BGP_FSM,  		 "%s [FSM] Unexpected event %s in state %s, prior events %s, %s, fd %d",  		 peer->host, bgp_event_str[peer->cur_event], -		 lookup_msg(bgp_status_msg, peer->status, NULL), +		 lookup_msg(bgp_status_msg, peer->connection.status, NULL),  		 bgp_event_str[peer->last_event],  		 bgp_event_str[peer->last_major_event], peer->connection.fd);  	return bgp_stop(peer); @@ -2359,7 +2367,7 @@ void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops)  	if (!peer)  		return; -	switch (peer->status) { +	switch (peer->connection.status) {  	case Idle:  		if (has_valid_nexthops)  			BGP_EVENT_ADD(peer, BGP_Start); @@ -2588,12 +2596,13 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)  	dyn_nbr = peer_dynamic_neighbor(peer);  	/* Logging this event. */ -	next = FSM[peer->status - 1][event - 1].next_state; +	next = FSM[peer->connection.status - 1][event - 1].next_state; -	if (bgp_debug_neighbor_events(peer) && peer->status != next) +	if (bgp_debug_neighbor_events(peer) && 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->status, NULL), +			   lookup_msg(bgp_status_msg, peer->connection.status, +				      NULL),  			   lookup_msg(bgp_status_msg, next, NULL),  			   peer->connection.fd); @@ -2601,8 +2610,9 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)  	peer->cur_event = event;  	/* Call function. */ -	if (FSM[peer->status - 1][event - 1].func) -		ret = (*(FSM[peer->status - 1][event - 1].func))(peer); +	if (FSM[peer->connection.status - 1][event - 1].func) +		ret = (*(FSM[peer->connection.status - 1][event - 1].func))( +			peer);  	if (ret >= BGP_FSM_SUCCESS) {  		if (ret == BGP_FSM_SUCCESS_STATE_TRANSFER && @@ -2615,7 +2625,7 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)  		}  		/* If status is changed. */ -		if (next != peer->status) { +		if (next != peer->connection.status) {  			bgp_fsm_change_status(peer, next);  			/* @@ -2645,7 +2655,8 @@ int bgp_event_update(struct peer *peer, enum bgp_fsm_events event)  			flog_err(EC_BGP_FSM,  				 "%s [FSM] Failure handling event %s in state %s, prior events %s, %s, fd %d, last reset: %s",  				 peer->host, bgp_event_str[peer->cur_event], -				 lookup_msg(bgp_status_msg, peer->status, NULL), +				 lookup_msg(bgp_status_msg, +					    peer->connection.status, NULL),  				 bgp_event_str[peer->last_event],  				 bgp_event_str[peer->last_major_event],  				 peer->connection.fd, diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index daf31b266e..547897de39 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -17,15 +17,14 @@ enum bgp_fsm_state_progress {  /* Macro for BGP read, write and timer thread.  */  #define BGP_TIMER_ON(T, F, V)                                                  \  	do {                                                                   \ -		if ((peer->status != Deleted))                                 \ +		if ((peer->connection.status != Deleted))                      \  			event_add_timer(bm->master, (F), peer, (V), &(T));     \  	} while (0) -#define BGP_EVENT_ADD(P, E)                                                    \ -	do {                                                                   \ -		if ((P)->status != Deleted)                                    \ -			event_add_event(bm->master, bgp_event, (P), (E),       \ -					NULL);                                 \ +#define BGP_EVENT_ADD(P, E)                                                     \ +	do {                                                                    \ +		if ((P)->connection.status != Deleted)                          \ +			event_add_event(bm->master, bgp_event, (P), (E), NULL); \  	} while (0)  #define BGP_EVENT_FLUSH(P)                                                     \ diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 25180ee53e..5b7d234f9d 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -49,7 +49,7 @@ void bgp_writes_on(struct peer_connection *connection)  	assert(fpt->running); -	assert(peer->status != Deleted); +	assert(connection->status != Deleted);  	assert(connection->obuf);  	assert(connection->ibuf);  	assert(connection->ibuf_work); @@ -80,7 +80,7 @@ void bgp_reads_on(struct peer_connection *connection)  	struct frr_pthread *fpt = bgp_pth_io;  	assert(fpt->running); -	assert(peer->status != Deleted); +	assert(connection->status != Deleted);  	assert(connection->ibuf);  	assert(connection->fd);  	assert(connection->ibuf_work); diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 9a162b151e..6a3b4e8c87 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -482,11 +482,11 @@ static void bgp_accept(struct event *thread)  	 * Established and then the Clearing_Completed event is generated. Also,  	 * block incoming connection in Deleted state.  	 */ -	if (peer1->status == Clearing || peer1->status == Deleted) { +	if (peer1->connection.status == Clearing || +	    peer1->connection.status == Deleted) {  		if (bgp_debug_neighbor_events(peer1)) -			zlog_debug( -				"[Event] Closing incoming conn for %s (%p) state %d", -				peer1->host, peer1, peer1->status); +			zlog_debug("[Event] Closing incoming conn for %s (%p) state %d", +				   peer1->host, peer1, peer1->connection.status);  		close(bgp_sock);  		return;  	} @@ -522,8 +522,8 @@ static void bgp_accept(struct event *thread)  	if (bgp_debug_neighbor_events(peer1))  		zlog_debug("[Event] connection from %s fd %d, active peer status %d fd %d", -			   inet_sutop(&su, buf), bgp_sock, peer1->status, -			   peer1->connection.fd); +			   inet_sutop(&su, buf), bgp_sock, +			   peer1->connection.status, peer1->connection.fd);  	if (peer1->doppelganger) {  		/* We have an existing connection. Kill the existing one and run diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index cd822fb32c..e13d1fd937 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1326,13 +1326,14 @@ static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)  	 * states. Note that a peer GR is handled by closing the existing  	 * connection upon receipt of new one.  	 */ -	if (peer_established(peer) || peer->status == Clearing) { +	if (peer_established(peer) || peer->connection.status == Clearing) {  		bgp_notify_send(new, BGP_NOTIFY_CEASE,  				BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);  		return -1;  	} -	if ((peer->status != OpenConfirm) && (peer->status != OpenSent)) +	if ((peer->connection.status != OpenConfirm) && +	    (peer->connection.status != OpenSent))  		return 0;  	/* @@ -1413,7 +1414,7 @@ static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)   * Side effects   * ------------   * - May send NOTIFY messages - * - May not modify peer->status + * - May not modify peer->connection.status   * - May not call bgp_event_update()   */ @@ -1921,9 +1922,10 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)  		flog_err(EC_BGP_INVALID_STATUS,  			 "%s [FSM] Update packet received under status %s",  			 peer->host, -			 lookup_msg(bgp_status_msg, peer->status, NULL)); +			 lookup_msg(bgp_status_msg, peer->connection.status, +				    NULL));  		bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, -				bgp_fsm_error_subcode(peer->status)); +				bgp_fsm_error_subcode(peer->connection.status));  		return BGP_Stop;  	} @@ -2369,13 +2371,13 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)  	/* Status must be Established. */  	if (!peer_established(peer)) { -		flog_err( -			EC_BGP_INVALID_STATUS, -			"%s [Error] Route refresh packet received under status %s", -			peer->host, -			lookup_msg(bgp_status_msg, peer->status, NULL)); +		flog_err(EC_BGP_INVALID_STATUS, +			 "%s [Error] Route refresh packet received under status %s", +			 peer->host, +			 lookup_msg(bgp_status_msg, peer->connection.status, +				    NULL));  		bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, -				bgp_fsm_error_subcode(peer->status)); +				bgp_fsm_error_subcode(peer->connection.status));  		return BGP_Stop;  	} @@ -2957,13 +2959,13 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size)  	/* Status must be Established. */  	if (!peer_established(peer)) { -		flog_err( -			EC_BGP_NO_CAP, -			"%s [Error] Dynamic capability packet received under status %s", -			peer->host, -			lookup_msg(bgp_status_msg, peer->status, NULL)); +		flog_err(EC_BGP_NO_CAP, +			 "%s [Error] Dynamic capability packet received under status %s", +			 peer->host, +			 lookup_msg(bgp_status_msg, peer->connection.status, +				    NULL));  		bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, -				bgp_fsm_error_subcode(peer->status)); +				bgp_fsm_error_subcode(peer->connection.status));  		return BGP_Stop;  	} @@ -3001,7 +3003,8 @@ void bgp_process_packet(struct event *thread)  	fsm_update_result = 0;  	/* Guard against scheduled events that occur after peer deletion. */ -	if (peer->status == Deleted || peer->status == Clearing) +	if (peer->connection.status == Deleted || +	    peer->connection.status == Clearing)  		return;  	unsigned int processed = 0; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 3b3cbb28a9..a91292d971 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2754,13 +2754,11 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,  						continue;  					if (BGP_PATH_HOLDDOWN(pi2))  						continue; -					if (pi2->peer != bgp->peer_self -					    && !CHECK_FLAG( -						    pi2->peer->sflags, -						    PEER_STATUS_NSF_WAIT)) -						if (pi2->peer->status -						    != Established) -							continue; +					if (pi2->peer != bgp->peer_self && +					    !CHECK_FLAG(pi2->peer->sflags, +							PEER_STATUS_NSF_WAIT) && +					    !peer_established(pi2->peer)) +						continue;  					if (!aspath_cmp_left(pi1->attr->aspath,  							     pi2->attr->aspath) diff --git a/bgpd/bgp_script.c b/bgpd/bgp_script.c index 68df175c18..fe075f37b0 100644 --- a/bgpd/bgp_script.c +++ b/bgpd/bgp_script.c @@ -26,7 +26,8 @@ void lua_pushpeer(lua_State *L, const struct peer *peer)  	lua_setfield(L, -2, "remote_id");  	lua_pushinaddr(L, &peer->local_id);  	lua_setfield(L, -2, "local_id"); -	lua_pushstring(L, lookup_msg(bgp_status_msg, peer->status, NULL)); +	lua_pushstring(L, lookup_msg(bgp_status_msg, peer->connection.status, +				     NULL));  	lua_setfield(L, -2, "state");  	lua_pushstring(L, peer->desc ? peer->desc : "");  	lua_setfield(L, -2, "description"); diff --git a/bgpd/bgp_snmp_bgp4.c b/bgpd/bgp_snmp_bgp4.c index 123d33bd14..4f90907d28 100644 --- a/bgpd/bgp_snmp_bgp4.c +++ b/bgpd/bgp_snmp_bgp4.c @@ -251,7 +251,7 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length,  	case BGPPEERIDENTIFIER:  		return SNMP_IPADDRESS(peer->remote_id);  	case BGPPEERSTATE: -		return SNMP_INTEGER(peer->status); +		return SNMP_INTEGER(peer->connection.status);  	case BGPPEERADMINSTATUS:  		*write_method = write_bgpPeerTable;  #define BGP_PeerAdmin_stop 1 @@ -756,7 +756,8 @@ int bgpTrapEstablished(struct peer *peer)  	oid index[sizeof(oid) * IN_ADDR_SIZE];  	/* Check if this peer just went to Established */ -	if ((peer->ostatus != OpenConfirm) || !(peer_established(peer))) +	if ((peer->connection.ostatus != OpenConfirm) || +	    !(peer_established(peer)))  		return 0;  	ret = inet_aton(peer->host, &addr); diff --git a/bgpd/bgp_snmp_bgp4v2.c b/bgpd/bgp_snmp_bgp4v2.c index 712b5d4af8..179970af11 100644 --- a/bgpd/bgp_snmp_bgp4v2.c +++ b/bgpd/bgp_snmp_bgp4v2.c @@ -265,7 +265,7 @@ static uint8_t *bgpv2PeerTable(struct variable *v, oid name[], size_t *length,  		else  			return SNMP_INTEGER(BGP_PEER_ADMIN_STATUS_RUNNING);  	case BGP4V2_PEER_STATE: -		return SNMP_INTEGER(peer->status); +		return SNMP_INTEGER(peer->connection.status);  	case BGP4V2_PEER_DESCRIPTION:  		if (peer->desc)  			return SNMP_STRING(peer->desc); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5b224c4c56..9086e8af76 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -2888,7 +2888,7 @@ DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd,  	 * with aspath containing AS_SET or AS_CONFED_SET.  	 */  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_AS_SETS_REJECT;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -2914,7 +2914,7 @@ DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd,  	 * with aspath containing AS_SET or AS_CONFED_SET.  	 */  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_AS_SETS_REJECT;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -4851,7 +4851,7 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,  			peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY);  		/* v6only flag changed. Reset bgp seesion */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5040,7 +5040,7 @@ DEFUN (no_neighbor,  			peer_notify_unconfig(peer);  			peer_delete(peer); -			if (other && other->status != Deleted) { +			if (other && other->connection.status != Deleted) {  				peer_notify_unconfig(other);  				peer_delete(other);  			} @@ -11791,7 +11791,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					json_object_string_add(  						json_peer, "state",  						lookup_msg(bgp_status_msg, -							   peer->status, NULL)); +							   peer->connection.status, +							   NULL));  				else if (CHECK_FLAG(  						 peer->sflags,  						 PEER_STATUS_PREFIX_OVERFLOW)) @@ -11802,7 +11803,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					json_object_string_add(  						json_peer, "state",  						lookup_msg(bgp_status_msg, -							   peer->status, NULL)); +							   peer->connection.status, +							   NULL));  				/* BGP peer state */  				if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) @@ -11997,7 +11999,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					else  						vty_out(vty, " %12s",  							lookup_msg(bgp_status_msg, -								   peer->status, NULL)); +								   peer->connection +									   .status, +								   NULL));  					vty_out(vty, " %8u", 0);  				} @@ -13577,9 +13581,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  						     "nbrCommonAdmin");  		/* Status. */ -		json_object_string_add( -			json_neigh, "bgpState", -			lookup_msg(bgp_status_msg, p->status, NULL)); +		json_object_string_add(json_neigh, "bgpState", +				       lookup_msg(bgp_status_msg, +						  p->connection.status, NULL));  		if (peer_established(p)) {  			time_t uptime; @@ -13597,9 +13601,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  			json_object_int_add(json_neigh,  					    "bgpTimerUpEstablishedEpoch",  					    epoch_tbuf); -		} - -		else if (p->status == Active) { +		} else if (p->connection.status == Active) {  			if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))  				json_object_string_add(json_neigh, "bgpStateIs",  						       "passive"); @@ -13705,14 +13707,13 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		/* Status. */  		vty_out(vty, "  BGP state = %s", -			lookup_msg(bgp_status_msg, p->status, NULL)); +			lookup_msg(bgp_status_msg, p->connection.status, NULL));  		if (peer_established(p))  			vty_out(vty, ", up for %8s",  				peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN,  					    0, NULL)); - -		else if (p->status == Active) { +		else if (p->connection.status == Active) {  			if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE))  				vty_out(vty, " (passive)");  			else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) @@ -16427,7 +16428,8 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group,  				peer_status = "Idle (PfxCt)";  			else  				peer_status = lookup_msg(bgp_status_msg, -							 peer->status, NULL); +							 peer->connection.status, +							 NULL);  			dynamic = peer_dynamic_neighbor(peer); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index a1d9184829..3b34f12e2a 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -134,8 +134,9 @@ static int bgp_check_main_socket(bool create, struct bgp *bgp)  void bgp_session_reset(struct peer *peer)  { -	if (peer->doppelganger && (peer->doppelganger->status != Deleted) -	    && !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE))) +	if (peer->doppelganger && +	    (peer->doppelganger->connection.status != Deleted) && +	    !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE)))  		peer_delete(peer->doppelganger);  	BGP_EVENT_ADD(peer, BGP_Stop); @@ -155,9 +156,9 @@ static void bgp_session_reset_safe(struct peer *peer, struct listnode **nnode)  	n = (nnode) ? *nnode : NULL;  	npeer = (n) ? listgetdata(n) : NULL; -	if (peer->doppelganger && (peer->doppelganger->status != Deleted) -	    && !(CHECK_FLAG(peer->doppelganger->flags, -			    PEER_FLAG_CONFIG_NODE))) { +	if (peer->doppelganger && +	    (peer->doppelganger->connection.status != Deleted) && +	    !(CHECK_FLAG(peer->doppelganger->flags, PEER_FLAG_CONFIG_NODE))) {  		if (peer->doppelganger == npeer)  			/* nnode and *nnode are confirmed to be non-NULL here */  			*nnode = (*nnode)->next; @@ -305,7 +306,7 @@ static int bgp_router_id_set(struct bgp *bgp, const struct in_addr *id,  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {  		IPV4_ADDR_COPY(&peer->local_id, id); -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_RID_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -484,7 +485,7 @@ void bgp_cluster_id_set(struct bgp *bgp, struct in_addr *cluster_id)  		if (peer->sort != BGP_PEER_IBGP)  			continue; -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_CLID_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -508,7 +509,7 @@ void bgp_cluster_id_unset(struct bgp *bgp)  		if (peer->sort != BGP_PEER_IBGP)  			continue; -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_CLID_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -581,7 +582,7 @@ void bgp_confederation_id_set(struct bgp *bgp, as_t as, const char *as_str)  			if (ptype == BGP_PEER_EBGP) {  				peer->local_as = as;  				if (BGP_IS_VALID_STATE_FOR_NOTIF( -					    peer->status)) { +					    peer->connection.status)) {  					peer->last_reset =  						PEER_DOWN_CONFED_ID_CHANGE;  					bgp_notify_send( @@ -599,7 +600,7 @@ void bgp_confederation_id_set(struct bgp *bgp, as_t as, const char *as_str)  				if (ptype == BGP_PEER_EBGP)  					peer->local_as = as;  				if (BGP_IS_VALID_STATE_FOR_NOTIF( -					    peer->status)) { +					    peer->connection.status)) {  					peer->last_reset =  						PEER_DOWN_CONFED_ID_CHANGE;  					bgp_notify_send( @@ -626,7 +627,8 @@ void bgp_confederation_id_unset(struct bgp *bgp)  		/* We're looking for peers who's AS is not local */  		if (peer_sort(peer) != BGP_PEER_IBGP) {  			peer->local_as = bgp->as; -			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +			if (BGP_IS_VALID_STATE_FOR_NOTIF( +				    peer->connection.status)) {  				peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE;  				bgp_notify_send(peer, BGP_NOTIFY_CEASE,  						BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -680,7 +682,7 @@ void bgp_confederation_peers_add(struct bgp *bgp, as_t as, const char *as_str)  				peer->local_as = bgp->as;  				(void)peer_sort(peer);  				if (BGP_IS_VALID_STATE_FOR_NOTIF( -					    peer->status)) { +					    peer->connection.status)) {  					peer->last_reset =  						PEER_DOWN_CONFED_PEER_CHANGE;  					bgp_notify_send( @@ -737,7 +739,7 @@ void bgp_confederation_peers_remove(struct bgp *bgp, as_t as)  				peer->local_as = bgp->confed_id;  				(void)peer_sort(peer);  				if (BGP_IS_VALID_STATE_FOR_NOTIF( -					    peer->status)) { +					    peer->connection.status)) {  					peer->last_reset =  						PEER_DOWN_CONFED_PEER_CHANGE;  					bgp_notify_send( @@ -1171,7 +1173,7 @@ static void peer_free(struct peer *peer)  	afi_t afi;  	safi_t safi; -	assert(peer->status == Deleted); +	assert(peer->connection.status == Deleted);  	QOBJ_UNREG(peer); @@ -1427,8 +1429,8 @@ struct peer *peer_new(struct bgp *bgp)  	/* Set default value. */  	peer->v_start = BGP_INIT_START_TIMER;  	peer->v_connect = bgp->default_connect_retry; -	peer->status = Idle; -	peer->ostatus = Idle; +	peer->connection.status = Idle; +	peer->connection.ostatus = Idle;  	peer->cur_event = peer->last_event = peer->last_major_event = 0;  	peer->bgp = bgp_lock(bgp);  	peer = peer_lock(peer); /* initial reference */ @@ -1944,7 +1946,7 @@ void peer_as_change(struct peer *peer, as_t as, int as_specified,  	/* Stop peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -2316,7 +2318,8 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi)  						BGP_NOTIFY_CEASE_CONFIG_CHANGE);  			}  		} -		if (peer->status == OpenSent || peer->status == OpenConfirm) { +		if (peer->connection.status == OpenSent || +		    peer->connection.status == OpenConfirm) {  			peer->last_reset = PEER_DOWN_AF_ACTIVATE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -2331,9 +2334,8 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi)  		 * activation.  		 */  		other = peer->doppelganger; -		if (other -		    && (other->status == OpenSent -			|| other->status == OpenConfirm)) { +		if (other && (other->connection.status == OpenSent || +			      other->connection.status == OpenConfirm)) {  			other->last_reset = PEER_DOWN_AF_ACTIVATE;  			bgp_notify_send(other, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -2554,7 +2556,7 @@ int peer_delete(struct peer *peer)  	struct listnode *pn;  	int accept_peer; -	assert(peer->status != Deleted); +	assert(peer->connection.status != Deleted);  	bgp = peer->bgp;  	accept_peer = CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER); @@ -2892,7 +2894,7 @@ int peer_group_remote_as(struct bgp *bgp, const char *group_name, as_t *as,  void peer_notify_unconfig(struct peer *peer)  { -	if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +	if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  		bgp_notify_send(peer, BGP_NOTIFY_CEASE,  				BGP_NOTIFY_CEASE_PEER_UNCONFIG);  } @@ -2907,7 +2909,7 @@ static void peer_notify_shutdown(struct peer *peer)  		return;  	} -	if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +	if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  		bgp_notify_send(peer, BGP_NOTIFY_CEASE,  				BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);  } @@ -2919,7 +2921,7 @@ void peer_group_notify_unconfig(struct peer_group *group)  	for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {  		other = peer->doppelganger; -		if (other && other->status != Deleted) { +		if (other && other->connection.status != Deleted) {  			other->group = NULL;  			peer_notify_unconfig(other);  		} else @@ -2945,7 +2947,7 @@ int peer_group_delete(struct peer_group *group)  			bgp_zebra_terminate_radv(bgp, peer);  		peer_delete(peer); -		if (other && other->status != Deleted) { +		if (other && other->connection.status != Deleted) {  			other->group = NULL;  			peer_delete(other);  		} @@ -2994,7 +2996,7 @@ int peer_group_remote_as_delete(struct peer_group *group)  		peer_delete(peer); -		if (other && other->status != Deleted) { +		if (other && other->connection.status != Deleted) {  			other->group = NULL;  			peer_delete(other);  		} @@ -3174,7 +3176,7 @@ int peer_group_bind(struct bgp *bgp, union sockunion *su, struct peer *peer,  		SET_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE); -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_RMAP_BIND;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -3730,7 +3732,7 @@ void bgp_instance_down(struct bgp *bgp)  	/* Bring down peers, so corresponding routes are purged. */  	for (ALL_LIST_ELEMENTS(bgp->peer, node, next, peer)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);  		else @@ -4413,10 +4415,10 @@ void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,  	if (type == peer_change_reset) {  		/* If we're resetting session, we've to delete both peer struct  		 */ -		if ((peer->doppelganger) -		    && (peer->doppelganger->status != Deleted) -		    && (!CHECK_FLAG(peer->doppelganger->flags, -				    PEER_FLAG_CONFIG_NODE))) +		if ((peer->doppelganger) && +		    (peer->doppelganger->connection.status != Deleted) && +		    (!CHECK_FLAG(peer->doppelganger->flags, +				 PEER_FLAG_CONFIG_NODE)))  			peer_delete(peer->doppelganger);  		bgp_notify_send(peer, BGP_NOTIFY_CEASE, @@ -4426,10 +4428,10 @@ void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,  			bgp_route_refresh_send(peer, afi, safi, 0, 0, 0,  					       BGP_ROUTE_REFRESH_NORMAL);  		else { -			if ((peer->doppelganger) -			    && (peer->doppelganger->status != Deleted) -			    && (!CHECK_FLAG(peer->doppelganger->flags, -					    PEER_FLAG_CONFIG_NODE))) +			if ((peer->doppelganger) && +			    (peer->doppelganger->connection.status != Deleted) && +			    (!CHECK_FLAG(peer->doppelganger->flags, +					 PEER_FLAG_CONFIG_NODE)))  				peer_delete(peer->doppelganger);  			bgp_notify_send(peer, BGP_NOTIFY_CEASE, @@ -4585,7 +4587,8 @@ static void peer_flag_modify_action(struct peer *peer, uint64_t flag)  						peer);  			} -			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +			if (BGP_IS_VALID_STATE_FOR_NOTIF( +				    peer->connection.status)) {  				char *msg = peer->tx_shutdown_message;  				size_t msglen;  				uint8_t msgbuf[BGP_ADMIN_SHUTDOWN_MSG_LEN + 1]; @@ -4615,7 +4618,7 @@ static void peer_flag_modify_action(struct peer *peer, uint64_t flag)  			peer->v_start = BGP_INIT_START_TIMER;  			BGP_EVENT_ADD(peer, BGP_Stop);  		} -	} else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +	} else if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  		if (flag == PEER_FLAG_DYNAMIC_CAPABILITY)  			peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;  		else if (flag == PEER_FLAG_PASSIVE) @@ -4652,7 +4655,7 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg)  			continue;  		/* send a RFC 4486 notification message if necessary */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			if (msg) {  				size_t datalen = strlen(msg); @@ -5074,7 +5077,7 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		if (peer->sort != BGP_PEER_IBGP) { -			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  				bgp_notify_send(peer, BGP_NOTIFY_CEASE,  						BGP_NOTIFY_CEASE_CONFIG_CHANGE);  			else @@ -5092,7 +5095,7 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)  			peer->ttl = group->conf->ttl; -			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  				bgp_notify_send(peer, BGP_NOTIFY_CEASE,  						BGP_NOTIFY_CEASE_CONFIG_CHANGE);  			else @@ -5129,7 +5132,7 @@ int peer_ebgp_multihop_unset(struct peer *peer)  	peer->ttl = ttl;  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		else @@ -5147,7 +5150,8 @@ int peer_ebgp_multihop_unset(struct peer *peer)  			peer->ttl = BGP_DEFAULT_TTL;  			if (peer->connection.fd >= 0) { -				if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +				if (BGP_IS_VALID_STATE_FOR_NOTIF( +					    peer->connection.status))  					bgp_notify_send(  						peer, BGP_NOTIFY_CEASE,  						BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5302,7 +5306,7 @@ int peer_update_source_if_set(struct peer *peer, const char *ifname)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5340,7 +5344,7 @@ int peer_update_source_if_set(struct peer *peer, const char *ifname)  		member->update_source = NULL;  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {  			member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;  			bgp_notify_send(member, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5373,7 +5377,7 @@ void peer_update_source_addr_set(struct peer *peer, const union sockunion *su)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5410,7 +5414,7 @@ void peer_update_source_addr_set(struct peer *peer, const union sockunion *su)  		XFREE(MTYPE_PEER_UPDATE_SOURCE, member->update_if);  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {  			member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;  			bgp_notify_send(member, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5461,7 +5465,7 @@ void peer_update_source_unset(struct peer *peer)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -5497,7 +5501,7 @@ void peer_update_source_unset(struct peer *peer)  		XFREE(MTYPE_PEER_UPDATE_SOURCE, member->update_if);  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {  			member->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;  			bgp_notify_send(member, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -6462,7 +6466,7 @@ int peer_local_as_unset(struct peer *peer)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Send notification or stop peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status)) {  			peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -6490,7 +6494,7 @@ int peer_local_as_unset(struct peer *peer)  		XFREE(MTYPE_BGP, member->change_local_as_pretty);  		/* Send notification or stop peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) { +		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status)) {  			member->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;  			bgp_notify_send(member, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE); @@ -6522,7 +6526,7 @@ int peer_password_set(struct peer *peer, const char *password)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		else @@ -6558,7 +6562,7 @@ int peer_password_set(struct peer *peer, const char *password)  		member->password = XSTRDUP(MTYPE_PEER_PASSWORD, password);  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status))  			bgp_notify_send(member, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		else @@ -6603,7 +6607,7 @@ int peer_password_unset(struct peer *peer)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		else @@ -6630,7 +6634,7 @@ int peer_password_unset(struct peer *peer)  		XFREE(MTYPE_PEER_PASSWORD, member->password);  		/* Send notification or reset peer depending on state. */ -		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection.status))  			bgp_notify_send(member, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_CONFIG_CHANGE);  		else @@ -7835,7 +7839,8 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)  				sockopt_minttl(peer->su.sa.sa_family,  					       peer->connection.fd,  					       MAXTTL + 1 - gtsm_hops); -			if ((peer->status < Established) && peer->doppelganger && +			if ((peer->connection.status < Established) && +			    peer->doppelganger &&  			    (peer->doppelganger->connection.fd >= 0))  				sockopt_minttl(peer->su.sa.sa_family,  					       peer->doppelganger->connection.fd, @@ -7861,7 +7866,7 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)  						       gpeer->connection.fd,  						       MAXTTL + 1 -  							       gpeer->gtsm_hops); -				if ((gpeer->status < Established) && +				if ((gpeer->connection.status < Established) &&  				    gpeer->doppelganger &&  				    (gpeer->doppelganger->connection.fd >= 0))  					sockopt_minttl(gpeer->su.sa.sa_family, @@ -7903,7 +7908,8 @@ int peer_ttl_security_hops_unset(struct peer *peer)  				sockopt_minttl(peer->su.sa.sa_family,  					       peer->connection.fd, 0); -			if ((peer->status < Established) && peer->doppelganger && +			if ((peer->connection.status < Established) && +			    peer->doppelganger &&  			    (peer->doppelganger->connection.fd >= 0))  				sockopt_minttl(peer->su.sa.sa_family,  					       peer->doppelganger->connection.fd, @@ -7920,7 +7926,7 @@ int peer_ttl_security_hops_unset(struct peer *peer)  					sockopt_minttl(peer->su.sa.sa_family,  						       peer->connection.fd, 0); -				if ((peer->status < Established) && +				if ((peer->connection.status < Established) &&  				    peer->doppelganger &&  				    (peer->doppelganger->connection.fd >= 0))  					sockopt_minttl(peer->su.sa.sa_family, @@ -7977,7 +7983,7 @@ int peer_clear(struct peer *peer, struct listnode **nnode)  			return 0;  		peer->v_start = BGP_INIT_START_TIMER; -		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  			bgp_notify_send(peer, BGP_NOTIFY_CEASE,  					BGP_NOTIFY_CEASE_ADMIN_RESET);  		else @@ -8280,8 +8286,8 @@ static int peer_unshut_after_cfg(struct bgp *bgp)  				   peer->host);  		peer->shut_during_cfg = false; -		if (peer_active(peer) && peer->status != Established) { -			if (peer->status != Idle) +		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);  		} @@ -8382,7 +8388,7 @@ void bgp_terminate(void)  						peer);  				continue;  			} -			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) +			if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection.status))  				bgp_notify_send(peer, BGP_NOTIFY_CEASE,  						BGP_NOTIFY_CEASE_PEER_UNCONFIG);  		} diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index dcee9caec8..5215c6a08d 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1123,6 +1123,10 @@ struct llgr_info {  struct peer_connection {  	struct peer *peer; +	/* Status of the peer connection. */ +	enum bgp_fsm_status status; +	enum bgp_fsm_status ostatus; +  	int fd;  	/* Packet receive and send buffer. */ @@ -1187,10 +1191,6 @@ struct peer {  	/* the doppelganger peer structure, due to dual TCP conn setup */  	struct peer *doppelganger; -	/* Status of the peer. */ -	enum bgp_fsm_status status; -	enum bgp_fsm_status ostatus; -  	/* FSM events, stored for debug purposes.  	 * Note: uchar used for reduced memory usage.  	 */ @@ -2594,7 +2594,7 @@ static inline char *timestamp_string(time_t ts)  static inline bool peer_established(struct peer *peer)  { -	return peer->status == Established; +	return peer->connection.status == Established;  }  static inline bool peer_dynamic_neighbor(struct peer *peer) diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index d24a07cd8a..6e99c74bcb 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1236,7 +1236,7 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp,  	 * Fill in BGP peer structure  	 */  	rfd->peer = peer_new(bgp); -	rfd->peer->status = Established; /* keep bgp core happy */ +	rfd->peer->connection.status = Established; /* keep bgp core happy */  	bgp_peer_connection_buffers_free(&rfd->peer->connection); diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index 8a30edce91..4fd057e848 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -171,7 +171,7 @@ static void vnc_redistribute_add(struct prefix *p, uint32_t metric,  			 * Same setup as in rfapi_open()  			 */  			vncHD1VR.peer = peer_new(bgp); -			vncHD1VR.peer->status = +			vncHD1VR.peer->connection.status =  				Established; /* keep bgp core happy */  			bgp_peer_connection_buffers_free(  | 
