diff options
| -rw-r--r-- | bgpd/bgp_bfd.c | 4 | ||||
| -rw-r--r-- | bgpd/bgp_bmp.c | 8 | ||||
| -rw-r--r-- | bgpd/bgp_conditional_adv.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_fsm.c | 16 | ||||
| -rw-r--r-- | bgpd/bgp_mac.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_network.c | 4 | ||||
| -rw-r--r-- | bgpd/bgp_nexthop.c | 9 | ||||
| -rw-r--r-- | bgpd/bgp_packet.c | 23 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 12 | ||||
| -rw-r--r-- | bgpd/bgp_routemap.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_rpki.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_snmp_bgp4.c | 5 | ||||
| -rw-r--r-- | bgpd/bgp_updgrp.c | 17 | ||||
| -rw-r--r-- | bgpd/bgp_vty.c | 37 | ||||
| -rw-r--r-- | bgpd/bgp_zebra.c | 4 | ||||
| -rw-r--r-- | bgpd/bgpd.c | 54 | ||||
| -rw-r--r-- | bgpd/bgpd.h | 4 | 
17 files changed, 108 insertions, 97 deletions
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index ba04c6fe85..11de3e3e6b 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -63,8 +63,8 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,  		BGP_EVENT_ADD(peer, BGP_Stop);  	} -	if (bss->state == BSS_UP && bss->previous_state != BSS_UP -	    && !peer_established(peer)) { +	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); diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 9821dcf7bb..c0f9a9a732 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -370,7 +370,7 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)  #define BGP_BMP_MAX_PACKET_SIZE	1024  	s = stream_new(BGP_MAX_PACKET_SIZE); -	if (peer_established(peer) && !down) { +	if (peer_established(peer->connection) && !down) {  		struct bmp_bgp_peer *bbpeer;  		bmp_common_hdr(s, BMP_VERSION_3, @@ -716,7 +716,7 @@ static int bmp_peer_status_changed(struct peer *peer)  	/* Check if this peer just went to Established */  	if ((peer->connection->ostatus != OpenConfirm) || -	    !(peer_established(peer))) +	    !(peer_established(peer->connection)))  		return 0;  	if (peer->doppelganger && @@ -1170,7 +1170,7 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)  		zlog_info("bmp: skipping queued item for deleted peer");  		goto out;  	} -	if (!peer_established(peer)) +	if (!peer_established(peer->connection))  		goto out;  	bool is_vpn = (bqe->afi == AFI_L2VPN && bqe->safi == SAFI_EVPN) || @@ -1355,7 +1355,7 @@ static void bmp_stats(struct event *thread)  	for (ALL_LIST_ELEMENTS_RO(bt->bgp->peer, node, peer)) {  		size_t count = 0, count_pos, len; -		if (!peer_established(peer)) +		if (!peer_established(peer->connection))  			continue;  		s = stream_new(BGP_MAX_PACKET_SIZE); diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c index 53652f7dce..b30052d95a 100644 --- a/bgpd/bgp_conditional_adv.c +++ b/bgpd/bgp_conditional_adv.c @@ -194,7 +194,7 @@ static void bgp_conditional_adv_timer(struct event *t)  		if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))  			continue; -		if (!peer_established(peer)) +		if (!peer_established(peer->connection))  			continue;  		FOREACH_AFI_SAFI (afi, safi) { diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index a730f97450..10712656d6 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -966,7 +966,9 @@ void bgp_start_routeadv(struct bgp *bgp)  		      sizeof(bgp->update_delay_peers_resume_time));  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -		if (!peer_established(peer)) +		struct peer_connection *connection = peer->connection; + +		if (!peer_established(connection))  			continue;  		EVENT_OFF(peer->connection->t_routeadv);  		BGP_TIMER_ON(peer->connection->t_routeadv, bgp_routeadv_timer, @@ -1160,7 +1162,7 @@ static void bgp_maxmed_onstartup_begin(struct bgp *bgp)  static void bgp_maxmed_onstartup_process_status_change(struct peer *peer)  { -	if (peer_established(peer) && !peer->bgp->established) { +	if (peer_established(peer->connection) && !peer->bgp->established) {  		bgp_maxmed_onstartup_begin(peer->bgp);  	}  } @@ -1218,7 +1220,7 @@ static void bgp_update_delay_begin(struct bgp *bgp)  static void bgp_update_delay_process_status_change(struct peer *peer)  { -	if (peer_established(peer)) { +	if (peer_established(peer->connection)) {  		if (!peer->bgp->established++) {  			bgp_update_delay_begin(peer->bgp);  			zlog_info( @@ -1254,7 +1256,7 @@ void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status)  	if (status == Established)  		bgp->established_peers++; -	else if ((peer_established(peer)) && (status != Established)) +	else if ((peer_established(peer->connection)) && (status != Established))  		bgp->established_peers--;  	if (bgp_debug_neighbor_events(peer)) { @@ -1397,7 +1399,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection)  	}  	/* Increment Dropped count. */ -	if (peer_established(peer)) { +	if (peer_established(connection)) {  		peer->dropped++;  		/* Notify BGP conditional advertisement process */ @@ -1567,7 +1569,7 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection)  		peer->orf_plist[afi][safi] = NULL;  		if ((connection->status == OpenConfirm) || -		    peer_established(peer)) { +		    peer_established(connection)) {  			/* ORF received prefix-filter pnt */  			snprintf(orf_name, sizeof(orf_name), "%s.%d.%d",  				 peer->host, afi, safi); @@ -2034,7 +2036,7 @@ bgp_fsm_holdtime_expire(struct peer_connection *connection)  	 * the Graceful Restart procedures to be performed when the BGP  	 * speaker receives a BGP NOTIFICATION message or the Hold Time expires.  	 */ -	if (peer_established(peer) && +	if (peer_established(connection) &&  	    bgp_has_graceful_restart_notification(peer))  		if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_MODE))  			SET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT); diff --git a/bgpd/bgp_mac.c b/bgpd/bgp_mac.c index 0398e4e8c1..e629732c78 100644 --- a/bgpd/bgp_mac.c +++ b/bgpd/bgp_mac.c @@ -219,7 +219,7 @@ static void bgp_mac_rescan_evpn_table(struct bgp *bgp, struct ethaddr *macaddr)  		if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))  			continue; -		if (!peer_established(peer)) +		if (!peer_established(peer->connection))  			continue;  		if (bgp_debug_update(peer, NULL, NULL, 1)) diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 0d9aa570c5..550407eac9 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -573,8 +573,8 @@ static void bgp_accept(struct event *thread)  	SET_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER);  	/* Make dummy peer until read Open packet. */ -	if (peer_established(peer1) -	    && CHECK_FLAG(peer1->sflags, PEER_STATUS_NSF_MODE)) { +	if (peer_established(peer1->connection) && +	    CHECK_FLAG(peer1->sflags, PEER_STATUS_NSF_MODE)) {  		/* If we have an existing established connection with graceful  		 * restart  		 * capability announced with one or more address families, then diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 6cb6d65c64..b3360cf974 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -409,11 +409,10 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)  		}  		for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -			if (peer->conf_if -			    && (strcmp(peer->conf_if, ifc->ifp->name) == 0) -			    && !peer_established(peer) -			    && !CHECK_FLAG(peer->flags, -					   PEER_FLAG_IFPEER_V6ONLY)) { +			if (peer->conf_if && +			    (strcmp(peer->conf_if, ifc->ifp->name) == 0) && +			    !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); diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 86f5fdcebd..39e70c59c5 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -260,7 +260,7 @@ void bgp_update_restarted_peers(struct peer *peer)  	if (bgp_debug_neighbor_events(peer))  		zlog_debug("Peer %s: Checking restarted", peer->host); -	if (peer_established(peer)) { +	if (peer_established(peer->connection)) {  		peer->update_delay_over = 1;  		peer->bgp->restarted_peers++;  		bgp_check_update_delay(peer->bgp); @@ -283,7 +283,7 @@ void bgp_update_implicit_eors(struct peer *peer)  	if (bgp_debug_neighbor_events(peer))  		zlog_debug("Peer %s: Checking implicit EORs", peer->host); -	if (peer_established(peer)) { +	if (peer_established(peer->connection)) {  		peer->update_delay_over = 1;  		peer->bgp->implicit_eors++;  		bgp_check_update_delay(peer->bgp); @@ -463,7 +463,7 @@ void bgp_generate_updgrp_packets(struct event *thread)  	 * if peer is Established and updates are not on hold (as part of  	 * update-delay processing).  	 */ -	if (!peer_established(peer)) +	if (!peer_established(peer->connection))  		return;  	if ((peer->bgp->main_peers_update_hold) @@ -1210,7 +1210,7 @@ void bgp_capability_send(struct peer *peer, afi_t afi, safi_t safi,  	uint16_t len;  	uint32_t gr_restart_time; -	if (!peer_established(peer)) +	if (!peer_established(peer->connection))  		return;  	if (!CHECK_FLAG(peer->cap, PEER_CAP_DYNAMIC_RCV) && @@ -1389,7 +1389,8 @@ 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->connection->status == Clearing) { +	if (peer_established(peer->connection) || +	    peer->connection->status == Clearing) {  		bgp_notify_send(new->connection, BGP_NOTIFY_CEASE,  				BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);  		return -1; @@ -1986,7 +1987,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)  	struct bgp_nlri nlris[NLRI_TYPE_MAX];  	/* Status must be Established. */ -	if (!peer_established(peer)) { +	if (!peer_established(peer->connection)) {  		flog_err(EC_BGP_INVALID_STATUS,  			 "%s [FSM] Update packet received under status %s",  			 peer->host, @@ -2178,7 +2179,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)  		    && nlri_ret != BGP_NLRI_PARSE_ERROR_PREFIX_OVERFLOW) {  			flog_err(EC_BGP_UPDATE_RCV,  				 "%s [Error] Error parsing NLRI", peer->host); -			if (peer_established(peer)) +			if (peer_established(peer->connection))  				bgp_notify_send(peer->connection,  						BGP_NOTIFY_UPDATE_ERR,  						i <= NLRI_WITHDRAW @@ -2438,7 +2439,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)  	}  	/* Status must be Established. */ -	if (!peer_established(peer)) { +	if (!peer_established(peer->connection)) {  		flog_err(EC_BGP_INVALID_STATUS,  			 "%s [Error] Route refresh packet received under status %s",  			 peer->host, @@ -2736,7 +2737,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)  			bgp_set_stale_route(peer, afi, safi);  		} -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			event_add_timer(bm->master,  					bgp_refresh_stalepath_timer_expire, paf,  					peer->bgp->stalepath_time, @@ -3131,7 +3132,7 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size)  	}  	/* Status must be Established. */ -	if (!peer_established(peer)) { +	if (!peer_established(peer->connection)) {  		flog_err(EC_BGP_NO_CAP,  			 "%s [Error] Dynamic capability packet received under status %s",  			 peer->host, @@ -3354,7 +3355,7 @@ void bgp_packet_process_error(struct event *thread)  			   connection->fd);  	/* Closed connection or error on the socket */ -	if (peer_established(peer)) { +	if (peer_established(connection)) {  		if ((CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)  		     || CHECK_FLAG(peer->flags,  				   PEER_FLAG_GRACEFUL_RESTART_HELPER)) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 467163d48a..643dc85def 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2742,7 +2742,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,  			if (pi1->peer != bgp->peer_self &&  			    !CHECK_FLAG(pi1->peer->sflags,  					PEER_STATUS_NSF_WAIT)) { -				if (!peer_established(pi1->peer)) +				if (!peer_established(pi1->peer->connection))  					continue;  			} @@ -2757,7 +2757,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,  					if (pi2->peer != bgp->peer_self &&  					    !CHECK_FLAG(pi2->peer->sflags,  							PEER_STATUS_NSF_WAIT) && -					    !peer_established(pi2->peer)) +					    !peer_established( +						    pi2->peer->connection))  						continue;  					if (!aspath_cmp_left(pi1->attr->aspath, @@ -2828,8 +2829,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,  		if (pi->peer && pi->peer != bgp->peer_self  		    && !CHECK_FLAG(pi->peer->sflags, PEER_STATUS_NSF_WAIT)) -			if (!peer_established(pi->peer)) { - +			if (!peer_established(pi->peer->connection)) {  				if (debug)  					zlog_debug(  						"%s: %pBD(%s) non self peer %s not estab state", @@ -2903,7 +2903,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,  			if (pi->peer && pi->peer != bgp->peer_self  			    && !CHECK_FLAG(pi->peer->sflags,  					   PEER_STATUS_NSF_WAIT)) -				if (!peer_established(pi->peer)) +				if (!peer_established(pi->peer->connection))  					continue;  			if (!bgp_path_info_nexthop_cmp(pi, new_select)) { @@ -5173,7 +5173,7 @@ static void bgp_announce_route_timer_expired(struct event *t)  	paf = EVENT_ARG(t);  	peer = paf->peer; -	if (!peer_established(peer)) +	if (!peer_established(peer->connection))  		return;  	if (!peer->afc_nego[paf->afi][paf->safi]) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 9e851c5bca..c1057b7196 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -4340,7 +4340,7 @@ static void bgp_route_map_process_peer(const char *rmap_name,  	    && (strcmp(rmap_name, filter->map[RMAP_IN].name) == 0)) {  		filter->map[RMAP_IN].map = map; -		if (route_update && peer_established(peer)) { +		if (route_update && peer_established(peer->connection)) {  			if (CHECK_FLAG(peer->af_flags[afi][safi],  				       PEER_FLAG_SOFT_RECONFIG)) {  				if (bgp_debug_update(peer, NULL, NULL, 1)) diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index c6e3131e02..f0b2ffdee5 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -520,7 +520,7 @@ static void revalidate_all_routes(void)  				if (!bgp->rib[afi][safi])  					continue; -				if (!peer_established(peer)) +				if (!peer_established(peer->connection))  					continue;  				rvp = XCALLOC(MTYPE_BGP_RPKI_REVALIDATE, diff --git a/bgpd/bgp_snmp_bgp4.c b/bgpd/bgp_snmp_bgp4.c index 8af87ae4b2..8a1b57f22f 100644 --- a/bgpd/bgp_snmp_bgp4.c +++ b/bgpd/bgp_snmp_bgp4.c @@ -754,10 +754,11 @@ int bgpTrapEstablished(struct peer *peer)  	int ret;  	struct in_addr addr;  	oid index[sizeof(oid) * IN_ADDR_SIZE]; +	struct peer_connection *connection = peer->connection;  	/* Check if this peer just went to Established */ -	if ((peer->connection->ostatus != OpenConfirm) || -	    !(peer_established(peer))) +	if ((connection->ostatus != OpenConfirm) || +	    !(peer_established(connection)))  		return 0;  	ret = inet_aton(peer->host, &addr); diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index e9202e6a3e..00c7fcd5a9 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -988,7 +988,7 @@ static struct update_group *update_group_find(struct peer_af *paf)  	struct update_group tmp;  	struct peer tmp_conf; -	if (!peer_established(PAF_PEER(paf))) +	if (!peer_established((PAF_PEER(paf))->connection))  		return NULL;  	memset(&tmp, 0, sizeof(tmp)); @@ -1251,7 +1251,7 @@ static struct update_subgroup *update_subgroup_find(struct update_group *updgrp,  	} else  		version = 0; -	if (!peer_established(PAF_PEER(paf))) +	if (!peer_established(PAF_PEER(paf)->connection))  		return NULL;  	UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) { @@ -1945,7 +1945,7 @@ void update_group_adjust_peer(struct peer_af *paf)  		return;  	peer = PAF_PEER(paf); -	if (!peer_established(peer)) { +	if (!peer_established(peer->connection)) {  		return;  	} @@ -2000,13 +2000,13 @@ int update_group_adjust_soloness(struct peer *peer, int set)  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		peer_lonesoul_or_not(peer, set); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			bgp_announce_route_all(peer);  	} else {  		group = peer->group;  		for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {  			peer_lonesoul_or_not(peer, set); -			if (peer_established(peer)) +			if (peer_established(peer->connection))  				bgp_announce_route_all(peer);  		}  	} @@ -2199,13 +2199,16 @@ void subgroup_trigger_write(struct update_subgroup *subgrp)  	 * the subgroup output queue into their own output queue. This action  	 * will trigger a write job on the I/O thread.  	 */ -	SUBGRP_FOREACH_PEER (subgrp, paf) -		if (peer_established(paf->peer)) +	SUBGRP_FOREACH_PEER (subgrp, paf) { +		struct peer_connection *connection = paf->peer->connection; + +		if (peer_established(connection))  			event_add_timer_msec(bm->master,  					     bgp_generate_updgrp_packets,  					     paf->peer, 0,  					     &paf->peer->connection  						      ->t_generate_updgrp_packets); +	}  }  int update_group_clear_update_dbg(struct update_group *updgrp, void *arg) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1e2af357e7..4f7e2f58a9 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10722,7 +10722,7 @@ static inline void calc_peers_cfgd_estbd(struct bgp *bgp, int *peers_cfgd,  		if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))  			continue;  		(*peers_cfgd)++; -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			(*peers_estbd)++;  	}  } @@ -11246,7 +11246,8 @@ static void bgp_show_peer_reset(struct vty * vty, struct peer *peer,  static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi,  				       safi_t safi)  { -	return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); +	return ((!peer_established(peer->connection)) || +		!peer->afc_recv[afi][safi]);  }  static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, @@ -11273,7 +11274,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,  				    peer->dropped);  		peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN,  			    use_json, json_peer); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			json_object_string_add(json_peer, "lastResetDueTo",  					       "AFI/SAFI Not Negotiated");  		else @@ -11296,7 +11297,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,  			peer->dropped,  			peer_uptime(peer->uptime, timebuf,  				    BGP_UPTIME_LEN, 0, NULL)); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			vty_out(vty, "  AFI/SAFI Not Negotiated\n");  		else  			bgp_show_peer_reset(vty, peer, NULL, @@ -11977,7 +11978,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  					peer_uptime(peer->uptime, timebuf,  						    BGP_UPTIME_LEN, 0, NULL)); -				if (peer_established(peer)) { +				if (peer_established(peer->connection)) {  					if (peer->afc_recv[afi][safi]) {  						if (CHECK_FLAG(  							    bgp->flags, @@ -12433,9 +12434,9 @@ static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty,  	bool rbit = false;  	bool nbit = false; -	if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) -	    && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) -	    && (peer_established(p))) { +	if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && +	    (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) && +	    (peer_established(p->connection))) {  		rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV);  		nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV);  	} @@ -12458,9 +12459,8 @@ static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty,  	if (!json)  		vty_out(vty, "\n    Remote GR Mode: "); -	if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) -	    && (peer_established(peer))) { - +	if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) && +	    (peer_established(peer->connection))) {  		if ((peer->nsf_af_count == 0)  		    && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { @@ -13615,7 +13615,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  				       lookup_msg(bgp_status_msg,  						  p->connection->status, NULL)); -		if (peer_established(p)) { +		if (peer_established(p->connection)) {  			time_t uptime;  			uptime = monotime(NULL); @@ -13739,7 +13739,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		vty_out(vty, "  BGP state = %s",  			lookup_msg(bgp_status_msg, p->connection->status, NULL)); -		if (peer_established(p)) +		if (peer_established(p->connection))  			vty_out(vty, ", up for %8s",  				peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN,  					    0, NULL)); @@ -13799,7 +13799,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  					bgp->t_condition_check));  	}  	/* Capability. */ -	if (peer_established(p) && +	if (peer_established(p->connection) &&  	    (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) {  		if (use_json) {  			json_object *json_cap = NULL; @@ -14656,7 +14656,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		json_grace_send = json_object_new_object();  		json_grace_recv = json_object_new_object(); -		if ((peer_established(p)) && +		if ((peer_established(p->connection)) &&  		    CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {  			FOREACH_AFI_SAFI (afi, safi) {  				if (CHECK_FLAG(p->af_sflags[afi][safi], @@ -14704,9 +14704,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  				       json_grace);  	} else {  		vty_out(vty, "  Graceful restart information:\n"); -		if ((peer_established(p)) && +		if ((peer_established(p->connection)) &&  		    CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { -  			vty_out(vty, "    End-of-RIB send: ");  			FOREACH_AFI_SAFI (afi, safi) {  				if (CHECK_FLAG(p->af_sflags[afi][safi], @@ -15124,7 +15123,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  	if (use_json) {  		json_object_int_add(json_neigh, "connectRetryTimer",  				    p->v_connect); -		if (peer_established(p)) { +		if (peer_established(p->connection)) {  			json_object_int_add(json_neigh, "estimatedRttInMsecs",  					    p->rtt);  			if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) { @@ -15174,7 +15173,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  	} else {  		vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n",  			p->v_connect); -		if (peer_established(p)) { +		if (peer_established(p->connection)) {  			vty_out(vty, "Estimated round trip time: %d ms\n",  				p->rtt);  			if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 105c1080bc..1020e43302 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -140,8 +140,8 @@ static void bgp_start_interface_nbrs(struct bgp *bgp, struct interface *ifp)  	struct peer *peer;  	for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { -		if (peer->conf_if && (strcmp(peer->conf_if, ifp->name) == 0) -		    && !peer_established(peer)) { +		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); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 749225bd30..1e83a1fb79 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -2324,7 +2324,7 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi)  	if (!active && peer_active(peer)) {  		bgp_timer_set(peer->connection);  	} else { -		if (peer_established(peer)) { +		if (peer_established(peer->connection)) {  			if (CHECK_FLAG(peer->cap, PEER_CAP_DYNAMIC_RCV)) {  				peer->afc_adv[afi][safi] = 1;  				bgp_capability_send(peer, afi, safi, @@ -2456,7 +2456,7 @@ static bool non_peergroup_deactivate_af(struct peer *peer, afi_t afi,  		return true;  	} -	if (peer_established(peer)) { +	if (peer_established(peer->connection)) {  		if (CHECK_FLAG(peer->cap, PEER_CAP_DYNAMIC_RCV)) {  			peer->afc_adv[afi][safi] = 0;  			peer->afc_nego[afi][safi] = 0; @@ -4434,7 +4434,7 @@ void peer_change_action(struct peer *peer, afi_t afi, safi_t safi,  	if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))  		return; -	if (!peer_established(peer)) +	if (!peer_established(peer->connection))  		return;  	if (type == peer_change_reset) { @@ -4956,8 +4956,8 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,  		COND_FLAG(peer->af_flags[afi][safi], flag, set);  	/* Execute action when peer is established.  */ -	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP) -	    && peer_established(peer)) { +	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP) && +	    peer_established(peer->connection)) {  		if (!set && flag == PEER_FLAG_SOFT_RECONFIG)  			bgp_clear_adj_in(peer, afi, safi);  		else { @@ -5010,7 +5010,7 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,  				  set != member_invert);  			/* Execute flag action on peer-group member. */ -			if (peer_established(member)) { +			if (peer_established(member->connection)) {  				if (!set && flag == PEER_FLAG_SOFT_RECONFIG)  					bgp_clear_adj_in(member, afi, safi);  				else { @@ -5612,7 +5612,8 @@ int peer_default_originate_set(struct peer *peer, afi_t afi, safi_t safi,  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Update peer route announcements. */ -		if (peer_established(peer) && peer->afc_nego[afi][safi]) { +		if (peer_established(peer->connection) && +		    peer->afc_nego[afi][safi]) {  			update_group_adjust_peer(peer_af_find(peer, afi, safi));  			bgp_default_originate(peer, afi, safi, 0);  			bgp_announce_route(peer, afi, safi, false); @@ -5653,7 +5654,8 @@ int peer_default_originate_set(struct peer *peer, afi_t afi, safi_t safi,  		}  		/* Update peer route announcements. */ -		if (peer_established(member) && member->afc_nego[afi][safi]) { +		if (peer_established(member->connection) && +		    member->afc_nego[afi][safi]) {  			update_group_adjust_peer(  				peer_af_find(member, afi, safi));  			bgp_default_originate(member, afi, safi, 0); @@ -5698,7 +5700,8 @@ int peer_default_originate_unset(struct peer *peer, afi_t afi, safi_t safi)  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Update peer route announcements. */ -		if (peer_established(peer) && peer->afc_nego[afi][safi]) { +		if (peer_established(peer->connection) && +		    peer->afc_nego[afi][safi]) {  			update_group_adjust_peer(peer_af_find(peer, afi, safi));  			bgp_default_originate(peer, afi, safi, 1);  			bgp_announce_route(peer, afi, safi, false); @@ -5736,7 +5739,8 @@ int peer_default_originate_unset(struct peer *peer, afi_t afi, safi_t safi)  		member->default_rmap[afi][safi].map = NULL;  		/* Update peer route announcements. */ -		if (peer_established(member) && member->afc_nego[afi][safi]) { +		if (peer_established(member->connection) && +		    member->afc_nego[afi][safi]) {  			update_group_adjust_peer(peer_af_find(member, afi, safi));  			bgp_default_originate(member, afi, safi, 1);  			bgp_announce_route(member, afi, safi, false); @@ -5788,10 +5792,10 @@ void peer_on_policy_change(struct peer *peer, afi_t afi, safi_t safi,  {  	if (outbound) {  		update_group_adjust_peer(peer_af_find(peer, afi, safi)); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			bgp_announce_route(peer, afi, safi, false);  	} else { -		if (!peer_established(peer)) +		if (!peer_established(peer->connection))  			return;  		if (bgp_soft_reconfig_in(peer, afi, safi)) @@ -5986,7 +5990,7 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect)  	/* Skip peer-group mechanics for regular peers. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { -		if (!peer_established(peer)) { +		if (!peer_established(peer->connection)) {  			if (peer_active(peer))  				BGP_EVENT_ADD(peer, BGP_Stop);  			BGP_EVENT_ADD(peer, BGP_Start); @@ -6007,7 +6011,7 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect)  		member->connect = connect;  		member->v_connect = connect; -		if (!peer_established(member)) { +		if (!peer_established(member->connection)) {  			if (peer_active(member))  				BGP_EVENT_ADD(member, BGP_Stop);  			BGP_EVENT_ADD(member, BGP_Start); @@ -6040,7 +6044,7 @@ int peer_timers_connect_unset(struct peer *peer)  	/* Skip peer-group mechanics for regular peers. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { -		if (!peer_established(peer)) { +		if (!peer_established(peer->connection)) {  			if (peer_active(peer))  				BGP_EVENT_ADD(peer, BGP_Stop);  			BGP_EVENT_ADD(peer, BGP_Start); @@ -6061,7 +6065,7 @@ int peer_timers_connect_unset(struct peer *peer)  		member->connect = 0;  		member->v_connect = peer->bgp->default_connect_retry; -		if (!peer_established(member)) { +		if (!peer_established(member->connection)) {  			if (peer_active(member))  				BGP_EVENT_ADD(member, BGP_Stop);  			BGP_EVENT_ADD(member, BGP_Start); @@ -6088,7 +6092,7 @@ int peer_advertise_interval_set(struct peer *peer, uint32_t routeadv)  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Update peer route announcements. */  		update_group_adjust_peer_afs(peer); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			bgp_announce_route_all(peer);  		/* Skip peer-group mechanics for regular peers. */ @@ -6111,7 +6115,7 @@ int peer_advertise_interval_set(struct peer *peer, uint32_t routeadv)  		/* Update peer route announcements. */  		update_group_adjust_peer_afs(member); -		if (peer_established(member)) +		if (peer_established(member->connection))  			bgp_announce_route_all(member);  	} @@ -6145,7 +6149,7 @@ int peer_advertise_interval_unset(struct peer *peer)  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Update peer route announcements. */  		update_group_adjust_peer_afs(peer); -		if (peer_established(peer)) +		if (peer_established(peer->connection))  			bgp_announce_route_all(peer);  		/* Skip peer-group mechanics for regular peers. */ @@ -6170,7 +6174,7 @@ int peer_advertise_interval_unset(struct peer *peer)  		/* Update peer route announcements. */  		update_group_adjust_peer_afs(member); -		if (peer_established(member)) +		if (peer_established(member->connection))  			bgp_announce_route_all(member);  	} @@ -7582,7 +7586,8 @@ int peer_maximum_prefix_set(struct peer *peer, afi_t afi, safi_t safi,  	/* Check if handling a regular peer. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {  		/* Re-check if peer violates maximum-prefix. */ -		if ((peer_established(peer)) && (peer->afc[afi][safi])) +		if ((peer_established(peer->connection)) && +		    (peer->afc[afi][safi]))  			bgp_maximum_prefix_overflow(peer, afi, safi, 1);  		/* Skip peer-group mechanics for regular peers. */ @@ -7619,7 +7624,8 @@ int peer_maximum_prefix_set(struct peer *peer, afi_t afi, safi_t safi,  				   PEER_FLAG_MAX_PREFIX_WARNING);  		/* Re-check if peer violates maximum-prefix. */ -		if ((peer_established(member)) && (member->afc[afi][safi])) +		if ((peer_established(member->connection)) && +		    (member->afc[afi][safi]))  			bgp_maximum_prefix_overflow(member, afi, safi, 1);  	} @@ -7690,7 +7696,7 @@ void peer_maximum_prefix_out_refresh_routes(struct peer *peer, afi_t afi,  {  	update_group_adjust_peer(peer_af_find(peer, afi, safi)); -	if (peer_established(peer)) +	if (peer_established(peer->connection))  		bgp_announce_route(peer, afi, safi, false);  } @@ -8027,7 +8033,7 @@ int peer_clear_soft(struct peer *peer, afi_t afi, safi_t safi,  {  	struct peer_af *paf; -	if (!peer_established(peer)) +	if (!peer_established(peer->connection))  		return 0;  	if (!peer->afc[afi][safi]) diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index c815d97bd1..fb2bd6e503 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -2598,9 +2598,9 @@ static inline char *timestamp_string(time_t ts)  	return ctime(&tbuf);  } -static inline bool peer_established(struct peer *peer) +static inline bool peer_established(struct peer_connection *connection)  { -	return peer->connection->status == Established; +	return connection->status == Established;  }  static inline bool peer_dynamic_neighbor(struct peer *peer)  | 
