summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_addpath.c6
-rw-r--r--bgpd/bgp_attr.c60
-rw-r--r--bgpd/bgp_bfd.c6
-rw-r--r--bgpd/bgp_debug.c2
-rw-r--r--bgpd/bgp_evpn.c9
-rw-r--r--bgpd/bgp_fsm.c32
-rw-r--r--bgpd/bgp_main.c2
-rw-r--r--bgpd/bgp_mpath.c5
-rw-r--r--bgpd/bgp_nht.c28
-rw-r--r--bgpd/bgp_open.c5
-rw-r--r--bgpd/bgp_packet.c2
-rw-r--r--bgpd/bgp_route.c86
-rw-r--r--bgpd/bgp_routemap.c2
-rw-r--r--bgpd/bgp_updgrp.c2
-rw-r--r--bgpd/bgp_updgrp_adv.c3
-rw-r--r--bgpd/bgp_vty.c219
-rw-r--r--bgpd/bgp_zebra.c9
-rw-r--r--bgpd/bgpd.c45
-rw-r--r--bgpd/bgpd.h24
-rw-r--r--bgpd/rfapi/rfapi_import.c6
-rw-r--r--eigrpd/eigrp_main.c2
-rw-r--r--lib/csv.c18
-rw-r--r--lib/imsg-buffer.c34
-rw-r--r--lib/imsg.c40
-rw-r--r--lib/openbsd-tree.c4
-rw-r--r--lib/printf/printf-pos.c36
-rw-r--r--lib/printf/vfprintf.c6
-rw-r--r--lib/ptm_lib.c20
-rw-r--r--lib/routemap.c2
-rw-r--r--lib/typerb.c2
-rw-r--r--ospf6d/ospf6_area.c2
-rw-r--r--ospf6d/ospf6_intra.c14
-rw-r--r--ospf6d/ospf6_route.c2
-rw-r--r--ospfd/ospf_main.c2
-rw-r--r--ripd/rip_main.c2
-rw-r--r--scripts/coccinelle/replace_bgp_flag_functions.cocci14
-rw-r--r--scripts/coccinelle/return_without_parenthesis.cocci9
-rw-r--r--tests/bgpd/test_aspath.c2
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py9
-rwxr-xr-xtests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py36
-rwxr-xr-xtests/topotests/ldp-topo1/test_ldp_topo1.py28
-rw-r--r--vtysh/vtysh.c4
-rw-r--r--vtysh/vtysh_config.c2
-rw-r--r--vtysh/vtysh_main.c2
-rw-r--r--zebra/redistribute.c4
-rw-r--r--zebra/zebra_mpls_openbsd.c2
-rw-r--r--zebra/zebra_ptm.c6
-rw-r--r--zebra/zebra_routemap.c2
48 files changed, 478 insertions, 381 deletions
diff --git a/bgpd/bgp_addpath.c b/bgpd/bgp_addpath.c
index e7e7c3cc1f..aaa77b04dc 100644
--- a/bgpd/bgp_addpath.c
+++ b/bgpd/bgp_addpath.c
@@ -380,11 +380,13 @@ void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi,
if (addpath_type != BGP_ADDPATH_NONE) {
if (bgp_addpath_dmed_required(addpath_type)) {
- if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
+ if (!CHECK_FLAG(bgp->flags,
+ BGP_FLAG_DETERMINISTIC_MED)) {
zlog_warn(
"%s: enabling bgp deterministic-med, this is required for addpath-tx-bestpath-per-AS",
peer->host);
- bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED);
+ SET_FLAG(bgp->flags,
+ BGP_FLAG_DETERMINISTIC_MED);
bgp_recalculate_all_bestpaths(bgp);
}
}
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index c0d88fc521..f00bb2b3cd 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -933,7 +933,7 @@ struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin,
/* If we are not shutting down ourselves and we are
* aggregating a route that contains the GSHUT community we
* need to remove that community when creating the aggregate */
- if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)
&& community_include(community, gshut)) {
community_del_val(community, &gshut);
}
@@ -952,9 +952,8 @@ struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin,
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
}
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&attr);
- }
attr.label_index = BGP_INVALID_LABEL_INDEX;
attr.label = MPLS_INVALID_LABEL;
@@ -996,13 +995,13 @@ struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin,
return NULL;
}
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&attr_tmp);
new = bgp_attr_intern(&attr_tmp);
} else {
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&attr);
new = bgp_attr_intern(&attr);
@@ -1177,7 +1176,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
return BGP_ATTR_PARSE_PROCEED;
/* Core attributes, particularly ones which may influence route
- * selection, should always cause session resets
+ * selection, should be treat-as-withdraw.
*/
case BGP_ATTR_ORIGIN:
case BGP_ATTR_AS_PATH:
@@ -1185,11 +1184,13 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
case BGP_ATTR_MULTI_EXIT_DISC:
case BGP_ATTR_LOCAL_PREF:
case BGP_ATTR_COMMUNITIES:
+ case BGP_ATTR_EXT_COMMUNITIES:
+ case BGP_ATTR_LARGE_COMMUNITIES:
case BGP_ATTR_ORIGINATOR_ID:
case BGP_ATTR_CLUSTER_LIST:
+ return BGP_ATTR_PARSE_WITHDRAW;
case BGP_ATTR_MP_REACH_NLRI:
case BGP_ATTR_MP_UNREACH_NLRI:
- case BGP_ATTR_EXT_COMMUNITIES:
bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR, subcode,
notify_datap, length);
return BGP_ATTR_PARSE_ERROR;
@@ -1422,9 +1423,7 @@ static bgp_attr_parse_ret_t bgp_attr_aspath_check(struct peer *const peer,
&& aspath_confed_check(attr->aspath))) {
flog_err(EC_BGP_ATTR_MAL_AS_PATH, "Malformed AS path from %s",
peer->host);
- bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_MAL_AS_PATH);
- return BGP_ATTR_PARSE_ERROR;
+ return BGP_ATTR_PARSE_WITHDRAW;
}
/* First AS check for EBGP. */
@@ -1434,9 +1433,7 @@ static bgp_attr_parse_ret_t bgp_attr_aspath_check(struct peer *const peer,
flog_err(EC_BGP_ATTR_FIRST_AS,
"%s incorrect first AS (must be %u)",
peer->host, peer->as);
- bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_MAL_AS_PATH);
- return BGP_ATTR_PARSE_ERROR;
+ return BGP_ATTR_PARSE_WITHDRAW;
}
}
@@ -1563,8 +1560,12 @@ bgp_attr_local_pref(struct bgp_attr_parser_args *args)
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
- /* Length check. */
- if (length != 4) {
+ /* if received from an internal neighbor, it SHALL be considered
+ * malformed if its length is not equal to 4. If malformed, the
+ * UPDATE message SHALL be handled using the approach of "treat-as-
+ * withdraw".
+ */
+ if (peer->sort == BGP_PEER_IBGP && length != 4) {
flog_err(EC_BGP_ATTR_LEN,
"LOCAL_PREF attribute length isn't 4 [%u]", length);
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
@@ -1618,7 +1619,8 @@ static int bgp_attr_aggregator(struct bgp_attr_parser_args *args)
int wantedlen = 6;
/* peer with AS4 will send 4 Byte AS, peer without will send 2 Byte */
- if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV))
+ if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV)
+ && CHECK_FLAG(peer->cap, PEER_CAP_AS4_ADV))
wantedlen = 8;
if (length != wantedlen) {
@@ -1793,6 +1795,9 @@ bgp_attr_community(struct bgp_attr_parser_args *args)
/* XXX: fix community_parse to use stream API and remove this */
stream_forward_getp(peer->curr, length);
+ /* The Community attribute SHALL be considered malformed if its
+ * length is not a non-zero multiple of 4.
+ */
if (!attr->community)
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
args->total);
@@ -1810,7 +1815,11 @@ bgp_attr_originator_id(struct bgp_attr_parser_args *args)
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
- /* Length check. */
+ /* if received from an internal neighbor, it SHALL be considered
+ * malformed if its length is not equal to 4. If malformed, the
+ * UPDATE message SHALL be handled using the approach of "treat-as-
+ * withdraw".
+ */
if (length != 4) {
flog_err(EC_BGP_ATTR_LEN, "Bad originator ID length %d",
length);
@@ -1834,7 +1843,11 @@ bgp_attr_cluster_list(struct bgp_attr_parser_args *args)
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
- /* Check length. */
+ /* if received from an internal neighbor, it SHALL be considered
+ * malformed if its length is not a non-zero multiple of 4. If
+ * malformed, the UPDATE message SHALL be handled using the approach
+ * of "treat-as-withdraw".
+ */
if (length % 4) {
flog_err(EC_BGP_ATTR_LEN, "Bad cluster list length %d", length);
@@ -2151,6 +2164,9 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
/* XXX: fix ecommunity_parse to use stream API */
stream_forward_getp(peer->curr, length);
+ /* The Extended Community attribute SHALL be considered malformed if
+ * its length is not a non-zero multiple of 8.
+ */
if (!attr->ecommunity)
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
args->total);
@@ -2755,14 +2771,14 @@ static int bgp_attr_check(struct peer *peer, struct attr *attr)
&& !CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
type = BGP_ATTR_LOCAL_PREF;
+ /* If any of the well-known mandatory attributes are not present
+ * in an UPDATE message, then "treat-as-withdraw" MUST be used.
+ */
if (type) {
flog_warn(EC_BGP_MISSING_ATTRIBUTE,
"%s Missing well-known attribute %s.", peer->host,
lookup_msg(attr_str, type, NULL));
- bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_MISS_ATTR, &type,
- 1);
- return BGP_ATTR_PARSE_ERROR;
+ return BGP_ATTR_PARSE_WITHDRAW;
}
return BGP_ATTR_PARSE_PROCEED;
}
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
index 0ed6057eac..80ef43f0d3 100644
--- a/bgpd/bgp_bfd.c
+++ b/bgpd/bgp_bfd.c
@@ -116,10 +116,10 @@ static void bgp_bfd_peer_sendmsg(struct peer *peer, int command)
* and bfd controlplane check not configured is not kept
* keep bfd independent controlplane bit set to 1
*/
- if (!bgp_flag_check(peer->bgp, BGP_FLAG_GRACEFUL_RESTART)
- && !bgp_flag_check(peer->bgp, BGP_FLAG_GR_PRESERVE_FWD)
+ if (!CHECK_FLAG(peer->bgp->flags, BGP_FLAG_GRACEFUL_RESTART)
+ && !CHECK_FLAG(peer->bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)
&& !CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_CHECK_CONTROLPLANE))
- SET_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON);
+ SET_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON);
cbit = CHECK_FLAG(bfd_info->flags, BFD_FLAG_BFD_CBIT_ON);
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index f3bd9f59ff..c69bc52e47 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -511,7 +511,7 @@ void bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify,
char msg_buf[1024];
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS)
- || bgp_flag_check(peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) {
+ || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) {
code_str = bgp_notify_code_str(bgp_notify->code);
subcode_str = bgp_notify_subcode_str(bgp_notify->code,
bgp_notify->subcode);
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index a93f81a8d8..76c7d93ad1 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -2526,13 +2526,13 @@ static int handle_tunnel_ip_change(struct bgp *bgp, struct bgpevpn *vpn,
static struct bgp_path_info *
bgp_create_evpn_bgp_path_info(struct bgp_path_info *parent_pi,
- struct bgp_node *rn)
+ struct bgp_node *rn, struct attr *attr)
{
struct attr *attr_new;
struct bgp_path_info *pi;
/* Add (or update) attribute to hash. */
- attr_new = bgp_attr_intern(parent_pi->attr);
+ attr_new = bgp_attr_intern(attr);
/* Create new route with its attribute. */
pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0, parent_pi->peer,
@@ -2675,7 +2675,7 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
break;
if (!pi)
- pi = bgp_create_evpn_bgp_path_info(parent_pi, rn);
+ pi = bgp_create_evpn_bgp_path_info(parent_pi, rn, &attr);
else {
if (attrhash_cmp(pi->attr, &attr)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
@@ -2744,7 +2744,8 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
if (!pi) {
/* Create an info */
- (void)bgp_create_evpn_bgp_path_info(parent_pi, rn);
+ (void)bgp_create_evpn_bgp_path_info(parent_pi, rn,
+ parent_pi->attr);
} else {
if (attrhash_cmp(pi->attr, parent_pi->attr)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index ac8fe5e914..e0a9e3e4f0 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -103,7 +103,7 @@ static int bgp_peer_reg_with_nht(struct peer *peer)
if (peer->sort == BGP_PEER_EBGP && peer->ttl == BGP_DEFAULT_TTL
&& !CHECK_FLAG(peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)
- && !bgp_flag_check(peer->bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
+ && !CHECK_FLAG(peer->bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
connected = 1;
return bgp_find_or_add_nexthop(
@@ -576,7 +576,9 @@ const char *const peer_down_str[] = {"",
"Waiting for NHT",
"Waiting for Peer IPv6 LLA",
"Waiting for VRF to be initialized",
- "No AFI/SAFI activated for peer"};
+ "No AFI/SAFI activated for peer",
+ "AS Set config change",
+ "Waiting for peer OPEN"};
static int bgp_graceful_restart_timer_expire(struct thread *thread)
{
@@ -1144,7 +1146,8 @@ int bgp_stop(struct peer *peer)
peer->dropped++;
/* bgp log-neighbor-changes of neighbor Down */
- if (bgp_flag_check(peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) {
+ if (CHECK_FLAG(peer->bgp->flags,
+ BGP_FLAG_LOG_NEIGHBOR_CHANGES)) {
struct vrf *vrf = vrf_lookup_by_id(peer->bgp->vrf_id);
zlog_info(
@@ -1722,7 +1725,7 @@ static int bgp_update_gr_info(struct peer *peer, afi_t afi, safi_t safi)
if (BGP_PEER_GRACEFUL_RESTART_CAPABLE(peer)
&& BGP_PEER_RESTARTING_MODE(peer)) {
/* Check if the forwarding state is preserved */
- if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) {
gr_info = &(bgp->gr_info[afi][safi]);
ret = bgp_start_deferral_timer(bgp, afi, safi, gr_info);
}
@@ -1768,15 +1771,14 @@ static int bgp_establish(struct peer *peer)
bgp_fsm_change_status(peer, Established);
/* bgp log-neighbor-changes of neighbor Up */
- if (bgp_flag_check(peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) {
+ if (CHECK_FLAG(peer->bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) {
struct vrf *vrf = vrf_lookup_by_id(peer->bgp->vrf_id);
- zlog_info("%%ADJCHANGE: neighbor %s(%s) in vrf %s Up",
- peer->host,
- (peer->hostname) ? peer->hostname : "Unknown",
- vrf ? ((vrf->vrf_id != VRF_DEFAULT)
- ? vrf->name
- : VRF_DEFAULT_NAME)
- : "");
+ zlog_info(
+ "%%ADJCHANGE: neighbor %s(%s) in vrf %s Up", peer->host,
+ (peer->hostname) ? peer->hostname : "Unknown",
+ vrf ? ((vrf->vrf_id != VRF_DEFAULT) ? vrf->name
+ : VRF_DEFAULT_NAME)
+ : "");
}
/* assign update-group/subgroup */
update_group_adjust_peer_afs(peer);
@@ -1823,8 +1825,8 @@ static int bgp_establish(struct peer *peer)
if (BGP_PEER_GRACEFUL_RESTART_CAPABLE(
peer)
&& BGP_PEER_RESTARTING_MODE(peer)
- && bgp_flag_check(
- peer->bgp,
+ && CHECK_FLAG(
+ peer->bgp->flags,
BGP_FLAG_GR_PRESERVE_FWD))
peer->bgp->gr_info[afi][safi]
.eor_required++;
@@ -1993,7 +1995,7 @@ void bgp_fsm_event_update(struct peer *peer, int valid)
case OpenSent:
case OpenConfirm:
case Established:
- if (!valid && (peer->gtsm_hops == 1))
+ if (!valid && (peer->gtsm_hops == BGP_GTSM_HOPS_CONNECTED))
BGP_EVENT_ADD(peer, TCP_fatal_error);
case Clearing:
case Deleted:
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 74e561c743..c4ece2f082 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -493,5 +493,5 @@ int main(int argc, char **argv)
frr_run(bm->master);
/* Not reached. */
- return (0);
+ return 0;
}
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 6bc8134f36..9e73acdc01 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -721,8 +721,9 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
attr = *new_best->attr;
- if (new_best->peer && bgp_flag_check(new_best->peer->bgp,
- BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
+ if (new_best->peer
+ && CHECK_FLAG(new_best->peer->bgp->flags,
+ BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
/* aggregate attribute from multipath constituents */
aspath = aspath_dup(attr.aspath);
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index a50fc7d697..3060fe482c 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -186,12 +186,13 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
SET_FLAG(bnc->flags, BGP_STATIC_ROUTE);
/* If we're toggling the type, re-register */
- if ((bgp_flag_check(bgp_route, BGP_FLAG_IMPORT_CHECK))
+ if ((CHECK_FLAG(bgp_route->flags, BGP_FLAG_IMPORT_CHECK))
&& !CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH)) {
SET_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH);
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
- } else if ((!bgp_flag_check(bgp_route, BGP_FLAG_IMPORT_CHECK))
+ } else if ((!CHECK_FLAG(bgp_route->flags,
+ BGP_FLAG_IMPORT_CHECK))
&& CHECK_FLAG(bnc->flags,
BGP_STATIC_ROUTE_EXACT_MATCH)) {
UNSET_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH);
@@ -788,13 +789,22 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
bgp_process(bgp_path, rn, afi, safi);
}
- if (peer && !CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED)) {
- if (BGP_DEBUG(nht, NHT))
- zlog_debug("%s: Updating peer (%s(%s)) status with NHT",
- __FUNCTION__, peer->host,
- peer->bgp->name_pretty);
- bgp_fsm_event_update(peer, bgp_isvalid_nexthop(bnc));
- SET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
+ if (peer) {
+ int valid_nexthops = bgp_isvalid_nexthop(bnc);
+
+ if (valid_nexthops)
+ peer->last_reset = PEER_DOWN_WAITING_OPEN;
+ else
+ peer->last_reset = PEER_DOWN_WAITING_NHT;
+
+ if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED)) {
+ if (BGP_DEBUG(nht, NHT))
+ zlog_debug("%s: Updating peer (%s(%s)) status with NHT",
+ __FUNCTION__, peer->host,
+ peer->bgp->name_pretty);
+ bgp_fsm_event_update(peer, valid_nexthops);
+ SET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
+ }
}
RESET_FLAG(bnc->change_flags);
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 473a51c5a0..906083f755 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -1341,7 +1341,7 @@ static void bgp_peer_send_gr_capability(struct stream *s, struct peer *peer,
* only when GR config is present
*/
if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) {
- if (bgp_flag_check(peer->bgp, BGP_FLAG_GR_PRESERVE_FWD)
+ if (CHECK_FLAG(peer->bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)
&& BGP_DEBUG(graceful_restart, GRACEFUL_RESTART))
zlog_debug("[BGP_GR] F bit Set");
@@ -1361,7 +1361,8 @@ static void bgp_peer_send_gr_capability(struct stream *s, struct peer *peer,
&pkt_safi);
stream_putw(s, pkt_afi);
stream_putc(s, pkt_safi);
- if (bgp_flag_check(peer->bgp, BGP_FLAG_GR_PRESERVE_FWD))
+ if (CHECK_FLAG(peer->bgp->flags,
+ BGP_FLAG_GR_PRESERVE_FWD))
stream_putc(s, RESTART_F_BIT);
else
stream_putc(s, 0);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index afb3a09b6b..c72f7226e2 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -973,7 +973,7 @@ static int bgp_collision_detect(struct peer *new, struct in_addr remote_id)
if (peer->status == Established || peer->status == Clearing) {
bgp_notify_send(new, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_COLLISION_RESOLUTION);
- return (-1);
+ return -1;
} else if ((peer->status == OpenConfirm)
|| (peer->status == OpenSent)) {
/* 1. The BGP Identifier of the local system is compared
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 5e41f82d4a..34580788bd 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -501,7 +501,7 @@ static uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp)
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
return attr->med;
else {
- if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST))
return BGP_MED_MAX;
else
return 0;
@@ -747,11 +747,11 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
}
/* 4. AS path length check. */
- if (!bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) {
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) {
int exist_hops = aspath_count_hops(existattr->aspath);
int exist_confeds = aspath_count_confeds(existattr->aspath);
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) {
int aspath_hops;
aspath_hops = aspath_count_hops(newattr->aspath);
@@ -832,8 +832,8 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
&& aspath_count_hops(newattr->aspath) == 0
&& aspath_count_hops(existattr->aspath) == 0);
- if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
- || (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) && confed_as_route)
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)
+ || (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) && confed_as_route)
|| aspath_cmp_left(newattr->aspath, existattr->aspath)
|| aspath_cmp_left_confed(newattr->aspath, existattr->aspath)
|| internal_as_route) {
@@ -978,8 +978,8 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
zlog_debug(
"%s: %s and %s cannot be multipath, one has a label while the other does not",
pfx_buf, new_buf, exist_buf);
- } else if (bgp_flag_check(bgp,
- BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
+ } else if (CHECK_FLAG(bgp->flags,
+ BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
/*
* For the two paths, all comparison steps till IGP
@@ -1041,7 +1041,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
first (the oldest one). This step minimizes route-flap, since a
newer path won't displace an older one, even if it was the
preferred route based on the additional decision criteria below. */
- if (!bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)
&& new_sort == BGP_PEER_EBGP && exist_sort == BGP_PEER_EBGP) {
if (CHECK_FLAG(new->flags, BGP_PATH_SELECTED)) {
*reason = bgp_path_selection_older;
@@ -1762,7 +1762,8 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
check
is already done. So there is noting to do. */
/* no bgp client-to-client reflection check. */
- if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
+ if (CHECK_FLAG(bgp->flags,
+ BGP_FLAG_NO_CLIENT_TO_CLIENT))
if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT))
return 0;
@@ -1894,8 +1895,8 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
* of the reflected IBGP routes unless explicitly allowed.
*/
if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
- && !bgp_flag_check(bgp,
- BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+ && !CHECK_FLAG(bgp->flags,
+ BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
dummy_attr = *attr;
rmap_path.attr = &dummy_attr;
}
@@ -1945,7 +1946,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if (aspath_check_as_sets(attr->aspath))
return 0;
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
if (peer->sort == BGP_PEER_IBGP
|| peer->sort == BGP_PEER_CONFED) {
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
@@ -2105,7 +2106,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
/* bgp deterministic-med */
new_select = NULL;
- if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
/* Clear BGP_PATH_DMED_SELECTED for all paths */
for (pi1 = bgp_node_get_bgp_path_info(rn); pi1;
@@ -2212,7 +2213,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
continue;
}
- if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)
&& (!CHECK_FLAG(pi->flags, BGP_PATH_DMED_SELECTED))) {
bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK);
if (debug)
@@ -2445,14 +2446,14 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
char pfx_buf[PREFIX2STR_BUFFER];
int debug = 0;
- if (bgp_flag_check(bgp, BGP_FLAG_DELETE_IN_PROGRESS)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
if (rn)
debug = bgp_debug_bestpath(&rn->p);
if (debug) {
prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
zlog_debug(
- "%s: bgp delete in progress, ignoring event, p=%s",
- __func__, pfx_buf);
+ "%s: bgp delete in progress, ignoring event, p=%s",
+ __func__, pfx_buf);
}
return;
}
@@ -3418,10 +3419,9 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
/* If graceful-shutdown is configured then add the GSHUT
* community to all paths received from eBGP peers */
- } else if (bgp_flag_check(peer->bgp,
- BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ } else if (CHECK_FLAG(peer->bgp->flags,
+ BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&new_attr);
- }
}
if (pi) {
@@ -3707,8 +3707,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
&& peer->ttl == BGP_DEFAULT_TTL
&& !CHECK_FLAG(peer->flags,
PEER_FLAG_DISABLE_CONNECTED_CHECK)
- && !bgp_flag_check(
- bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
+ && !CHECK_FLAG(bgp->flags,
+ BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
connected = 1;
else
connected = 0;
@@ -3862,7 +3862,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
&& peer->ttl == BGP_DEFAULT_TTL
&& !CHECK_FLAG(peer->flags,
PEER_FLAG_DISABLE_CONNECTED_CHECK)
- && !bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
+ && !CHECK_FLAG(bgp->flags,
+ BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
connected = 1;
else
connected = 0;
@@ -4953,13 +4954,13 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,
return;
}
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&attr_tmp);
attr_new = bgp_attr_intern(&attr_tmp);
} else {
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&attr);
attr_new = bgp_attr_intern(&attr);
@@ -4973,7 +4974,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,
if (pi) {
if (attrhash_cmp(pi->attr, attr_new)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)
- && !bgp_flag_check(bgp, BGP_FLAG_FORCE_STATIC_PROCESS)) {
+ && !CHECK_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS)) {
bgp_unlock_node(rn);
bgp_attr_unintern(&attr_new);
aspath_unintern(&attr.aspath);
@@ -5018,7 +5019,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,
#endif
/* Nexthop reachability check. */
- if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
&& (safi == SAFI_UNICAST
|| safi == SAFI_LABELED_UNICAST)) {
@@ -5077,7 +5078,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,
new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self,
attr_new, rn);
/* Nexthop reachability check. */
- if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
&& (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST)) {
if (bgp_find_or_add_nexthop(bgp, bgp, afi, new, NULL, 0))
bgp_path_info_set_flag(rn, new, BGP_PATH_VALID);
@@ -5596,7 +5597,7 @@ void bgp_static_redo_import_check(struct bgp *bgp)
struct bgp_static *bgp_static;
/* Use this flag to force reprocessing of the route */
- bgp_flag_set(bgp, BGP_FLAG_FORCE_STATIC_PROCESS);
+ SET_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS);
FOREACH_AFI_SAFI (afi, safi) {
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
rn = bgp_route_next(rn)) {
@@ -5623,7 +5624,7 @@ void bgp_static_redo_import_check(struct bgp *bgp)
}
}
}
- bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS);
}
static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi,
@@ -5636,8 +5637,8 @@ static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi,
/* Do not install the aggregate route if BGP is in the
* process of termination.
*/
- if (bgp_flag_check(bgp, BGP_FLAG_DELETE_IN_PROGRESS) ||
- (bgp->peer_self == NULL))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)
+ || (bgp->peer_self == NULL))
return;
table = bgp->rib[afi][safi];
@@ -6146,8 +6147,8 @@ void bgp_aggregate_route(struct bgp *bgp, struct prefix *p,
/* If the bgp instance is being deleted or self peer is deleted
* then do not create aggregate route
*/
- if (bgp_flag_check(bgp, BGP_FLAG_DELETE_IN_PROGRESS) ||
- (bgp->peer_self == NULL))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)
+ || (bgp->peer_self == NULL))
return;
/* ORIGIN attribute: If at least one route among routes that are
@@ -7101,7 +7102,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
}
}
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(&attr_new);
bn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi,
@@ -7392,7 +7393,8 @@ static void route_vty_short_status_out(struct vty *vty,
static char *bgp_nexthop_hostname(struct peer *peer, struct attr *attr)
{
- if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)
+ if (peer->hostname
+ && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME)
&& !(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
return peer->hostname;
return NULL;
@@ -8406,7 +8408,7 @@ static void route_vty_out_advertised_to(struct vty *vty, struct peer *peer,
}
if (peer->hostname
- && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) {
+ && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) {
if (peer->conf_if)
vty_out(vty, " %s(%s)", peer->hostname,
peer->conf_if);
@@ -8828,8 +8830,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
} else {
if (path->peer->conf_if) {
if (path->peer->hostname
- && bgp_flag_check(path->peer->bgp,
- BGP_FLAG_SHOW_HOSTNAME))
+ && CHECK_FLAG(path->peer->bgp->flags,
+ BGP_FLAG_SHOW_HOSTNAME))
vty_out(vty, " from %s(%s)",
path->peer->hostname,
path->peer->conf_if);
@@ -8838,8 +8840,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
path->peer->conf_if);
} else {
if (path->peer->hostname
- && bgp_flag_check(path->peer->bgp,
- BGP_FLAG_SHOW_HOSTNAME))
+ && CHECK_FLAG(path->peer->bgp->flags,
+ BGP_FLAG_SHOW_HOSTNAME))
vty_out(vty, " from %s(%s)",
path->peer->hostname,
path->peer->host);
@@ -11333,7 +11335,7 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi,
} else {
if (peer->hostname
- && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) {
+ && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) {
vty_out(vty, "Prefix counts for %s/%s, %s\n",
peer->hostname, peer->host,
get_afi_safi_str(afi, safi, false));
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index f5de9ac8c6..5e6c782400 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3706,7 +3706,7 @@ int bgp_route_map_update_timer(struct thread *thread)
route_map_walk_update_list(bgp_route_map_process_update_cb);
- return (0);
+ return 0;
}
static void bgp_route_map_mark_update(const char *rmap_name)
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index 3dbc675212..50824cd6dd 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -1780,7 +1780,7 @@ int update_group_refresh_default_originate_route_map(struct thread *thread)
THREAD_TIMER_OFF(bgp->t_rmap_def_originate_eval);
bgp_unlock(bgp);
- return (0);
+ return 0;
}
/*
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index 26dda8ebda..34f80def8c 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -783,9 +783,8 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
if (!CHECK_FLAG(subgrp->sflags,
SUBGRP_STATUS_DEFAULT_ORIGINATE)) {
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
bgp_attr_add_gshut_community(new_attr);
- }
SET_FLAG(subgrp->sflags,
SUBGRP_STATUS_DEFAULT_ORIGINATE);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index f1ec9b4932..5e2c5d07db 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -422,13 +422,13 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,
DFLT_BGP_CONNECT_RETRY);
if (DFLT_BGP_IMPORT_CHECK)
- bgp_flag_set(*bgp, BGP_FLAG_IMPORT_CHECK);
+ SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK);
if (DFLT_BGP_SHOW_HOSTNAME)
- bgp_flag_set(*bgp, BGP_FLAG_SHOW_HOSTNAME);
+ SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME);
if (DFLT_BGP_LOG_NEIGHBOR_CHANGES)
- bgp_flag_set(*bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+ SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
if (DFLT_BGP_DETERMINISTIC_MED)
- bgp_flag_set(*bgp, BGP_FLAG_DETERMINISTIC_MED);
+ SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED);
ret = BGP_SUCCESS;
}
@@ -1992,7 +1992,7 @@ DEFUN (bgp_client_to_client_reflection,
"reflection of routes allowed\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
bgp_clear_star_soft_out(vty, bgp->name);
return CMD_SUCCESS;
@@ -2007,7 +2007,7 @@ DEFUN (no_bgp_client_to_client_reflection,
"reflection of routes allowed\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
+ SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
bgp_clear_star_soft_out(vty, bgp->name);
return CMD_SUCCESS;
@@ -2021,7 +2021,7 @@ DEFUN (bgp_always_compare_med,
"Allow comparing MED from different neighbors\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
+ SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2035,7 +2035,7 @@ DEFUN (no_bgp_always_compare_med,
"Allow comparing MED from different neighbors\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2123,8 +2123,8 @@ DEFUN (bgp_deterministic_med,
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
- bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED);
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
bgp_recalculate_all_bestpaths(bgp);
}
@@ -2145,7 +2145,7 @@ DEFUN (no_bgp_deterministic_med,
struct peer *peer;
struct listnode *node, *nnode;
- if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
bestpath_per_as_used = 0;
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
@@ -2165,7 +2165,7 @@ DEFUN (no_bgp_deterministic_med,
"bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
return CMD_WARNING_CONFIG_FAILED;
} else {
- bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
bgp_recalculate_all_bestpaths(bgp);
}
}
@@ -2277,9 +2277,9 @@ DEFUN (bgp_graceful_restart_select_defer_time,
defer_time = strtoul(argv[idx_number]->arg, NULL, 10);
bgp->select_defer_time = defer_time;
if (defer_time == 0)
- bgp_flag_set(bgp, BGP_FLAG_SELECT_DEFER_DISABLE);
+ SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE);
else
- bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE);
return CMD_SUCCESS;
}
@@ -2326,7 +2326,7 @@ DEFUN (no_bgp_graceful_restart_select_defer_time,
VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME;
- bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE);
return CMD_SUCCESS;
}
@@ -2339,7 +2339,7 @@ DEFUN (bgp_graceful_restart_preserve_fw,
"Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD);
+ SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD);
return CMD_SUCCESS;
}
@@ -2352,7 +2352,7 @@ DEFUN (no_bgp_graceful_restart_preserve_fw,
"Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD);
return CMD_SUCCESS;
}
@@ -2646,7 +2646,7 @@ DEFUN_HIDDEN (bgp_graceful_restart_disable_eor,
"Disable EOR Check\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_GR_DISABLE_EOR);
+ SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR);
return CMD_SUCCESS;
}
@@ -2660,7 +2660,7 @@ DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor,
"Disable EOR Check\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_GR_DISABLE_EOR);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR);
return CMD_SUCCESS;
}
@@ -2714,8 +2714,8 @@ DEFUN (bgp_graceful_shutdown,
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
- bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN);
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
bgp_static_redo_import_check(bgp);
bgp_redistribute_redo(bgp);
bgp_clear_star_soft_out(vty, bgp->name);
@@ -2734,8 +2734,8 @@ DEFUN (no_bgp_graceful_shutdown,
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
- bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN);
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
bgp_static_redo_import_check(bgp);
bgp_redistribute_redo(bgp);
bgp_clear_star_soft_out(vty, bgp->name);
@@ -2753,7 +2753,7 @@ DEFUN (bgp_fast_external_failover,
"Immediately reset session if a link to a directly connected external peer goes down\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
return CMD_SUCCESS;
}
@@ -2765,7 +2765,7 @@ DEFUN (no_bgp_fast_external_failover,
"Immediately reset session if a link to a directly connected external peer goes down\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+ SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
return CMD_SUCCESS;
}
@@ -2778,7 +2778,7 @@ DEFUN (bgp_bestpath_compare_router_id,
"Compare router-id for identical EBGP paths\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID);
+ SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2793,7 +2793,7 @@ DEFUN (no_bgp_bestpath_compare_router_id,
"Compare router-id for identical EBGP paths\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2809,7 +2809,7 @@ DEFUN (bgp_bestpath_aspath_ignore,
"Ignore as-path length in selecting a route\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE);
+ SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2825,7 +2825,7 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
"Ignore as-path length in selecting a route\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2841,7 +2841,7 @@ DEFUN (bgp_bestpath_aspath_confed,
"Compare path lengths including confederation sets & sequences in selecting a route\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED);
+ SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2857,7 +2857,7 @@ DEFUN (no_bgp_bestpath_aspath_confed,
"Compare path lengths including confederation sets & sequences in selecting a route\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2876,14 +2876,14 @@ DEFUN (bgp_bestpath_aspath_multipath_relax,
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx = 0;
- bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
+ SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
/* no-as-set is now the default behavior so we can silently
* ignore it */
if (argv_find(argv, argc, "as-set", &idx))
- bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+ SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
else
- bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
bgp_recalculate_all_bestpaths(bgp);
@@ -2902,8 +2902,8 @@ DEFUN (no_bgp_bestpath_aspath_multipath_relax,
"Do not generate an AS_SET\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
- bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
bgp_recalculate_all_bestpaths(bgp);
return CMD_SUCCESS;
@@ -2917,7 +2917,7 @@ DEFUN (bgp_log_neighbor_changes,
"Log neighbor up/down and reset reason\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+ SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
return CMD_SUCCESS;
}
@@ -2929,7 +2929,7 @@ DEFUN (no_bgp_log_neighbor_changes,
"Log neighbor up/down and reset reason\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
return CMD_SUCCESS;
}
@@ -2949,10 +2949,10 @@ DEFUN (bgp_bestpath_med,
int idx = 0;
if (argv_find(argv, argc, "confed", &idx))
- bgp_flag_set(bgp, BGP_FLAG_MED_CONFED);
+ SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
idx = 0;
if (argv_find(argv, argc, "missing-as-worst", &idx))
- bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST);
+ SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
bgp_recalculate_all_bestpaths(bgp);
@@ -2975,10 +2975,10 @@ DEFUN (no_bgp_bestpath_med,
int idx = 0;
if (argv_find(argv, argc, "confed", &idx))
- bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
idx = 0;
if (argv_find(argv, argc, "missing-as-worst", &idx))
- bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
bgp_recalculate_all_bestpaths(bgp);
@@ -2995,7 +2995,7 @@ DEFUN (no_bgp_default_ipv4_unicast,
"Activate ipv4-unicast for a peer by default\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4);
+ SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4);
return CMD_SUCCESS;
}
@@ -3007,7 +3007,7 @@ DEFUN (bgp_default_ipv4_unicast,
"Activate ipv4-unicast for a peer by default\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4);
return CMD_SUCCESS;
}
@@ -3020,7 +3020,7 @@ DEFUN (bgp_default_show_hostname,
"Show hostname in certain command outputs\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME);
+ SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
return CMD_SUCCESS;
}
@@ -3033,7 +3033,7 @@ DEFUN (no_bgp_default_show_hostname,
"Show hostname in certain command outputs\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
return CMD_SUCCESS;
}
@@ -3046,8 +3046,8 @@ DEFUN (bgp_network_import_check,
"Check BGP network route exists in IGP\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) {
- bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK);
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
bgp_static_redo_import_check(bgp);
}
@@ -3070,8 +3070,8 @@ DEFUN (no_bgp_network_import_check,
"Check BGP network route exists in IGP\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) {
- bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK);
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
bgp_static_redo_import_check(bgp);
}
@@ -3158,8 +3158,8 @@ DEFUN (bgp_rr_allow_outbound_policy,
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
- bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
update_group_announce_rrclients(bgp);
bgp_clear_star_soft_out(vty, bgp->name);
}
@@ -3177,8 +3177,8 @@ DEFUN (no_bgp_rr_allow_outbound_policy,
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
- bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
update_group_announce_rrclients(bgp);
bgp_clear_star_soft_out(vty, bgp->name);
}
@@ -3405,7 +3405,7 @@ DEFUN (bgp_disable_connected_route_check,
"Disable checking if nexthop is connected on ebgp sessions\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
+ SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
bgp_clear_star_soft_in(vty, bgp->name);
return CMD_SUCCESS;
@@ -3419,7 +3419,7 @@ DEFUN (no_bgp_disable_connected_route_check,
"Disable checking if nexthop is connected on ebgp sessions\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
bgp_clear_star_soft_in(vty, bgp->name);
return CMD_SUCCESS;
@@ -3558,7 +3558,7 @@ static int peer_conf_interface_get(struct vty *vty, const char *conf_if,
ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type,
afi, safi);
} else {
- if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)
&& afi == AFI_IP && safi == SAFI_UNICAST)
peer = peer_create(NULL, conf_if, bgp, bgp->as, as,
as_type, 0, 0, NULL);
@@ -6901,7 +6901,7 @@ DEFUN (neighbor_ttl_security,
* If 'neighbor swpX', then this is for directly connected peers,
* we should not accept a ttl-security hops value greater than 1.
*/
- if (peer->conf_if && (gtsm_hops > 1)) {
+ if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) {
vty_out(vty,
"%s is directly connected peer, hops cannot exceed 1\n",
argv[idx_peer]->arg);
@@ -8513,14 +8513,14 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json)
{
json_object *bestpath = json_object_new_object();
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE))
json_object_string_add(bestpath, "asPath", "ignore");
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED))
json_object_string_add(bestpath, "asPath", "confed");
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
- if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET))
json_object_string_add(bestpath, "multiPathRelax",
"as-set");
else
@@ -8529,13 +8529,13 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json)
} else
json_object_string_add(bestpath, "multiPathRelax", "false");
- if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID))
json_object_string_add(bestpath, "compareRouterId", "true");
- if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)
- || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) {
- if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)
+ || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED))
json_object_string_add(bestpath, "med", "confed");
- if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST))
json_object_string_add(bestpath, "med",
"missing-as-worst");
else
@@ -8658,7 +8658,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,
dn_flag[1] = '\0';
dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0';
if (peer->hostname
- && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
+ && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME))
len = vty_out(vty, "%s%s(%s)", dn_flag,
peer->hostname, peer->host);
else
@@ -8741,8 +8741,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
dn_flag[0] = '*';
if (peer->hostname
- && bgp_flag_check(bgp,
- BGP_FLAG_SHOW_HOSTNAME))
+ && CHECK_FLAG(bgp->flags,
+ BGP_FLAG_SHOW_HOSTNAME))
sprintf(neighbor_buf, "%s%s(%s) ",
dn_flag, peer->hostname,
peer->host);
@@ -9103,9 +9103,11 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
}
if (peer->hostname
- && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
+ && CHECK_FLAG(bgp->flags,
+ BGP_FLAG_SHOW_HOSTNAME))
len = vty_out(vty, "%s%s(%s)", dn_flag,
- peer->hostname, peer->host);
+ peer->hostname,
+ peer->host);
else
len = vty_out(vty, "%s%s", dn_flag, peer->host);
@@ -11937,7 +11939,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
/* EBGP Multihop and GTSM */
if (p->sort != BGP_PEER_IBGP) {
if (use_json) {
- if (p->gtsm_hops > 0)
+ if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED)
json_object_int_add(json_neigh,
"externalBgpNbrMaxHopsAway",
p->gtsm_hops);
@@ -11946,7 +11948,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
"externalBgpNbrMaxHopsAway",
p->ttl);
} else {
- if (p->gtsm_hops > 0)
+ if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED)
vty_out(vty,
" External BGP neighbor may be up to %d hops away.\n",
p->gtsm_hops);
@@ -11956,7 +11958,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
p->ttl);
}
} else {
- if (p->gtsm_hops > 0) {
+ if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) {
if (use_json)
json_object_int_add(json_neigh,
"internalBgpNbrMaxHopsAway",
@@ -14448,7 +14450,8 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
/* ebgp-multihop */
if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL
- && !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) {
+ && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED
+ && peer->ttl == MAXTTL)) {
if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) {
vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr,
peer->ttl);
@@ -14456,7 +14459,7 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
}
/* ttl-security hops */
- if (peer->gtsm_hops != 0) {
+ if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) {
if (!peer_group_active(peer)
|| g_peer->gtsm_hops != peer->gtsm_hops) {
vty_out(vty, " neighbor %s ttl-security hops %d\n",
@@ -14603,8 +14606,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
} else {
if (peer->afc[afi][safi]) {
if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) {
- if (bgp_flag_check(bgp,
- BGP_FLAG_NO_DEFAULT_IPV4)) {
+ if (CHECK_FLAG(bgp->flags,
+ BGP_FLAG_NO_DEFAULT_IPV4)) {
vty_out(vty, " neighbor %s activate\n",
addr);
}
@@ -14612,8 +14615,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
vty_out(vty, " neighbor %s activate\n", addr);
} else {
if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) {
- if (!bgp_flag_check(bgp,
- BGP_FLAG_NO_DEFAULT_IPV4)) {
+ if (!CHECK_FLAG(bgp->flags,
+ BGP_FLAG_NO_DEFAULT_IPV4)) {
vty_out(vty,
" no neighbor %s activate\n",
addr);
@@ -14974,16 +14977,16 @@ int bgp_config_write(struct vty *vty)
inet_ntoa(bgp->router_id_static));
/* BGP log-neighbor-changes. */
- if (!!bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
!= SAVE_BGP_LOG_NEIGHBOR_CHANGES)
vty_out(vty, " %sbgp log-neighbor-changes\n",
- bgp_flag_check(bgp,
- BGP_FLAG_LOG_NEIGHBOR_CHANGES)
+ CHECK_FLAG(bgp->flags,
+ BGP_FLAG_LOG_NEIGHBOR_CHANGES)
? ""
: "no ");
/* BGP configuration. */
- if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED))
vty_out(vty, " bgp always-compare-med\n");
/* RFC8212 default eBGP policy. */
@@ -14996,7 +14999,7 @@ int bgp_config_write(struct vty *vty)
vty_out(vty, " bgp reject-as-sets\n");
/* BGP default ipv4-unicast. */
- if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4))
vty_out(vty, " no bgp default ipv4-unicast\n");
/* BGP default local-preference. */
@@ -15005,10 +15008,10 @@ int bgp_config_write(struct vty *vty)
bgp->default_local_pref);
/* BGP default show-hostname */
- if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)
!= SAVE_BGP_SHOW_HOSTNAME)
vty_out(vty, " %sbgp default show-hostname\n",
- bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)
+ CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)
? ""
: "no ");
@@ -15019,7 +15022,7 @@ int bgp_config_write(struct vty *vty)
bgp->default_subgroup_pkt_queue_max);
/* BGP client-to-client reflection. */
- if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT))
vty_out(vty, " no bgp client-to-client reflection\n");
/* BGP cluster ID. */
@@ -15028,7 +15031,7 @@ int bgp_config_write(struct vty *vty)
inet_ntoa(bgp->cluster_id));
/* Disable ebgp connected nexthop check */
- if (bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
vty_out(vty,
" bgp disable-ebgp-connected-route-check\n");
@@ -15050,10 +15053,11 @@ int bgp_config_write(struct vty *vty)
}
/* BGP deterministic-med. */
- if (!!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)
!= SAVE_BGP_DETERMINISTIC_MED)
vty_out(vty, " %sbgp deterministic-med\n",
- bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)
+ CHECK_FLAG(bgp->flags,
+ BGP_FLAG_DETERMINISTIC_MED)
? ""
: "no ");
@@ -15107,11 +15111,11 @@ int bgp_config_write(struct vty *vty)
vty_out(vty, " bgp graceful-restart-disable\n");
/* BGP graceful-shutdown */
- if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN))
vty_out(vty, " bgp graceful-shutdown\n");
/* BGP graceful-restart Preserve State F bit. */
- if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD))
vty_out(vty,
" bgp graceful-restart preserve-fw-state\n");
@@ -15122,14 +15126,14 @@ int bgp_config_write(struct vty *vty)
bgp->rib_stale_time);
/* BGP bestpath method. */
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE))
vty_out(vty, " bgp bestpath as-path ignore\n");
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED))
vty_out(vty, " bgp bestpath as-path confed\n");
- if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
- if (bgp_flag_check(bgp,
- BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) {
+ if (CHECK_FLAG(bgp->flags,
+ BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
vty_out(vty,
" bgp bestpath as-path multipath-relax as-set\n");
} else {
@@ -15138,27 +15142,28 @@ int bgp_config_write(struct vty *vty)
}
}
- if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
vty_out(vty,
" bgp route-reflector allow-outbound-policy\n");
}
- if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID))
vty_out(vty, " bgp bestpath compare-routerid\n");
- if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)
- || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)
+ || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) {
vty_out(vty, " bgp bestpath med");
- if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED))
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED))
vty_out(vty, " confed");
- if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST))
+ if (CHECK_FLAG(bgp->flags,
+ BGP_FLAG_MED_MISSING_AS_WORST))
vty_out(vty, " missing-as-worst");
vty_out(vty, "\n");
}
/* BGP network import check. */
- if (!!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
!= SAVE_BGP_IMPORT_CHECK)
vty_out(vty, " %sbgp network import-check\n",
- bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)
+ CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
? ""
: "no ");
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 076b6aabca..bb718c355f 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -279,13 +279,13 @@ static int bgp_ifp_down(struct interface *ifp)
* tracked (directly connected) IBGP peers.
*/
if ((peer->ttl != BGP_DEFAULT_TTL)
- && (peer->gtsm_hops != 1)
+ && (peer->gtsm_hops != BGP_GTSM_HOPS_CONNECTED)
&& (!peer->bfd_info
|| bgp_bfd_is_peer_multihop(peer)))
#else
/* Take down directly connected EBGP peers */
if ((peer->ttl != BGP_DEFAULT_TTL)
- && (peer->gtsm_hops != 1))
+ && (peer->gtsm_hops != BGP_GTSM_HOPS_CONNECTED))
#endif
continue;
@@ -451,7 +451,8 @@ static int bgp_interface_vrf_update(ZAPI_CALLBACK_ARGS)
if (!CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) {
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
if ((peer->ttl != BGP_DEFAULT_TTL)
- && (peer->gtsm_hops != 1))
+ && (peer->gtsm_hops
+ != BGP_GTSM_HOPS_CONNECTED))
continue;
if (ifp == peer->nexthop.ifp)
@@ -1227,7 +1228,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
if ((peer->sort == BGP_PEER_EBGP && peer->ttl != BGP_DEFAULT_TTL)
|| CHECK_FLAG(peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)
- || bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
+ || CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK))
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 60bcc7b8e3..34581b66fc 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -201,24 +201,6 @@ int bgp_option_check(int flag)
return CHECK_FLAG(bm->options, flag);
}
-/* BGP flag manipulation. */
-int bgp_flag_set(struct bgp *bgp, int flag)
-{
- SET_FLAG(bgp->flags, flag);
- return 0;
-}
-
-int bgp_flag_unset(struct bgp *bgp, int flag)
-{
- UNSET_FLAG(bgp->flags, flag);
- return 0;
-}
-
-int bgp_flag_check(struct bgp *bgp, int flag)
-{
- return CHECK_FLAG(bgp->flags, flag);
-}
-
/* Internal function to set BGP structure configureation flag. */
static void bgp_config_set(struct bgp *bgp, int config)
{
@@ -1818,7 +1800,7 @@ int peer_remote_as(struct bgp *bgp, union sockunion *su, const char *conf_if,
/* If this is IPv4 unicast configuration and "no bgp default
ipv4-unicast" is specified. */
- if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)
&& afi == AFI_IP && safi == SAFI_UNICAST)
peer_create(su, conf_if, bgp, local_as, *as, as_type, 0,
0, NULL);
@@ -2428,14 +2410,14 @@ struct peer_group *peer_group_get(struct bgp *bgp, const char *name)
for (afi = AFI_IP; afi < AFI_MAX; afi++)
group->listen_range[afi] = list_new();
group->conf = peer_new(bgp);
- if (!bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4))
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4))
group->conf->afc[AFI_IP][SAFI_UNICAST] = 1;
XFREE(MTYPE_BGP_PEER_HOST, group->conf->host);
group->conf->host = XSTRDUP(MTYPE_BGP_PEER_HOST, name);
group->conf->group = group;
group->conf->as = 0;
group->conf->ttl = BGP_DEFAULT_TTL;
- group->conf->gtsm_hops = 0;
+ group->conf->gtsm_hops = BGP_GTSM_HOPS_DISABLED;
group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
SET_FLAG(group->conf->sflags, PEER_STATUS_GROUP);
listnode_add_sort(bgp->group, group);
@@ -3314,7 +3296,7 @@ int bgp_delete(struct bgp *bgp)
THREAD_OFF(bgp->t_establish_wait);
/* Set flag indicating bgp instance delete in progress */
- bgp_flag_set(bgp, BGP_FLAG_DELETE_IN_PROGRESS);
+ SET_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS);
/* Delete the graceful restart info */
FOREACH_AFI_SAFI (afi, safi) {
@@ -4339,7 +4321,7 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
if (ttl != MAXTTL) {
if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
group = peer->group;
- if (group->conf->gtsm_hops != 0)
+ if (group->conf->gtsm_hops != BGP_GTSM_HOPS_DISABLED)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
for (ALL_LIST_ELEMENTS(group->peer, node, nnode,
@@ -4347,11 +4329,11 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
if (peer1->sort == BGP_PEER_IBGP)
continue;
- if (peer1->gtsm_hops != 0)
+ if (peer1->gtsm_hops != BGP_GTSM_HOPS_DISABLED)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
} else {
- if (peer->gtsm_hops != 0)
+ if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
}
@@ -4392,7 +4374,7 @@ int peer_ebgp_multihop_unset(struct peer *peer)
if (peer->sort == BGP_PEER_IBGP)
return 0;
- if (peer->gtsm_hops != 0 && peer->ttl != MAXTTL)
+ if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED && peer->ttl != MAXTTL)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
if (peer_group_active(peer))
@@ -6585,7 +6567,8 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
mess of this configuration parameter, and OpenBGPD got it right.
*/
- if ((peer->gtsm_hops == 0) && (peer->sort != BGP_PEER_IBGP)) {
+ if ((peer->gtsm_hops == BGP_GTSM_HOPS_DISABLED)
+ && (peer->sort != BGP_PEER_IBGP)) {
if (is_ebgp_multihop_configured(peer))
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
@@ -6648,7 +6631,9 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
* no session then do nothing (will get
* handled by next connection)
*/
- if (peer->fd >= 0 && peer->gtsm_hops != 0)
+ if (peer->fd >= 0
+ && peer->gtsm_hops
+ != BGP_GTSM_HOPS_DISABLED)
sockopt_minttl(
peer->su.sa.sa_family, peer->fd,
MAXTTL + 1 - peer->gtsm_hops);
@@ -6679,7 +6664,7 @@ int peer_ttl_security_hops_unset(struct peer *peer)
if (peer_group_active(peer))
peer->gtsm_hops = peer->group->conf->gtsm_hops;
else
- peer->gtsm_hops = 0;
+ peer->gtsm_hops = BGP_GTSM_HOPS_DISABLED;
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Invoking ebgp_multihop_set will set the TTL back to the
@@ -6702,7 +6687,7 @@ int peer_ttl_security_hops_unset(struct peer *peer)
} else {
group = peer->group;
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
- peer->gtsm_hops = 0;
+ peer->gtsm_hops = BGP_GTSM_HOPS_DISABLED;
if (peer->sort == BGP_PEER_EBGP)
ret = peer_ebgp_multihop_unset(peer);
else {
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 7d3bd22a68..548dfe4683 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -239,7 +239,7 @@ enum bgp_instance_type {
};
#define BGP_SEND_EOR(bgp, afi, safi) \
- (!bgp_flag_check(bgp, BGP_FLAG_GR_DISABLE_EOR) \
+ (!CHECK_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR) \
&& ((bgp->gr_info[afi][safi].t_select_deferral == NULL) \
|| (bgp->gr_info[afi][safi].eor_required \
== bgp->gr_info[afi][safi].eor_received)))
@@ -674,7 +674,7 @@ struct afi_safi_info {
&& bgp->vrf_id != VRF_UNKNOWN))
#define BGP_SELECT_DEFER_DISABLE(bgp) \
- (bgp_flag_check(bgp, BGP_FLAG_SELECT_DEFER_DISABLE))
+ (CHECK_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE))
/* BGP peer-group support. */
struct peer_group {
@@ -723,7 +723,9 @@ struct bgp_nexthop {
#define RMAP_OUT 1
#define RMAP_MAX 2
-#define BGP_DEFAULT_TTL 1
+#define BGP_DEFAULT_TTL 1
+#define BGP_GTSM_HOPS_DISABLED 0
+#define BGP_GTSM_HOPS_CONNECTED 1
#include "filter.h"
@@ -1321,10 +1323,10 @@ struct peer {
#define PEER_DOWN_REMOTE_AS_CHANGE 2 /* neighbor remote-as command */
#define PEER_DOWN_LOCAL_AS_CHANGE 3 /* neighbor local-as command */
#define PEER_DOWN_CLID_CHANGE 4 /* bgp cluster-id command */
-#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation identifier command */
+#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation id command */
#define PEER_DOWN_CONFED_PEER_CHANGE 6 /* bgp confederation peer command */
-#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor route-reflector-client command */
-#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor route-server-client command */
+#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor rr-client command */
+#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor rs-client command */
#define PEER_DOWN_UPDATE_SOURCE_CHANGE 9 /* neighbor update-source command */
#define PEER_DOWN_AF_ACTIVATE 10 /* neighbor activate command */
#define PEER_DOWN_USER_SHUTDOWN 11 /* neighbor shutdown command */
@@ -1348,6 +1350,12 @@ struct peer {
#define PEER_DOWN_VRF_UNINIT 29 /* Associated VRF is not init yet */
#define PEER_DOWN_NOAFI_ACTIVATED 30 /* No AFI/SAFI activated for peer */
#define PEER_DOWN_AS_SETS_REJECT 31 /* Reject routes with AS_SET */
+#define PEER_DOWN_WAITING_OPEN 32 /* Waiting for open to succeed */
+ /*
+ * Remember to update peer_down_str in bgp_fsm.c when you add
+ * a new value to the last_reset reason
+ */
+
size_t last_reset_cause_size;
uint8_t last_reset_cause[BGP_MAX_PACKET_SIZE];
@@ -1757,10 +1765,6 @@ extern int bgp_delete(struct bgp *);
extern int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf,
vrf_id_t old_vrf_id, bool create);
-extern int bgp_flag_set(struct bgp *, int);
-extern int bgp_flag_unset(struct bgp *, int);
-extern int bgp_flag_check(struct bgp *, int);
-
extern void bgp_router_id_zebra_bump(vrf_id_t, const struct prefix *);
extern int bgp_router_id_static_set(struct bgp *, struct in_addr);
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 660442b492..61cbae1675 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -2388,10 +2388,10 @@ static int rfapiWithdrawTimerVPN(struct thread *t)
__func__);
return 0;
}
- if (bgp_flag_check(bgp, BGP_FLAG_DELETE_IN_PROGRESS)) {
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
vnc_zlog_debug_verbose(
- "%s: BGP delete in progress, assume shutdown race condition!!!",
- __func__);
+ "%s: BGP delete in progress, assume shutdown race condition!!!",
+ __func__);
return 0;
}
assert(wcb->node);
diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c
index 922c0fe3e7..add758fa21 100644
--- a/eigrpd/eigrp_main.c
+++ b/eigrpd/eigrp_main.c
@@ -229,5 +229,5 @@ int main(int argc, char **argv, char **envp)
frr_run(master);
/* Not reached. */
- return (0);
+ return 0;
}
diff --git a/lib/csv.c b/lib/csv.c
index 582106ebd4..445742807c 100644
--- a/lib/csv.c
+++ b/lib/csv.c
@@ -83,7 +83,7 @@ csv_t *csv_init(csv_t *csv, char *buf, int buflen)
csv = malloc(sizeof(csv_t));
if (csv == NULL) {
log_error("CSV Malloc failed\n");
- return (NULL);
+ return NULL;
}
}
memset(csv, 0, sizeof(csv_t));
@@ -144,7 +144,7 @@ char *csv_field_iter_next(csv_field_t **fld)
{
*fld = TAILQ_NEXT(*fld, next_field);
if ((*fld) == NULL) {
- return (NULL);
+ return NULL;
}
return ((*fld)->field);
}
@@ -198,7 +198,7 @@ static csv_field_t *csv_add_field_to_record(csv_t *csv, csv_record_t *rec,
if (!fld) {
log_error("field malloc failed\n");
/* more cleanup needed */
- return (NULL);
+ return NULL;
}
TAILQ_INSERT_TAIL(&(rec->fields), fld, next_field);
fld->field = str + rlen;
@@ -227,7 +227,7 @@ csv_record_t *csv_encode(csv_t *csv, int count, ...)
str = (char *)malloc(csv->buflen);
if (!str) {
log_error("field str malloc failed\n");
- return (NULL);
+ return NULL;
}
}
@@ -238,7 +238,7 @@ csv_record_t *csv_encode(csv_t *csv, int count, ...)
if (!buf)
free(str);
va_end(list);
- return (NULL);
+ return NULL;
}
csv_init_record(rec);
rec->record = str;
@@ -255,7 +255,7 @@ csv_record_t *csv_encode(csv_t *csv, int count, ...)
log_error("fld malloc failed\n");
csv_remove_record(csv, rec);
va_end(list);
- return (NULL);
+ return NULL;
}
if (tempc < (count - 1)) {
rec->rec_len += snprintf((str + rec->rec_len),
@@ -494,21 +494,21 @@ csv_record_t *csv_concat_record(csv_t *csv, csv_record_t *rec1,
if (!csv_is_record_valid(csv, rec1)
|| !csv_is_record_valid(csv, rec2)) {
log_error("rec1 and/or rec2 invalid\n");
- return (NULL);
+ return NULL;
}
/* we can only concat records if no buf was supplied during csv init */
if (csv->buf) {
log_error(
"un-supported for this csv type - single buf detected\n");
- return (NULL);
+ return NULL;
}
/* create a new rec */
rec = calloc(1, sizeof(csv_record_t));
if (!rec) {
log_error("record malloc failed\n");
- return (NULL);
+ return NULL;
}
csv_init_record(rec);
diff --git a/lib/imsg-buffer.c b/lib/imsg-buffer.c
index c2f4052b8f..4d41702707 100644
--- a/lib/imsg-buffer.c
+++ b/lib/imsg-buffer.c
@@ -30,10 +30,10 @@ struct ibuf *ibuf_open(size_t len)
struct ibuf *buf;
if ((buf = calloc(1, sizeof(struct ibuf))) == NULL)
- return (NULL);
+ return NULL;
if ((buf->buf = malloc(len)) == NULL) {
free(buf);
- return (NULL);
+ return NULL;
}
buf->size = buf->max = len;
buf->fd = -1;
@@ -46,10 +46,10 @@ struct ibuf *ibuf_dynamic(size_t len, size_t max)
struct ibuf *buf;
if (max < len)
- return (NULL);
+ return NULL;
if ((buf = ibuf_open(len)) == NULL)
- return (NULL);
+ return NULL;
if (max > 0)
buf->max = max;
@@ -64,27 +64,27 @@ static int ibuf_realloc(struct ibuf *buf, size_t len)
/* on static buffers max is eq size and so the following fails */
if (buf->wpos + len > buf->max) {
errno = ERANGE;
- return (-1);
+ return -1;
}
b = realloc(buf->buf, buf->wpos + len);
if (b == NULL)
- return (-1);
+ return -1;
buf->buf = b;
buf->size = buf->wpos + len;
- return (0);
+ return 0;
}
int ibuf_add(struct ibuf *buf, const void *data, size_t len)
{
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
- return (-1);
+ return -1;
memcpy(buf->buf + buf->wpos, data, len);
buf->wpos += len;
- return (0);
+ return 0;
}
void *ibuf_reserve(struct ibuf *buf, size_t len)
@@ -93,7 +93,7 @@ void *ibuf_reserve(struct ibuf *buf, size_t len)
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
- return (NULL);
+ return NULL;
b = buf->buf + buf->wpos;
buf->wpos += len;
@@ -104,7 +104,7 @@ void *ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
{
/* only allowed to seek in already written parts */
if (pos + len > buf->wpos)
- return (NULL);
+ return NULL;
return (buf->buf + pos);
}
@@ -146,17 +146,17 @@ again:
goto again;
if (errno == ENOBUFS)
errno = EAGAIN;
- return (-1);
+ return -1;
}
if (n == 0) { /* connection closed */
errno = 0;
- return (0);
+ return 0;
}
msgbuf_drain(msgbuf, n);
- return (1);
+ return 1;
}
void ibuf_free(struct ibuf *buf)
@@ -246,12 +246,12 @@ again:
goto again;
if (errno == ENOBUFS)
errno = EAGAIN;
- return (-1);
+ return -1;
}
if (n == 0) { /* connection closed */
errno = 0;
- return (0);
+ return 0;
}
/*
@@ -265,7 +265,7 @@ again:
msgbuf_drain(msgbuf, n);
- return (1);
+ return 1;
}
static void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
diff --git a/lib/imsg.c b/lib/imsg.c
index f07c56f0a6..b46d5cbc24 100644
--- a/lib/imsg.c
+++ b/lib/imsg.c
@@ -37,7 +37,7 @@ static int available_fds(unsigned int n)
int ret, fds[256];
if (n > (unsigned int)array_size(fds))
- return (1);
+ return 1;
ret = 0;
for (i = 0; i < n; i++) {
@@ -93,7 +93,7 @@ ssize_t imsg_read(struct imsgbuf *ibuf)
msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((ifd = calloc(1, sizeof(struct imsg_fd))) == NULL)
- return (-1);
+ return -1;
again:
#ifdef __OpenBSD__
@@ -108,7 +108,7 @@ again:
#endif
errno = EAGAIN;
free(ifd);
- return (-1);
+ return -1;
}
n = recvmsg(ibuf->fd, &msg, 0);
@@ -161,21 +161,21 @@ ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
av = ibuf->r.wpos;
if (IMSG_HEADER_SIZE > av)
- return (0);
+ return 0;
memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr));
if (imsg->hdr.len < IMSG_HEADER_SIZE || imsg->hdr.len > MAX_IMSGSIZE) {
errno = ERANGE;
- return (-1);
+ return -1;
}
if (imsg->hdr.len > av)
- return (0);
+ return 0;
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
ibuf->r.rptr = ibuf->r.buf + IMSG_HEADER_SIZE;
if (datalen == 0)
imsg->data = NULL;
else if ((imsg->data = malloc(datalen)) == NULL)
- return (-1);
+ return -1;
if (imsg->hdr.flags & IMSGF_HASFD)
imsg->fd = imsg_get_fd(ibuf);
@@ -201,16 +201,16 @@ int imsg_compose(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
struct ibuf *wbuf;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
- return (-1);
+ return -1;
if (imsg_add(wbuf, data, datalen) == -1)
- return (-1);
+ return -1;
wbuf->fd = fd;
imsg_close(ibuf, wbuf);
- return (1);
+ return 1;
}
int imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
@@ -223,17 +223,17 @@ int imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
datalen += iov[i].iov_len;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
- return (-1);
+ return -1;
for (i = 0; i < iovcnt; i++)
if (imsg_add(wbuf, iov[i].iov_base, iov[i].iov_len) == -1)
- return (-1);
+ return -1;
wbuf->fd = fd;
imsg_close(ibuf, wbuf);
- return (1);
+ return 1;
}
/* ARGSUSED */
@@ -248,7 +248,7 @@ struct ibuf *imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
datalen += IMSG_HEADER_SIZE;
if (datalen > MAX_IMSGSIZE) {
errno = ERANGE;
- return (NULL);
+ return NULL;
}
hdr.type = type;
@@ -257,10 +257,10 @@ struct ibuf *imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
if ((hdr.pid = pid) == 0)
hdr.pid = ibuf->pid;
if ((wbuf = ibuf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) {
- return (NULL);
+ return NULL;
}
if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1)
- return (NULL);
+ return NULL;
return (wbuf);
}
@@ -270,7 +270,7 @@ int imsg_add(struct ibuf *msg, const void *data, uint16_t datalen)
if (datalen)
if (ibuf_add(msg, data, datalen) == -1) {
ibuf_free(msg);
- return (-1);
+ return -1;
}
return (datalen);
}
@@ -301,7 +301,7 @@ int imsg_get_fd(struct imsgbuf *ibuf)
struct imsg_fd *ifd;
if ((ifd = TAILQ_POP_FIRST(&ibuf->fds, entry)) == NULL)
- return (-1);
+ return -1;
fd = ifd->fd;
free(ifd);
@@ -313,8 +313,8 @@ int imsg_flush(struct imsgbuf *ibuf)
{
while (ibuf->w.queued)
if (msgbuf_write(&ibuf->w) <= 0)
- return (-1);
- return (0);
+ return -1;
+ return 0;
}
void imsg_clear(struct imsgbuf *ibuf)
diff --git a/lib/openbsd-tree.c b/lib/openbsd-tree.c
index ddcc59fa8f..98d2e155e3 100644
--- a/lib/openbsd-tree.c
+++ b/lib/openbsd-tree.c
@@ -431,7 +431,7 @@ void *_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
rbe_insert_color(t, rbt, rbe);
- return (NULL);
+ return NULL;
}
/* Finds the node with the same key as elm */
@@ -453,7 +453,7 @@ void *_rb_find(const struct rb_type *t, const struct rbt_tree *rbt,
return (node);
}
- return (NULL);
+ return NULL;
}
/* Finds the first node greater than or equal to the search key */
diff --git a/lib/printf/printf-pos.c b/lib/printf/printf-pos.c
index 45e4f86229..20a58eacdc 100644
--- a/lib/printf/printf-pos.c
+++ b/lib/printf/printf-pos.c
@@ -125,11 +125,11 @@ _ensurespace(struct typetable *types)
if (types->nextarg >= types->tablesize) {
if (__grow_type_table(types))
- return (-1);
+ return -1;
}
if (types->nextarg > types->tablemax)
types->tablemax = types->nextarg;
- return (0);
+ return 0;
}
/*
@@ -141,9 +141,9 @@ addtype(struct typetable *types, enum typeid type)
{
if (_ensurespace(types))
- return (-1);
+ return -1;
types->table[types->nextarg++] = type;
- return (0);
+ return 0;
}
static inline int
@@ -151,7 +151,7 @@ addsarg(struct typetable *types, int flags)
{
if (_ensurespace(types))
- return (-1);
+ return -1;
if (flags & LONGDBL)
types->table[types->nextarg++] = T_INT64T;
else if (flags & INTMAXT)
@@ -166,7 +166,7 @@ addsarg(struct typetable *types, int flags)
types->table[types->nextarg++] = T_LONG;
else
types->table[types->nextarg++] = T_INT;
- return (0);
+ return 0;
}
static inline int
@@ -174,7 +174,7 @@ adduarg(struct typetable *types, int flags)
{
if (_ensurespace(types))
- return (-1);
+ return -1;
if (flags & LONGDBL)
types->table[types->nextarg++] = T_UINT64T;
else if (flags & INTMAXT)
@@ -189,7 +189,7 @@ adduarg(struct typetable *types, int flags)
types->table[types->nextarg++] = T_U_LONG;
else
types->table[types->nextarg++] = T_U_INT;
- return (0);
+ return 0;
}
/*
@@ -211,14 +211,14 @@ addaster(struct typetable *types, char **fmtp)
u_int hold = types->nextarg;
types->nextarg = n2;
if (addtype(types, T_INT))
- return (-1);
+ return -1;
types->nextarg = hold;
*fmtp = ++cp;
} else {
if (addtype(types, T_INT))
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
}
#ifdef WCHAR_SUPPORT
@@ -238,14 +238,14 @@ addwaster(struct typetable *types, wchar_t **fmtp)
u_int hold = types->nextarg;
types->nextarg = n2;
if (addtype(types, T_INT))
- return (-1);
+ return -1;
types->nextarg = hold;
*fmtp = ++cp;
} else {
if (addtype(types, T_INT))
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
}
#endif /* WCHAR_SUPPORT */
@@ -652,19 +652,19 @@ __grow_type_table(struct typetable *types)
/* Detect overflow */
if (types->nextarg > MAX_POSARG)
- return (-1);
+ return -1;
newsize = oldsize * 2;
if (newsize < types->nextarg + 1)
newsize = types->nextarg + 1;
if (oldsize == STATIC_ARG_TBL_SIZE) {
if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
- return (-1);
+ return -1;
bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
} else {
newtable = realloc(oldtable, newsize * sizeof(enum typeid));
if (newtable == NULL)
- return (-1);
+ return -1;
}
for (n = oldsize; n < newsize; n++)
newtable[n] = T_UNUSED;
@@ -672,7 +672,7 @@ __grow_type_table(struct typetable *types)
types->table = newtable;
types->tablesize = newsize;
- return (0);
+ return 0;
}
/*
diff --git a/lib/printf/vfprintf.c b/lib/printf/vfprintf.c
index 07df6dd8fe..6ffccb3811 100644
--- a/lib/printf/vfprintf.c
+++ b/lib/printf/vfprintf.c
@@ -94,7 +94,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
mbs = initial;
nbytes = wcsrtombs(NULL, (const wchar_t **)&p, 0, &mbs);
if (nbytes == (size_t)-1)
- return (NULL);
+ return NULL;
} else {
/*
* Optimisation: if the output precision is small enough,
@@ -117,7 +117,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
}
}
if ((convbuf = malloc(nbytes + 1)) == NULL)
- return (NULL);
+ return NULL;
/* Fill the output buffer. */
p = wcsarg;
@@ -125,7 +125,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
if ((nbytes = wcsrtombs(convbuf, (const wchar_t **)&p,
nbytes, &mbs)) == (size_t)-1) {
free(convbuf);
- return (NULL);
+ return NULL;
}
convbuf[nbytes] = '\0';
return (convbuf);
diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c
index a2ce9a0e2f..54f027deeb 100644
--- a/lib/ptm_lib.c
+++ b/lib/ptm_lib.c
@@ -92,36 +92,36 @@ static int _ptm_lib_decode_header(csv_t *csv, int *msglen, int *version,
rec = csv_record_iter(csv);
if (rec == NULL) {
DLOG("malformed CSV\n");
- return (-1);
+ return -1;
}
hdr = csv_field_iter(rec, &fld);
if (hdr == NULL) {
DLOG("malformed CSV\n");
- return (-1);
+ return -1;
}
*msglen = atoi(hdr);
hdr = csv_field_iter_next(&fld);
if (hdr == NULL) {
DLOG("malformed CSV\n");
- return (-1);
+ return -1;
}
*version = atoi(hdr);
hdr = csv_field_iter_next(&fld);
if (hdr == NULL) {
DLOG("malformed CSV\n");
- return (-1);
+ return -1;
}
*type = atoi(hdr);
hdr = csv_field_iter_next(&fld);
if (hdr == NULL) {
DLOG("malformed CSV\n");
- return (-1);
+ return -1;
}
*cmd_id = atoi(hdr);
hdr = csv_field_iter_next(&fld);
if (hdr == NULL) {
DLOG("malformed CSV\n");
- return (-1);
+ return -1;
}
/* remove leading spaces */
for (i = j = 0; i < csv_field_len(fld); i++) {
@@ -132,7 +132,7 @@ static int _ptm_lib_decode_header(csv_t *csv, int *msglen, int *version,
}
client_name[j] = '\0';
- return (0);
+ return 0;
}
int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,
@@ -364,7 +364,7 @@ int ptm_lib_process_msg(ptm_lib_handle_t *hdl, int fd, char *inbuf, int inlen,
if (!csv) {
DLOG("Cannot allocate csv for hdr\n");
- return (-1);
+ return -1;
}
rc = _ptm_lib_decode_header(csv, &msglen, &ver, &type, &cmd_id,
@@ -390,14 +390,14 @@ int ptm_lib_process_msg(ptm_lib_handle_t *hdl, int fd, char *inbuf, int inlen,
/* we only support the get-status cmd */
if (strcmp(inbuf, PTMLIB_CMD_GET_STATUS)) {
DLOG("unsupported legacy cmd %s\n", inbuf);
- return (-1);
+ return -1;
}
/* internally create a csv-style cmd */
ptm_lib_init_msg(hdl, 0, PTMLIB_MSG_TYPE_CMD, NULL,
(void *)&p_ctxt);
if (!p_ctxt) {
DLOG("couldnt allocate context\n");
- return (-1);
+ return -1;
}
ptm_lib_append_msg(hdl, p_ctxt, "cmd", PTMLIB_CMD_GET_STATUS);
diff --git a/lib/routemap.c b/lib/routemap.c
index e46323028d..a604c5921c 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -1157,7 +1157,7 @@ const char *route_map_get_match_arg(struct route_map_index *index,
if (rule->cmd == cmd && rule->rule_str != NULL)
return (rule->rule_str);
- return (NULL);
+ return NULL;
}
static route_map_event_t get_route_map_delete_event(route_map_event_t type)
diff --git a/lib/typerb.c b/lib/typerb.c
index 3886fc678e..7e8cd9d8f7 100644
--- a/lib/typerb.c
+++ b/lib/typerb.c
@@ -395,7 +395,7 @@ struct rb_entry *typed_rb_find(struct rbt_tree *rbt, const struct rb_entry *key,
return tmp;
}
- return (NULL);
+ return NULL;
}
struct rb_entry *typed_rb_find_gteq(struct rbt_tree *rbt,
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 484e5adae6..e4c4d4ad9c 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -157,7 +157,7 @@ static int ospf6_area_stub_set(struct ospf6 *ospf6, struct ospf6_area *area)
ospf6_area_stub_update(area);
}
- return (1);
+ return 1;
}
static void ospf6_area_stub_unset(struct ospf6 *ospf6, struct ospf6_area *area)
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 0fde997a20..61879b2cbb 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -172,13 +172,13 @@ int ospf6_router_is_stub_router(struct ospf6_lsa *lsa)
+ sizeof(struct ospf6_lsa_header));
if (!OSPF6_OPT_ISSET(rtr_lsa->options, OSPF6_OPT_R)) {
- return (OSPF6_IS_STUB_ROUTER);
+ return OSPF6_IS_STUB_ROUTER;
} else if (!OSPF6_OPT_ISSET(rtr_lsa->options, OSPF6_OPT_V6)) {
- return (OSPF6_IS_STUB_ROUTER_V6);
+ return OSPF6_IS_STUB_ROUTER_V6;
}
}
- return (OSPF6_NOT_STUB_ROUTER);
+ return OSPF6_NOT_STUB_ROUTER;
}
int ospf6_router_lsa_originate(struct thread *thread)
@@ -596,7 +596,7 @@ static char *ospf6_link_lsa_get_prefix_str(struct ospf6_lsa *lsa, char *buf,
prefixnum = ntohl(link_lsa->prefix_num);
if (pos > prefixnum)
- return (NULL);
+ return NULL;
start = (char *)link_lsa + sizeof(struct ospf6_link_lsa);
end = (char *)lsa->header + ntohs(lsa->header->length);
@@ -606,7 +606,7 @@ static char *ospf6_link_lsa_get_prefix_str(struct ospf6_lsa *lsa, char *buf,
prefix = (struct ospf6_prefix *)current;
if (prefix->prefix_length == 0
|| current + OSPF6_PREFIX_SIZE(prefix) > end) {
- return (NULL);
+ return NULL;
}
if (cnt < pos) {
@@ -623,7 +623,7 @@ static char *ospf6_link_lsa_get_prefix_str(struct ospf6_lsa *lsa, char *buf,
}
} while (current <= end);
}
- return (NULL);
+ return NULL;
}
static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
@@ -797,7 +797,7 @@ static char *ospf6_intra_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
prefixnum = ntohs(intra_prefix_lsa->prefix_num);
if (pos > prefixnum)
- return (NULL);
+ return NULL;
start = (char *)intra_prefix_lsa
+ sizeof(struct ospf6_intra_prefix_lsa);
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index 28b15769d7..723746c471 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -336,7 +336,7 @@ int ospf6_route_get_first_nh_index(struct ospf6_route *route)
return nh->ifindex;
}
- return (-1);
+ return -1;
}
int ospf6_nexthop_cmp(struct ospf6_nexthop *a, struct ospf6_nexthop *b)
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 9cde64bc38..4d6ebb40eb 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -235,5 +235,5 @@ int main(int argc, char **argv)
frr_run(master);
/* Not reached. */
- return (0);
+ return 0;
}
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index ca41afaea6..73e94deefc 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -180,5 +180,5 @@ int main(int argc, char **argv)
frr_run(master);
/* Not reached. */
- return (0);
+ return 0;
}
diff --git a/scripts/coccinelle/replace_bgp_flag_functions.cocci b/scripts/coccinelle/replace_bgp_flag_functions.cocci
new file mode 100644
index 0000000000..3064fc0267
--- /dev/null
+++ b/scripts/coccinelle/replace_bgp_flag_functions.cocci
@@ -0,0 +1,14 @@
+@@
+expression e1, e2;
+@@
+
+(
+- bgp_flag_check(e1, e2)
++ CHECK_FLAG(e1->flags, e2)
+|
+- bgp_flag_set(e1, e2)
++ SET_FLAG(e1->flags, e2)
+|
+- bgp_flag_unset(e1, e2)
++ UNSET_FLAG(e1->flags, e2)
+)
diff --git a/scripts/coccinelle/return_without_parenthesis.cocci b/scripts/coccinelle/return_without_parenthesis.cocci
new file mode 100644
index 0000000000..7097e87ddc
--- /dev/null
+++ b/scripts/coccinelle/return_without_parenthesis.cocci
@@ -0,0 +1,9 @@
+// Do not apply only for ldpd daemon since it uses the BSD coding style,
+// where parentheses on return is expected.
+
+@@
+constant c;
+@@
+
+- return (c);
++ return c;
diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c
index 925d3112d3..9feec7156a 100644
--- a/tests/bgpd/test_aspath.c
+++ b/tests/bgpd/test_aspath.c
@@ -653,7 +653,7 @@ static struct aspath_tests {
&test_segments[6],
NULL,
AS4_DATA,
- -1,
+ -2,
PEER_CAP_AS4_ADV,
{
COMMON_ATTRS,
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py
new file mode 100644
index 0000000000..d447548783
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py
@@ -0,0 +1,9 @@
+from lutil import luCommand
+rtrs = ['ce1', 'ce2', 'ce3', 'r1', 'r2', 'r3', 'r4']
+for rtr in rtrs:
+ ret = luCommand(rtr, 'vtysh -c "show bgp neigh"', 'Notification received .([A-Za-z0-9/ ]*)', 'none', 'collect neighbor stats')
+ found = luLast()
+ if ret != False and found != None:
+ val = found.group(1)
+ ret = luCommand(rtr, 'vtysh -c "show bgp neigh"', 'Notification received', 'fail', 'Notify RXed! {}'.format(val))
+#done
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py
index 2dad5e7687..7e36398298 100755
--- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py
@@ -47,6 +47,15 @@ def test_adjacencies():
#CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True)'
ltemplateTest('scripts/adjacencies.py', False, CliOnFail, CheckFunc)
+def test_notification_check():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ #CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = 'ltemplateVersionCheck(\'4.1\', iproute2=\'4.9\')'
+ #uncomment next line to start cli *before* script is run
+ #CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest('scripts/notification_check.py', False, CliOnFail, CheckFunc)
+
def SKIP_test_add_routes():
CliOnFail = None
# For debugging, uncomment the next line
@@ -75,6 +84,15 @@ def test_check_linux_mpls():
#CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
ltemplateTest('scripts/check_linux_mpls.py', False, CliOnFail, CheckFunc)
+def test_notification_check():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ #CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = 'ltemplateVersionCheck(\'4.1\', iproute2=\'4.9\')'
+ #uncomment next line to start cli *before* script is run
+ #CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest('scripts/notification_check.py', False, CliOnFail, CheckFunc)
+
def test_check_scale_up():
CliOnFail = None
# For debugging, uncomment the next line
@@ -84,6 +102,15 @@ def test_check_scale_up():
#CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
ltemplateTest('scripts/scale_up.py', False, CliOnFail, CheckFunc)
+def test_notification_check():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ #CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = 'ltemplateVersionCheck(\'4.1\', iproute2=\'4.9\')'
+ #uncomment next line to start cli *before* script is run
+ #CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest('scripts/notification_check.py', False, CliOnFail, CheckFunc)
+
def test_check_scale_down():
CliOnFail = None
# For debugging, uncomment the next line
@@ -93,6 +120,15 @@ def test_check_scale_down():
#CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
ltemplateTest('scripts/scale_down.py', False, CliOnFail, CheckFunc)
+def test_notification_check():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ #CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = 'ltemplateVersionCheck(\'4.1\', iproute2=\'4.9\')'
+ #uncomment next line to start cli *before* script is run
+ #CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest('scripts/notification_check.py', False, CliOnFail, CheckFunc)
+
def SKIP_test_cleanup_all():
CliOnFail = None
# For debugging, uncomment the next line
diff --git a/tests/topotests/ldp-topo1/test_ldp_topo1.py b/tests/topotests/ldp-topo1/test_ldp_topo1.py
index f02f4c4e21..c0d11fd5e0 100755
--- a/tests/topotests/ldp-topo1/test_ldp_topo1.py
+++ b/tests/topotests/ldp-topo1/test_ldp_topo1.py
@@ -185,7 +185,7 @@ def test_mpls_interfaces():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify MPLS Interfaces
print("\n\n** Verifying MPLS Interfaces")
print("******************************************\n")
failures = 0
@@ -238,7 +238,7 @@ def test_mpls_ldp_neighbor_establish():
if (fatal_error != ""):
pytest.skip(fatal_error)
- # Wait for OSPF6 to converge (All Neighbors in either Full or TwoWay State)
+ # Wait for MPLS LDP neighbors to establish.
print("\n\n** Verify MPLS LDP neighbors to establish")
print("******************************************\n")
timeout = 90
@@ -302,12 +302,12 @@ def test_mpls_ldp_discovery():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify MPLS LDP discovery
print("\n\n** Verifying MPLS LDP discovery")
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_discovery.ref'
+ refTableFile = '%s/r%s/show_mpls_ldp_discovery.ref' % (thisDir, i)
if os.path.isfile(refTableFile):
# Actual output from router
actual = net['r%s' % i].cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null').rstrip()
@@ -356,12 +356,12 @@ def test_mpls_ldp_neighbor():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify MPLS LDP neighbor
print("\n\n** Verifying MPLS LDP neighbor")
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_neighbor.ref'
+ refTableFile = '%s/r%s/show_mpls_ldp_neighbor.ref' % (thisDir, i)
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -415,12 +415,12 @@ def test_mpls_ldp_binding():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify MPLS LDP binding
print("\n\n** Verifying MPLS LDP binding")
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_binding.ref'
+ refTableFile = '%s/r%s/show_mpls_ldp_binding.ref' % (thisDir, i)
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -484,12 +484,12 @@ def test_zebra_ipv4_routingTable():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify Zebra IPv4 Routing Table
print("\n\n** Verifying Zebra IPv4 Routing Table")
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_ipv4_route.ref'
+ refTableFile = '%s/r%s/show_ipv4_route.ref' % (thisDir, i)
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -547,13 +547,13 @@ def test_mpls_table():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify MPLS table
print("\n\n** Verifying MPLS table")
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_table.ref'
+ refTableFile = '%s/r%s/show_mpls_table.ref' % (thisDir, i)
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read()
@@ -562,7 +562,7 @@ def test_mpls_table():
# Actual output from router
actual = net['r%s' % i].cmd('vtysh -c "show mpls table" 2> /dev/null')
-
+
# Fix inconsistent Label numbers at beginning of line
actual = re.sub(r"(\s+)[0-9]+(\s+LDP)", r"\1XX\2", actual)
# Fix inconsistent Label numbers at end of line
@@ -617,7 +617,7 @@ def test_linux_mpls_routes():
thisDir = os.path.dirname(os.path.realpath(__file__))
- # Verify OSPFv3 Routing Table
+ # Verify Linux Kernel MPLS routes
print("\n\n** Verifying Linux Kernel MPLS routes")
print("******************************************\n")
failures = 0
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 3a46835d1a..225524c67e 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -704,7 +704,7 @@ int vtysh_mark_file(const char *filename)
if (confp == NULL) {
fprintf(stderr, "%% Can't open config file %s due to '%s'.\n",
filename, safe_strerror(errno));
- return (CMD_ERR_NO_FILE);
+ return CMD_ERR_NO_FILE;
}
vty = vty_new();
@@ -885,7 +885,7 @@ int vtysh_mark_file(const char *filename)
if (confp != stdin)
fclose(confp);
- return (0);
+ return 0;
}
/* Configration make from file. */
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 27f4b0834d..9b1f0208e0 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -520,7 +520,7 @@ int vtysh_read_config(const char *config_default_dir)
fprintf(stderr,
"%% Can't open configuration file %s due to '%s'.\n",
config_default_dir, safe_strerror(errno));
- return (CMD_ERR_NO_FILE);
+ return CMD_ERR_NO_FILE;
}
ret = vtysh_read_file(confp);
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 0ba1b9d9c8..5951274257 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -470,7 +470,7 @@ int main(int argc, char **argv, char **env)
if (!inputfile) {
fprintf(stderr,
"-f option MUST be specified with -m option\n");
- return (1);
+ return 1;
}
return (vtysh_mark_file(inputfile));
}
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 6aa52bcb61..b891fb121f 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -717,10 +717,10 @@ int zebra_import_table(afi_t afi, vrf_id_t vrf_id, uint32_t table_id,
if (!is_zebra_valid_kernel_table(table_id)
|| (table_id == RT_TABLE_MAIN))
- return (-1);
+ return -1;
if (afi >= AFI_MAX)
- return (-1);
+ return -1;
table = zebra_vrf_get_table_with_table_id(afi, SAFI_UNICAST, vrf_id,
table_id);
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c
index fcd476dc2c..5e18414985 100644
--- a/zebra/zebra_mpls_openbsd.c
+++ b/zebra/zebra_mpls_openbsd.c
@@ -302,7 +302,7 @@ static int kernel_lsp_cmd(struct zebra_dplane_ctx *ctx)
}
}
- return (0);
+ return 0;
}
enum zebra_dplane_result kernel_lsp_update(struct zebra_dplane_ctx *ctx)
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index d7bbe779bd..681b4d1ab8 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -190,7 +190,7 @@ static int zebra_ptm_flush_messages(struct thread *thread)
ptm_cb.t_timer = NULL;
thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
ptm_cb.reconnect_time, &ptm_cb.t_timer);
- return (-1);
+ return -1;
case BUFFER_PENDING:
ptm_cb.t_write = NULL;
thread_add_write(zrouter.master, zebra_ptm_flush_messages, NULL,
@@ -200,7 +200,7 @@ static int zebra_ptm_flush_messages(struct thread *thread)
break;
}
- return (0);
+ return 0;
}
static int zebra_ptm_send_message(char *data, int size)
@@ -661,7 +661,7 @@ int zebra_ptm_sock_read(struct thread *thread)
thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
ptm_cb.reconnect_time,
&ptm_cb.t_timer);
- return (-1);
+ return -1;
}
ptm_cb.t_read = NULL;
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 641fc8799c..2963d83828 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -1779,7 +1779,7 @@ static int zebra_route_map_update_timer(struct thread *thread)
* 1) VRF Aware <sigh>
* 2) Route-map aware
*/
- return (0);
+ return 0;
}
static void zebra_route_map_set_delay_timer(uint32_t value)