mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 10:04:18 +00:00
Merge pull request #8806 from donaldsharp/established
bgpd: Convert to using peer_established(peer) function
This commit is contained in:
commit
072d821684
@ -72,7 +72,7 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,
|
||||
}
|
||||
|
||||
if (bss->state == BSS_UP && bss->previous_state != BSS_UP
|
||||
&& peer->status != Established) {
|
||||
&& !peer_established(peer)) {
|
||||
if (!BGP_PEER_START_SUPPRESSED(peer)) {
|
||||
bgp_fsm_nht_update(peer, true);
|
||||
BGP_EVENT_ADD(peer, BGP_Start);
|
||||
|
@ -365,7 +365,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->status == Established && !down) {
|
||||
if (peer_established(peer) && !down) {
|
||||
struct bmp_bgp_peer *bbpeer;
|
||||
|
||||
bmp_common_hdr(s, BMP_VERSION_3,
|
||||
@ -1146,7 +1146,7 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
|
||||
zlog_info("bmp: skipping queued item for deleted peer");
|
||||
goto out;
|
||||
}
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
goto out;
|
||||
|
||||
bn = bgp_node_lookup(bmp->targets->bgp->rib[afi][safi], &bqe->p);
|
||||
@ -1323,7 +1323,7 @@ static int bmp_stats(struct thread *thread)
|
||||
for (ALL_LIST_ELEMENTS_RO(bt->bgp->peer, node, peer)) {
|
||||
size_t count = 0, count_pos, len;
|
||||
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
continue;
|
||||
|
||||
s = stream_new(BGP_MAX_PACKET_SIZE);
|
||||
|
@ -195,7 +195,7 @@ static int bgp_conditional_adv_timer(struct thread *t)
|
||||
if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
|
||||
continue;
|
||||
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
continue;
|
||||
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
|
@ -811,7 +811,7 @@ 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->status != Established)
|
||||
if (!peer_established(peer))
|
||||
continue;
|
||||
BGP_TIMER_OFF(peer->t_routeadv);
|
||||
BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
|
||||
@ -1004,7 +1004,7 @@ static void bgp_maxmed_onstartup_begin(struct bgp *bgp)
|
||||
|
||||
static void bgp_maxmed_onstartup_process_status_change(struct peer *peer)
|
||||
{
|
||||
if (peer->status == Established && !peer->bgp->established) {
|
||||
if (peer_established(peer) && !peer->bgp->established) {
|
||||
bgp_maxmed_onstartup_begin(peer->bgp);
|
||||
}
|
||||
}
|
||||
@ -1066,7 +1066,7 @@ static void bgp_update_delay_begin(struct bgp *bgp)
|
||||
|
||||
static void bgp_update_delay_process_status_change(struct peer *peer)
|
||||
{
|
||||
if (peer->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
if (!peer->bgp->established++) {
|
||||
bgp_update_delay_begin(peer->bgp);
|
||||
zlog_info(
|
||||
@ -1102,7 +1102,7 @@ void bgp_fsm_change_status(struct peer *peer, int status)
|
||||
|
||||
if (status == Established)
|
||||
bgp->established_peers++;
|
||||
else if ((peer->status == Established) && (status != Established))
|
||||
else if ((peer_established(peer)) && (status != Established))
|
||||
bgp->established_peers--;
|
||||
|
||||
if (bgp_debug_neighbor_events(peer)) {
|
||||
@ -1235,7 +1235,7 @@ int bgp_stop(struct peer *peer)
|
||||
}
|
||||
|
||||
/* Increment Dropped count. */
|
||||
if (peer->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
peer->dropped++;
|
||||
|
||||
/* bgp log-neighbor-changes of neighbor Down */
|
||||
@ -1396,8 +1396,7 @@ int bgp_stop(struct peer *peer)
|
||||
/* Received ORF prefix-filter */
|
||||
peer->orf_plist[afi][safi] = NULL;
|
||||
|
||||
if ((peer->status == OpenConfirm)
|
||||
|| (peer->status == Established)) {
|
||||
if ((peer->status == OpenConfirm) || (peer_established(peer))) {
|
||||
/* ORF received prefix-filter pnt */
|
||||
snprintf(orf_name, sizeof(orf_name), "%s.%d.%d",
|
||||
peer->host, afi, safi);
|
||||
|
@ -239,7 +239,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->status != Established)
|
||||
if (!peer_established(peer))
|
||||
continue;
|
||||
|
||||
if (CHECK_FLAG(peer->af_flags[afi][safi],
|
||||
|
@ -581,7 +581,7 @@ static int bgp_accept(struct thread *thread)
|
||||
|
||||
SET_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER);
|
||||
/* Make dummy peer until read Open packet. */
|
||||
if (peer1->status == Established
|
||||
if (peer_established(peer1)
|
||||
&& CHECK_FLAG(peer1->sflags, PEER_STATUS_NSF_MODE)) {
|
||||
/* If we have an existing established connection with graceful
|
||||
* restart
|
||||
|
@ -414,7 +414,7 @@ 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->status != Established
|
||||
&& !peer_established(peer)
|
||||
&& !CHECK_FLAG(peer->flags,
|
||||
PEER_FLAG_IFPEER_V6ONLY)) {
|
||||
if (peer_active(peer))
|
||||
|
@ -232,7 +232,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->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
peer->update_delay_over = 1;
|
||||
peer->bgp->restarted_peers++;
|
||||
bgp_check_update_delay(peer->bgp);
|
||||
@ -255,7 +255,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->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
peer->update_delay_over = 1;
|
||||
peer->bgp->implicit_eors++;
|
||||
bgp_check_update_delay(peer->bgp);
|
||||
@ -404,7 +404,7 @@ int bgp_generate_updgrp_packets(struct thread *thread)
|
||||
* if peer is Established and updates are not on hold (as part of
|
||||
* update-delay processing).
|
||||
*/
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
return 0;
|
||||
|
||||
if ((peer->bgp->main_peers_update_hold)
|
||||
@ -1019,7 +1019,7 @@ 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->status == Established || peer->status == Clearing) {
|
||||
if (peer_established(peer) || peer->status == Clearing) {
|
||||
bgp_notify_send(new, BGP_NOTIFY_CEASE,
|
||||
BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);
|
||||
return -1;
|
||||
@ -1542,7 +1542,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->status != Established) {
|
||||
if (!peer_established(peer)) {
|
||||
flog_err(EC_BGP_INVALID_STATUS,
|
||||
"%s [FSM] Update packet received under status %s",
|
||||
peer->host,
|
||||
@ -1732,7 +1732,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->status == Established)
|
||||
if (peer_established(peer))
|
||||
bgp_notify_send(
|
||||
peer, BGP_NOTIFY_UPDATE_ERR,
|
||||
i <= NLRI_WITHDRAW
|
||||
@ -1955,7 +1955,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)
|
||||
}
|
||||
|
||||
/* Status must be Established. */
|
||||
if (peer->status != Established) {
|
||||
if (!peer_established(peer)) {
|
||||
flog_err(
|
||||
EC_BGP_INVALID_STATUS,
|
||||
"%s [Error] Route refresh packet received under status %s",
|
||||
@ -2258,7 +2258,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)
|
||||
bgp_set_stale_route(peer, afi, safi);
|
||||
}
|
||||
|
||||
if (peer->status == Established)
|
||||
if (peer_established(peer))
|
||||
thread_add_timer(bm->master,
|
||||
bgp_refresh_stalepath_timer_expire,
|
||||
paf, peer->bgp->stalepath_time,
|
||||
@ -2490,7 +2490,7 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size)
|
||||
}
|
||||
|
||||
/* Status must be Established. */
|
||||
if (peer->status != Established) {
|
||||
if (!peer_established(peer)) {
|
||||
flog_err(
|
||||
EC_BGP_NO_CAP,
|
||||
"%s [Error] Dynamic capability packet received under status %s",
|
||||
@ -2711,7 +2711,7 @@ int bgp_packet_process_error(struct thread *thread)
|
||||
peer->host, peer->fd, code);
|
||||
|
||||
/* Closed connection or error on the socket */
|
||||
if (peer->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
if ((CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)
|
||||
|| CHECK_FLAG(peer->flags,
|
||||
PEER_FLAG_GRACEFUL_RESTART_HELPER))
|
||||
|
@ -2347,7 +2347,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
|
||||
if (BGP_PATH_HOLDDOWN(pi1))
|
||||
continue;
|
||||
if (pi1->peer != bgp->peer_self)
|
||||
if (pi1->peer->status != Established)
|
||||
if (!peer_established(pi1->peer))
|
||||
continue;
|
||||
|
||||
new_select = pi1;
|
||||
@ -2432,7 +2432,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 (pi->peer->status != Established) {
|
||||
if (!peer_established(pi->peer)) {
|
||||
|
||||
if (debug)
|
||||
zlog_debug(
|
||||
@ -2502,7 +2502,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 (pi->peer->status != Established)
|
||||
if (!peer_established(pi->peer))
|
||||
continue;
|
||||
|
||||
if (!bgp_path_info_nexthop_cmp(pi, new_select)) {
|
||||
@ -4524,7 +4524,7 @@ static int bgp_announce_route_timer_expired(struct thread *t)
|
||||
paf = THREAD_ARG(t);
|
||||
peer = paf->peer;
|
||||
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
return 0;
|
||||
|
||||
if (!peer->afc_nego[paf->afi][paf->safi])
|
||||
@ -4646,7 +4646,7 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
|
||||
struct bgp_dest *dest;
|
||||
struct bgp_table *table;
|
||||
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
return;
|
||||
|
||||
if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
|
||||
|
@ -3452,7 +3452,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->status == Established) {
|
||||
if (route_update && peer_established(peer)) {
|
||||
if (CHECK_FLAG(peer->af_flags[afi][safi],
|
||||
PEER_FLAG_SOFT_RECONFIG)) {
|
||||
if (bgp_debug_update(peer, NULL, NULL, 1))
|
||||
|
@ -1705,13 +1705,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->status == Established)
|
||||
if (peer_established(peer))
|
||||
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->status == Established)
|
||||
if (peer_established(peer))
|
||||
bgp_announce_route_all(peer);
|
||||
}
|
||||
}
|
||||
@ -1901,7 +1901,7 @@ void subgroup_trigger_write(struct update_subgroup *subgrp)
|
||||
* will trigger a write job on the I/O thread.
|
||||
*/
|
||||
SUBGRP_FOREACH_PEER (subgrp, paf)
|
||||
if (paf->peer->status == Established)
|
||||
if (peer_established(paf->peer))
|
||||
thread_add_timer_msec(
|
||||
bm->master, bgp_generate_updgrp_packets,
|
||||
paf->peer, 0,
|
||||
|
@ -10425,7 +10425,7 @@ DEFUN (show_bgp_vrfs,
|
||||
if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
|
||||
continue;
|
||||
peers_cfg++;
|
||||
if (peer->status == Established)
|
||||
if (peer_established(peer))
|
||||
peers_estb++;
|
||||
}
|
||||
|
||||
@ -10794,8 +10794,7 @@ 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->status != Established) ||
|
||||
!peer->afc_recv[afi][safi]);
|
||||
return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]);
|
||||
}
|
||||
|
||||
static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,
|
||||
@ -10822,7 +10821,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->status == Established)
|
||||
if (peer_established(peer))
|
||||
json_object_string_add(json_peer, "lastResetDueTo",
|
||||
"AFI/SAFI Not Negotiated");
|
||||
else
|
||||
@ -10845,7 +10844,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->status == Established)
|
||||
if (peer_established(peer))
|
||||
vty_out(vty, " AFI/SAFI Not Negotiated\n");
|
||||
else
|
||||
bgp_show_peer_reset(vty, peer, NULL,
|
||||
@ -11472,7 +11471,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
|
||||
BGP_UPTIME_LEN, 0,
|
||||
NULL));
|
||||
|
||||
if (peer->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
if (peer->afc_recv[afi][safi]) {
|
||||
if (CHECK_FLAG(
|
||||
bgp->flags,
|
||||
@ -11901,7 +11900,7 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,
|
||||
|
||||
if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)
|
||||
&& (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV))
|
||||
&& (p->status == Established)) {
|
||||
&& (peer_established(p))) {
|
||||
|
||||
if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV))
|
||||
rbit_status = true;
|
||||
@ -11933,7 +11932,7 @@ static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty,
|
||||
vty_out(vty, "\n Remote GR Mode: ");
|
||||
|
||||
if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV)
|
||||
&& (peer->status == Established)) {
|
||||
&& (peer_established(peer))) {
|
||||
|
||||
if ((peer->nsf_af_count == 0)
|
||||
&& !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
|
||||
@ -13121,7 +13120,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
|
||||
json_neigh, "bgpState",
|
||||
lookup_msg(bgp_status_msg, p->status, NULL));
|
||||
|
||||
if (p->status == Established) {
|
||||
if (peer_established(p)) {
|
||||
time_t uptime;
|
||||
|
||||
uptime = bgp_clock();
|
||||
@ -13239,7 +13238,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->status, NULL));
|
||||
|
||||
if (p->status == Established)
|
||||
if (peer_established(p))
|
||||
vty_out(vty, ", up for %8s",
|
||||
peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN,
|
||||
0, NULL));
|
||||
@ -13289,7 +13288,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
|
||||
}
|
||||
}
|
||||
/* Capability. */
|
||||
if (p->status == Established) {
|
||||
if (peer_established(p)) {
|
||||
if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST]
|
||||
|| p->afc_recv[AFI_IP][SAFI_UNICAST]
|
||||
|| p->afc_adv[AFI_IP][SAFI_MULTICAST]
|
||||
@ -14201,7 +14200,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 ((p->status == Established)
|
||||
if ((peer_established(p))
|
||||
&& CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
if (CHECK_FLAG(p->af_sflags[afi][safi],
|
||||
@ -14254,7 +14253,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
|
||||
json_neigh, "gracefulRestartInfo", json_grace);
|
||||
} else {
|
||||
vty_out(vty, " Graceful restart information:\n");
|
||||
if ((p->status == Established)
|
||||
if ((peer_established(p))
|
||||
&& CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) {
|
||||
|
||||
vty_out(vty, " End-of-RIB send: ");
|
||||
@ -14653,7 +14652,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 (p->status == Established && p->rtt)
|
||||
if (peer_established(p) && p->rtt)
|
||||
json_object_int_add(json_neigh, "estimatedRttInMsecs",
|
||||
p->rtt);
|
||||
if (p->t_start)
|
||||
@ -14690,7 +14689,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 (p->status == Established && p->rtt)
|
||||
if (peer_established(p) && p->rtt)
|
||||
vty_out(vty, "Estimated round trip time: %d ms\n",
|
||||
p->rtt);
|
||||
if (p->t_start)
|
||||
|
@ -155,7 +155,7 @@ static void bgp_start_interface_nbrs(struct bgp *bgp, struct interface *ifp)
|
||||
|
||||
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
|
||||
if (peer->conf_if && (strcmp(peer->conf_if, ifp->name) == 0)
|
||||
&& peer->status != Established) {
|
||||
&& !peer_established(peer)) {
|
||||
if (peer_active(peer))
|
||||
BGP_EVENT_ADD(peer, BGP_Stop);
|
||||
BGP_EVENT_ADD(peer, BGP_Start);
|
||||
|
48
bgpd/bgpd.c
48
bgpd/bgpd.c
@ -2153,7 +2153,7 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi)
|
||||
if (!active && peer_active(peer)) {
|
||||
bgp_timer_set(peer);
|
||||
} else {
|
||||
if (peer->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
if (CHECK_FLAG(peer->cap, PEER_CAP_DYNAMIC_RCV)) {
|
||||
peer->afc_adv[afi][safi] = 1;
|
||||
bgp_capability_send(peer, afi, safi,
|
||||
@ -2276,7 +2276,7 @@ static bool non_peergroup_deactivate_af(struct peer *peer, afi_t afi,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (peer->status == Established) {
|
||||
if (peer_established(peer)) {
|
||||
if (CHECK_FLAG(peer->cap, PEER_CAP_DYNAMIC_RCV)) {
|
||||
peer->afc_adv[afi][safi] = 0;
|
||||
peer->afc_nego[afi][safi] = 0;
|
||||
@ -4111,7 +4111,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->status != Established)
|
||||
if (!peer_established(peer))
|
||||
return;
|
||||
|
||||
if (type == peer_change_reset) {
|
||||
@ -4603,7 +4603,7 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,
|
||||
|
||||
/* Execute action when peer is established. */
|
||||
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)
|
||||
&& peer->status == Established) {
|
||||
&& peer_established(peer)) {
|
||||
if (!set && flag == PEER_FLAG_SOFT_RECONFIG)
|
||||
bgp_clear_adj_in(peer, afi, safi);
|
||||
else {
|
||||
@ -4656,7 +4656,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 (member->status == Established) {
|
||||
if (peer_established(member)) {
|
||||
if (!set && flag == PEER_FLAG_SOFT_RECONFIG)
|
||||
bgp_clear_adj_in(member, afi, safi);
|
||||
else {
|
||||
@ -5058,7 +5058,7 @@ 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->status == Established && peer->afc_nego[afi][safi]) {
|
||||
if (peer_established(peer) && 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);
|
||||
@ -5094,8 +5094,7 @@ int peer_default_originate_set(struct peer *peer, afi_t afi, safi_t safi,
|
||||
}
|
||||
|
||||
/* Update peer route announcements. */
|
||||
if (member->status == Established
|
||||
&& member->afc_nego[afi][safi]) {
|
||||
if (peer_established(member) && member->afc_nego[afi][safi]) {
|
||||
update_group_adjust_peer(
|
||||
peer_af_find(member, afi, safi));
|
||||
bgp_default_originate(member, afi, safi, 0);
|
||||
@ -5135,7 +5134,7 @@ 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->status == Established && peer->afc_nego[afi][safi]) {
|
||||
if (peer_established(peer) && 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);
|
||||
@ -5166,7 +5165,7 @@ 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 (member->status == Established && member->afc_nego[afi][safi]) {
|
||||
if (peer_established(member) && 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);
|
||||
@ -5216,10 +5215,10 @@ static 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->status == Established)
|
||||
if (peer_established(peer))
|
||||
bgp_announce_route(peer, afi, safi);
|
||||
} else {
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
return;
|
||||
|
||||
if (CHECK_FLAG(peer->af_flags[afi][safi],
|
||||
@ -5415,7 +5414,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->status != Established) {
|
||||
if (!peer_established(peer)) {
|
||||
if (peer_active(peer))
|
||||
BGP_EVENT_ADD(peer, BGP_Stop);
|
||||
BGP_EVENT_ADD(peer, BGP_Start);
|
||||
@ -5436,7 +5435,7 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect)
|
||||
member->connect = connect;
|
||||
member->v_connect = connect;
|
||||
|
||||
if (member->status != Established) {
|
||||
if (!peer_established(member)) {
|
||||
if (peer_active(member))
|
||||
BGP_EVENT_ADD(member, BGP_Stop);
|
||||
BGP_EVENT_ADD(member, BGP_Start);
|
||||
@ -5469,7 +5468,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->status != Established) {
|
||||
if (!peer_established(peer)) {
|
||||
if (peer_active(peer))
|
||||
BGP_EVENT_ADD(peer, BGP_Stop);
|
||||
BGP_EVENT_ADD(peer, BGP_Start);
|
||||
@ -5490,7 +5489,7 @@ int peer_timers_connect_unset(struct peer *peer)
|
||||
member->connect = 0;
|
||||
member->v_connect = peer->bgp->default_connect_retry;
|
||||
|
||||
if (member->status != Established) {
|
||||
if (!peer_established(member)) {
|
||||
if (peer_active(member))
|
||||
BGP_EVENT_ADD(member, BGP_Stop);
|
||||
BGP_EVENT_ADD(member, BGP_Start);
|
||||
@ -5517,7 +5516,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->status == Established)
|
||||
if (peer_established(peer))
|
||||
bgp_announce_route_all(peer);
|
||||
|
||||
/* Skip peer-group mechanics for regular peers. */
|
||||
@ -5540,7 +5539,7 @@ int peer_advertise_interval_set(struct peer *peer, uint32_t routeadv)
|
||||
|
||||
/* Update peer route announcements. */
|
||||
update_group_adjust_peer_afs(member);
|
||||
if (member->status == Established)
|
||||
if (peer_established(member))
|
||||
bgp_announce_route_all(member);
|
||||
}
|
||||
|
||||
@ -5574,7 +5573,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->status == Established)
|
||||
if (peer_established(peer))
|
||||
bgp_announce_route_all(peer);
|
||||
|
||||
/* Skip peer-group mechanics for regular peers. */
|
||||
@ -5599,7 +5598,7 @@ int peer_advertise_interval_unset(struct peer *peer)
|
||||
|
||||
/* Update peer route announcements. */
|
||||
update_group_adjust_peer_afs(member);
|
||||
if (member->status == Established)
|
||||
if (peer_established(member))
|
||||
bgp_announce_route_all(member);
|
||||
}
|
||||
|
||||
@ -7144,7 +7143,7 @@ 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->status == Established) && (peer->afc[afi][safi]))
|
||||
if ((peer_established(peer)) && (peer->afc[afi][safi]))
|
||||
bgp_maximum_prefix_overflow(peer, afi, safi, 1);
|
||||
|
||||
/* Skip peer-group mechanics for regular peers. */
|
||||
@ -7181,7 +7180,7 @@ 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 ((member->status == Established) && (member->afc[afi][safi]))
|
||||
if ((peer_established(member)) && (member->afc[afi][safi]))
|
||||
bgp_maximum_prefix_overflow(member, afi, safi, 1);
|
||||
}
|
||||
|
||||
@ -7466,7 +7465,7 @@ int peer_clear_soft(struct peer *peer, afi_t afi, safi_t safi,
|
||||
{
|
||||
struct peer_af *paf;
|
||||
|
||||
if (peer->status != Established)
|
||||
if (!peer_established(peer))
|
||||
return 0;
|
||||
|
||||
if (!peer->afc[afi][safi])
|
||||
@ -7825,8 +7824,7 @@ void bgp_terminate(void)
|
||||
|
||||
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp))
|
||||
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer))
|
||||
if (peer->status == Established
|
||||
|| peer->status == OpenSent
|
||||
if (peer_established(peer) || peer->status == OpenSent
|
||||
|| peer->status == OpenConfirm)
|
||||
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
|
||||
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
|
||||
|
@ -2328,11 +2328,9 @@ static inline char *timestamp_string(time_t ts)
|
||||
return ctime(&tbuf);
|
||||
}
|
||||
|
||||
static inline int peer_established(struct peer *peer)
|
||||
static inline bool peer_established(struct peer *peer)
|
||||
{
|
||||
if (peer->status == Established)
|
||||
return 1;
|
||||
return 0;
|
||||
return peer->status == Established;
|
||||
}
|
||||
|
||||
static inline int peer_dynamic_neighbor(struct peer *peer)
|
||||
|
Loading…
Reference in New Issue
Block a user