summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfdd/bfdd_nb_config.c4
-rw-r--r--bfdd/bfdd_vty.c2
-rw-r--r--bgpd/bgp_route.c10
-rw-r--r--bgpd/bgp_updgrp_packet.c2
-rw-r--r--bgpd/bgp_vty.c26
-rw-r--r--bgpd/bgpd.c4
-rw-r--r--doc/user/overview.rst2
-rw-r--r--doc/user/rpki.rst12
-rw-r--r--ldpd/ldpd.c2
-rw-r--r--lib/frr_zmq.c10
-rw-r--r--lib/libfrr.c6
-rw-r--r--lib/module.c4
-rw-r--r--lib/northbound.c2
-rw-r--r--lib/plist.c2
-rw-r--r--lib/routemap.c2
-rw-r--r--lib/seqlock.c2
-rw-r--r--ospfd/ospf_ism.c27
-rw-r--r--pbrd/pbr_map.c2
-rw-r--r--pimd/pim_cmd.c3
-rw-r--r--pimd/pim_nht.c16
-rw-r--r--pimd/pim_register.c2
-rw-r--r--pimd/pim_upstream.c2
-rw-r--r--pimd/pim_upstream.h4
-rw-r--r--scripts/coccinelle/bool_assignment.cocci13
-rw-r--r--scripts/coccinelle/bool_expression.cocci29
-rw-r--r--scripts/coccinelle/bool_function.cocci21
-rw-r--r--scripts/coccinelle/bool_function_type.cocci19
-rw-r--r--scripts/coccinelle/test_after_assert.cocci7
-rw-r--r--vrrpd/vrrp.c12
-rw-r--r--zebra/zapi_msg.c11
-rw-r--r--zebra/zebra_gr.c49
-rw-r--r--zebra/zebra_mlag.c8
-rw-r--r--zebra/zebra_mpls.c82
-rw-r--r--zebra/zebra_nhg.c11
-rw-r--r--zebra/zebra_rib.c2
-rw-r--r--zebra/zebra_vty.c16
-rw-r--r--zebra/zserv.c4
-rw-r--r--zebra/zserv.h4
38 files changed, 283 insertions, 153 deletions
diff --git a/bfdd/bfdd_nb_config.c b/bfdd/bfdd_nb_config.c
index 50f953115c..48dcce3ddf 100644
--- a/bfdd/bfdd_nb_config.c
+++ b/bfdd/bfdd_nb_config.c
@@ -383,7 +383,7 @@ int bfdd_bfd_sessions_single_hop_administrative_down_modify(
bs = nb_running_get_entry(dnode, NULL, true);
- if (shutdown == false) {
+ if (!shutdown) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))
return NB_OK;
@@ -447,7 +447,7 @@ int bfdd_bfd_sessions_single_hop_echo_mode_modify(enum nb_event event,
bs = nb_running_get_entry(dnode, NULL, true);
- if (echo == false) {
+ if (!echo) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))
return NB_OK;
diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c
index 3b795748c0..2a98b0fb02 100644
--- a/bfdd/bfdd_vty.c
+++ b/bfdd/bfdd_vty.c
@@ -500,7 +500,7 @@ static void _display_peers_brief(struct vty *vty, const char *vrfname, bool use_
bvt.vrfname = vrfname;
- if (use_json == false) {
+ if (!use_json) {
bvt.vty = vty;
vty_out(vty, "Session count: %lu\n", bfd_get_session_count());
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 1cd0bbe578..c6a9aa722d 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -122,8 +122,6 @@ struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
struct bgp_node *prn = NULL;
assert(table);
- if (!table)
- return NULL;
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
@@ -299,7 +297,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
{
struct peer *peer;
struct bgp_path_info *old_pi, *nextpi;
- bool set_flag = 0;
+ bool set_flag = false;
struct bgp *bgp = NULL;
struct bgp_table *table = NULL;
afi_t afi = 0;
@@ -339,7 +337,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
*/
if (CHECK_FLAG(old_pi->flags, BGP_PATH_STALE)
&& (old_pi->sub_type == BGP_ROUTE_NORMAL)) {
- set_flag = 1;
+ set_flag = true;
} else {
/* If the peer is graceful restart capable and peer is
* restarting mode, set the flag BGP_NODE_SELECT_DEFER
@@ -349,7 +347,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
&& BGP_PEER_RESTARTING_MODE(peer)
&& (old_pi
&& old_pi->sub_type == BGP_ROUTE_NORMAL)) {
- set_flag = 1;
+ set_flag = true;
}
}
if (set_flag)
@@ -4909,8 +4907,6 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,
#endif
assert(bgp_static);
- if (!bgp_static)
- return;
rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 89199d05cb..4dc9dfa39a 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -330,8 +330,6 @@ void bpacket_queue_remove_peer(struct peer_af *paf)
q = PAF_PKTQ(paf);
assert(q);
- if (!q)
- return;
LIST_REMOVE(paf, pkt_train);
paf->next_pkt_to_send = NULL;
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 62767a603c..29d3b3878a 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -753,7 +753,7 @@ static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi,
}
static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,
- struct listnode *nnode, enum bgp_clear_type stype)
+ struct listnode **nnode, enum bgp_clear_type stype)
{
int ret = 0;
@@ -767,7 +767,7 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,
continue;
if (stype == BGP_CLEAR_SOFT_NONE)
- ret = peer_clear(peer, &nnode);
+ ret = peer_clear(peer, nnode);
else
ret = peer_clear_soft(peer, tmp_afi, tmp_safi,
stype);
@@ -782,7 +782,7 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,
continue;
if (stype == BGP_CLEAR_SOFT_NONE)
- ret = peer_clear(peer, &nnode);
+ ret = peer_clear(peer, nnode);
else
ret = peer_clear_soft(peer, afi,
tmp_safi, stype);
@@ -793,7 +793,7 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,
return 1;
if (stype == BGP_CLEAR_SOFT_NONE)
- ret = peer_clear(peer, &nnode);
+ ret = peer_clear(peer, nnode);
else
ret = peer_clear_soft(peer, afi, safi, stype);
}
@@ -826,7 +826,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))
gr_router_detected = true;
- ret = bgp_peer_clear(peer, afi, safi, nnode,
+ ret = bgp_peer_clear(peer, afi, safi, &nnode,
stype);
if (ret < 0)
@@ -901,7 +901,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
}
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
- ret = bgp_peer_clear(peer, afi, safi, nnode, stype);
+ ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);
if (ret < 0)
bgp_clear_vty_error(vty, peer, afi, safi, ret);
@@ -928,7 +928,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))
gr_router_detected = true;
- ret = bgp_peer_clear(peer, afi, safi, nnode, stype);
+ ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);
if (ret < 0)
bgp_clear_vty_error(vty, peer, afi, safi, ret);
@@ -965,7 +965,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))
gr_router_detected = true;
- ret = bgp_peer_clear(peer, afi, safi, nnode, stype);
+ ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);
if (ret < 0)
bgp_clear_vty_error(vty, peer, afi, safi, ret);
@@ -9440,7 +9440,7 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,
bool use_json,
json_object *json)
{
- bool rbit_status = 0;
+ bool rbit_status = false;
if (!use_json)
vty_out(vty, "\n R bit: ");
@@ -9450,9 +9450,9 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,
&& (p->status == Established)) {
if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV))
- rbit_status = 1;
+ rbit_status = true;
else
- rbit_status = 0;
+ rbit_status = false;
}
if (rbit_status) {
@@ -11506,12 +11506,12 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
vty_out(vty, "\n");
- /* Gracefull Restart */
+ /* Graceful Restart */
if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)
|| CHECK_FLAG(p->cap,
PEER_CAP_RESTART_ADV)) {
vty_out(vty,
- " Graceful Restart Capabilty:");
+ " Graceful Restart Capability:");
if (CHECK_FLAG(p->cap,
PEER_CAP_RESTART_ADV))
vty_out(vty, " advertised");
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 96b307ee21..8514574726 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1200,8 +1200,6 @@ struct peer *peer_new(struct bgp *bgp)
/* bgp argument is absolutely required */
assert(bgp);
- if (!bgp)
- return NULL;
/* Allocate new peer. */
peer = XCALLOC(MTYPE_BGP_PEER, sizeof(struct peer));
@@ -3148,7 +3146,7 @@ int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, vrf_id_t old_vrf_id,
/*
* suppress vrf socket
*/
- if (create == false) {
+ if (!create) {
bgp_close_vrf_socket(bgp);
return 0;
}
diff --git a/doc/user/overview.rst b/doc/user/overview.rst
index 2c8eadd4a7..b72ceb8d38 100644
--- a/doc/user/overview.rst
+++ b/doc/user/overview.rst
@@ -447,4 +447,4 @@ For information on reporting bugs, please see :ref:`bug-reports`.
.. _frr: |package-url|
.. _github: https://github.com/frrouting/frr/
.. _github issues: https://github.com/frrouting/frr/issues
-.. _slack: https://frrouting.slack.com/
+.. _slack: https://frrouting.org/#participate
diff --git a/doc/user/rpki.rst b/doc/user/rpki.rst
index dfac10b4f2..f8ec98c964 100644
--- a/doc/user/rpki.rst
+++ b/doc/user/rpki.rst
@@ -200,6 +200,18 @@ Debugging
Displaying RPKI
---------------
+.. index:: show rpki prefix <A.B.C.D/M|X:X::X:X/M> [(1-4294967295)]
+.. clicmd:: show rpki prefix <A.B.C.D/M|X:X::X:X/M> [(1-4294967295)]
+
+ Display validated prefixes received from the cache servers filtered
+ by the specified prefix.
+
+.. index:: show rpki as-number ASN
+.. clicmd:: show rpki as-number ASN
+
+ Display validated prefixes received from the cache servers filtered
+ by ASN.
+
.. index:: show rpki prefix-table
.. clicmd:: show rpki prefix-table
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 13de48fd70..7ab8d56f24 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -1688,7 +1688,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
}
RB_FOREACH_SAFE(xf, l2vpn_if_head, &xl->if_tree, ftmp) {
/* find new interfaces */
- if ((lif = l2vpn_if_find(l2vpn, xf->ifname)) == NULL) {
+ if (l2vpn_if_find(l2vpn, xf->ifname) == NULL) {
COPY(lif, xf);
RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif);
lif->l2vpn = l2vpn;
diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c
index 7781beae5e..565936a410 100644
--- a/lib/frr_zmq.c
+++ b/lib/frr_zmq.c
@@ -177,7 +177,7 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
else {
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
- cb->write.cancelled = 1;
+ cb->write.cancelled = true;
*cbp = cb;
}
@@ -187,7 +187,7 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
cb->read.cb_msg = msgfunc;
cb->read.cb_part = partfunc;
cb->read.cb_error = errfunc;
- cb->read.cancelled = 0;
+ cb->read.cancelled = false;
if (events & ZMQ_POLLIN) {
if (cb->read.thread) {
@@ -285,7 +285,7 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
else {
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
- cb->read.cancelled = 1;
+ cb->read.cancelled = true;
*cbp = cb;
}
@@ -295,7 +295,7 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
cb->write.cb_msg = msgfunc;
cb->write.cb_part = NULL;
cb->write.cb_error = errfunc;
- cb->write.cancelled = 0;
+ cb->write.cancelled = false;
if (events & ZMQ_POLLOUT) {
if (cb->write.thread) {
@@ -316,7 +316,7 @@ void frrzmq_thread_cancel(struct frrzmq_cb **cb, struct cb_core *core)
{
if (!cb || !*cb)
return;
- core->cancelled = 1;
+ core->cancelled = true;
if (core->thread) {
thread_cancel(core->thread);
core->thread = NULL;
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 4fb43edff2..3622890e46 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -383,7 +383,7 @@ static int frr_opt(int opt)
exit(0);
break;
case 'd':
- di->daemon_mode = 1;
+ di->daemon_mode = true;
break;
case 'M':
oc = XMALLOC(MTYPE_TMP, sizeof(*oc));
@@ -467,12 +467,12 @@ static int frr_opt(int opt)
case 'C':
if (di->flags & FRR_NO_CFG_PID_DRY)
return 1;
- di->dryrun = 1;
+ di->dryrun = true;
break;
case 't':
if (di->flags & FRR_NO_CFG_PID_DRY)
return 1;
- di->terminal = 1;
+ di->terminal = true;
break;
case 'z':
di->zpathspace = true;
diff --git a/lib/module.c b/lib/module.c
index 098c550684..14d5cfd44f 100644
--- a/lib/module.c
+++ b/lib/module.c
@@ -58,7 +58,7 @@ static const char *execname = NULL;
void frrmod_init(struct frrmod_runtime *modinfo)
{
- modinfo->finished_loading = 1;
+ modinfo->finished_loading = true;
*frrmod_last = modinfo;
frrmod_last = &modinfo->next;
@@ -134,7 +134,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err,
goto out_fail;
}
- rtinfo->finished_loading = 1;
+ rtinfo->finished_loading = true;
*frrmod_last = rtinfo;
frrmod_last = &rtinfo->next;
diff --git a/lib/northbound.c b/lib/northbound.c
index 206a88d980..cebedcff09 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -996,7 +996,7 @@ static int nb_transaction_process(enum nb_event event,
* Only try to release resources that were allocated
* successfully.
*/
- if (event == NB_EV_ABORT && change->prepare_ok == false)
+ if (event == NB_EV_ABORT && !change->prepare_ok)
break;
/* Call the appropriate callback. */
diff --git a/lib/plist.c b/lib/plist.c
index e465963f21..40131aebed 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -2039,7 +2039,7 @@ static void prefix_list_reset_afi(afi_t afi, int orf)
assert(master->str.head == NULL);
assert(master->str.tail == NULL);
- master->seqnum = 1;
+ master->seqnum = true;
master->recent = NULL;
}
diff --git a/lib/routemap.c b/lib/routemap.c
index 64677e8863..f3860924dd 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -2447,7 +2447,7 @@ route_map_result_t route_map_apply(struct route_map *map,
}
for (; index; index = index->next) {
- if (skip_match_clause == false) {
+ if (!skip_match_clause) {
/* Apply this index. */
match_ret = route_map_apply_match(&index->match_list,
prefix, type, object);
diff --git a/lib/seqlock.c b/lib/seqlock.c
index c05ec19db4..588a1175bc 100644
--- a/lib/seqlock.c
+++ b/lib/seqlock.c
@@ -254,7 +254,7 @@ bool seqlock_check(struct seqlock *sqlo, seqlock_val_t val)
cur = atomic_load_explicit(&sqlo->pos, memory_order_relaxed);
if (!(cur & SEQLOCK_HELD))
- return 1;
+ return true;
cur = SEQLOCK_VAL(cur) - val - 1;
assert(cur < 0x40000000 || cur > 0xc0000000);
return cur < 0x80000000;
diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c
index f4e89da45d..86712c6198 100644
--- a/ospfd/ospf_ism.c
+++ b/ospfd/ospf_ism.c
@@ -183,17 +183,22 @@ static void ospf_dr_change(struct ospf *ospf, struct route_table *nbrs)
struct route_node *rn;
struct ospf_neighbor *nbr;
- for (rn = route_top(nbrs); rn; rn = route_next(rn))
- if ((nbr = rn->info) != NULL)
- /* Ignore 0.0.0.0 node*/
- if (nbr->router_id.s_addr != INADDR_ANY)
- /* Is neighbor upper 2-Way? */
- if (nbr->state >= NSM_TwoWay)
- /* Ignore myself. */
- if (!IPV4_ADDR_SAME(&nbr->router_id,
- &ospf->router_id))
- OSPF_NSM_EVENT_SCHEDULE(
- nbr, NSM_AdjOK);
+ for (rn = route_top(nbrs); rn; rn = route_next(rn)) {
+ nbr = rn->info;
+
+ if (!nbr)
+ continue;
+
+ /*
+ * Ignore 0.0.0.0 node
+ * Is neighbor 2-Way?
+ * Ignore myself
+ */
+ if (nbr->router_id.s_addr != INADDR_ANY
+ && nbr->state >= NSM_TwoWay
+ && !IPV4_ADDR_SAME(&nbr->router_id, &ospf->router_id))
+ OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_AdjOK);
+ }
}
static int ospf_dr_election(struct ospf_interface *oi)
diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c
index 37b6be6949..fd77a07fb8 100644
--- a/pbrd/pbr_map.c
+++ b/pbrd/pbr_map.c
@@ -202,7 +202,7 @@ void pbr_map_reason_string(unsigned int reason, char *buf, int size)
void pbr_map_final_interface_deletion(struct pbr_map *pbrm,
struct pbr_map_interface *pmi)
{
- if (pmi->delete == true && !pbr_map_interface_is_installed(pbrm, pmi)) {
+ if (pmi->delete && !pbr_map_interface_is_installed(pbrm, pmi)) {
listnode_delete(pbrm->incoming, pmi);
pmi->pbrm = NULL;
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index fed256323f..93af0b92b5 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -7429,6 +7429,9 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
{
+ if (igmp->mtrace_only)
+ return;
+
if (igmp->t_igmp_query_timer) {
/* other querier present */
zassert(igmp->t_igmp_query_timer);
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index 9efeeaee27..dd94918b69 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -255,7 +255,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
int num_ifindex;
if (addr.s_addr == INADDR_NONE)
- return 0;
+ return false;
memset(nexthop_tab, 0,
sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM);
@@ -268,7 +268,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
zlog_warn(
"%s %s: could not find nexthop ifindex for address %s",
__FILE__, __PRETTY_FUNCTION__, addr_str);
- return 0;
+ return false;
}
while (i < num_ifindex) {
@@ -319,12 +319,12 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
if (nexthop_tab[i].nexthop_addr.u.prefix4.s_addr
== ip_src.s_addr)
- return 1;
+ return true;
i++;
}
- return 0;
+ return false;
}
/* Given a source address and a neighbor address, check if the neighbor is one
@@ -348,7 +348,7 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,
pnc = pim_nexthop_cache_find(pim, &rpf);
if (!pnc || !pnc->nexthop_num)
- return 0;
+ return false;
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex;
@@ -398,10 +398,10 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,
}
if (nh_node->gate.ipv4.s_addr == ip_src.s_addr)
- return 1;
+ return true;
}
- return 0;
+ return false;
}
void pim_rp_nexthop_del(struct rp_info *rp_info)
@@ -1086,7 +1086,7 @@ int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim,
sizeof(addr_str));
memset(&nhop, 0, sizeof(nhop));
- if (!pim_ecmp_nexthop_lookup(pim, &nhop, src, grp, 0)) {
+ if (!pim_ecmp_nexthop_lookup(pim, &nhop, src, grp, 1)) {
if (PIM_DEBUG_PIM_NHT)
zlog_debug(
"%s: could not find nexthop ifindex for address %s(%s)",
diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index aa9faf6923..27b3b1d9d6 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -122,6 +122,8 @@ int pim_register_stop_recv(struct interface *ifp, uint8_t *buf, int buf_size)
struct prefix_sg sg;
int l;
+ ++pim_ifp->pim_ifstat_reg_stop_recv;
+
memset(&sg, 0, sizeof(struct prefix_sg));
l = pim_parse_addr_group(&sg, buf, buf_size);
buf += l;
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index 444ab938f2..940b5a33ce 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -1151,7 +1151,7 @@ static inline bool pim_upstream_is_msdp_peer_sa(struct pim_upstream *up)
* AND inherited_olist(S,G) != NULL ) )
* }
*/
-int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
+bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,
struct pim_upstream *up)
{
bool empty_imm_oil;
diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h
index c717c467dc..4d693b8b64 100644
--- a/pimd/pim_upstream.h
+++ b/pimd/pim_upstream.h
@@ -303,8 +303,8 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
struct pim_upstream *up,
const char *name);
-int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
- struct pim_upstream *up);
+bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,
+ struct pim_upstream *up);
int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,
struct pim_ifchannel *ch,
struct pim_ifchannel *starch);
diff --git a/scripts/coccinelle/bool_assignment.cocci b/scripts/coccinelle/bool_assignment.cocci
new file mode 100644
index 0000000000..e6146ea310
--- /dev/null
+++ b/scripts/coccinelle/bool_assignment.cocci
@@ -0,0 +1,13 @@
+@@
+bool b;
+@@
+
+(
+ b =
+- 0
++ false
+|
+ b =
+- 1
++ true
+)
diff --git a/scripts/coccinelle/bool_expression.cocci b/scripts/coccinelle/bool_expression.cocci
new file mode 100644
index 0000000000..c0c329cb59
--- /dev/null
+++ b/scripts/coccinelle/bool_expression.cocci
@@ -0,0 +1,29 @@
+@@
+bool t;
+@@
+
+(
+- t == true
++ t
+|
+- true == t
++ t
+|
+- t != true
++ !t
+|
+- true != t
++ !t
+|
+- t == false
++ !t
+|
+- false == t
++ !t
+|
+- t != false
++ t
+|
+- false != t
++ t
+)
diff --git a/scripts/coccinelle/bool_function.cocci b/scripts/coccinelle/bool_function.cocci
new file mode 100644
index 0000000000..0328ecfbbe
--- /dev/null
+++ b/scripts/coccinelle/bool_function.cocci
@@ -0,0 +1,21 @@
+@@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+<...
+return
+(
+- 0
++ false
+|
+- 1
++ true
+)
+ ;
+...>
+}
diff --git a/scripts/coccinelle/bool_function_type.cocci b/scripts/coccinelle/bool_function_type.cocci
new file mode 100644
index 0000000000..71bf4f53b8
--- /dev/null
+++ b/scripts/coccinelle/bool_function_type.cocci
@@ -0,0 +1,19 @@
+@@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+- int
++ bool
+fn (...)
+{
+?...
+return
+(
+ true
+|
+ false
+);
+}
diff --git a/scripts/coccinelle/test_after_assert.cocci b/scripts/coccinelle/test_after_assert.cocci
new file mode 100644
index 0000000000..30596a89c2
--- /dev/null
+++ b/scripts/coccinelle/test_after_assert.cocci
@@ -0,0 +1,7 @@
+@@
+identifier i;
+@@
+
+assert(i);
+- if (!i)
+- return ...;
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c
index 03a08dd86b..da6de341e1 100644
--- a/vrrpd/vrrp.c
+++ b/vrrpd/vrrp.c
@@ -953,7 +953,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,
thread_add_timer_msec(
master, vrrp_master_down_timer_expire, r,
r->skew_time * CS2MS, &r->t_master_down_timer);
- } else if (r->vr->preempt_mode == false
+ } else if (!r->vr->preempt_mode
|| pkt->hdr.priority >= r->priority) {
if (r->vr->version == 3) {
r->master_adver_interval =
@@ -965,7 +965,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,
vrrp_master_down_timer_expire, r,
r->master_down_interval * CS2MS,
&r->t_master_down_timer);
- } else if (r->vr->preempt_mode == true
+ } else if (r->vr->preempt_mode
&& pkt->hdr.priority < r->priority) {
/* Discard advertisement */
DEBUGD(&vrrp_dbg_proto,
@@ -1834,7 +1834,7 @@ static int vrrp_autoconfig_if_add(struct interface *ifp)
created = true;
}
- if (!vr || vr->autoconf == false)
+ if (!vr || !vr->autoconf)
return 0;
if (!created) {
@@ -2347,11 +2347,11 @@ static bool vrrp_hash_cmp(const void *arg1, const void *arg2)
const struct vrrp_vrouter *vr2 = arg2;
if (vr1->ifp != vr2->ifp)
- return 0;
+ return false;
if (vr1->vrid != vr2->vrid)
- return 0;
+ return false;
- return 1;
+ return true;
}
void vrrp_init(void)
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 43bad5522c..1a5a293d11 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -1773,10 +1773,11 @@ static void zread_hello(ZAPI_HANDLER_ARGS)
client->proto = proto;
client->instance = instance;
+
+ /* Graceful restart processing for client connect */
+ zebra_gr_client_reconnect(client);
}
- /* Graceful restart processing for client connect */
- zebra_gr_client_reconnect(client);
zsend_capabilities(client, zvrf);
zebra_vrf_update_all(client);
stream_failure:
@@ -1826,7 +1827,9 @@ static void zread_mpls_labels_add(ZAPI_HANDLER_ARGS)
struct zapi_nexthop *znh;
znh = &zl.nexthops[i];
- mpls_lsp_install(zvrf, zl.type, zl.local_label, 1, znh->labels,
+
+ mpls_lsp_install(zvrf, zl.type, zl.local_label,
+ znh->label_num, znh->labels,
znh->type, &znh->gate, znh->ifindex);
if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN))
@@ -1929,7 +1932,7 @@ static void zread_mpls_labels_replace(ZAPI_HANDLER_ARGS)
znh = &zl.nexthops[i];
mpls_lsp_install(zvrf, zl.type, zl.local_label,
- 1, znh->labels, znh->type,
+ znh->label_num, znh->labels, znh->type,
&znh->gate, znh->ifindex);
if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN)) {
diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c
index 956fe9c2c8..bda1ad6b35 100644
--- a/zebra/zebra_gr.c
+++ b/zebra/zebra_gr.c
@@ -265,30 +265,31 @@ void zebra_gr_client_reconnect(struct zserv *client)
}
/* Copy the timers */
- if (old_client) {
- client->gr_instance_count = old_client->gr_instance_count;
- client->restart_time = old_client->restart_time;
-
- LOG_GR("%s : old client %s, gr_instance_count %d", __func__,
- zebra_route_string(old_client->proto),
- old_client->gr_instance_count);
-
- if (TAILQ_FIRST(&old_client->gr_info_queue)) {
- TAILQ_CONCAT(&client->gr_info_queue,
- &old_client->gr_info_queue, gr_info);
- TAILQ_INIT(&old_client->gr_info_queue);
- }
+ if (!old_client)
+ return;
- TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) {
- info->stale_client_ptr = client;
- info->stale_client = false;
- }
+ client->gr_instance_count = old_client->gr_instance_count;
+ client->restart_time = old_client->restart_time;
+
+ LOG_GR("%s : old client %s, gr_instance_count %d", __func__,
+ zebra_route_string(old_client->proto),
+ old_client->gr_instance_count);
+
+ if (TAILQ_FIRST(&old_client->gr_info_queue)) {
+ TAILQ_CONCAT(&client->gr_info_queue, &old_client->gr_info_queue,
+ gr_info);
+ TAILQ_INIT(&old_client->gr_info_queue);
+ }
- /* Delete the stale client */
- listnode_delete(zrouter.stale_client_list, old_client);
- /* Delete old client */
- XFREE(MTYPE_TMP, old_client);
+ TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) {
+ info->stale_client_ptr = client;
+ info->stale_client = false;
}
+
+ /* Delete the stale client */
+ listnode_delete(zrouter.stale_client_list, old_client);
+ /* Delete old client */
+ XFREE(MTYPE_TMP, old_client);
}
/*
@@ -425,6 +426,12 @@ void zread_client_capabilities(ZAPI_HANDLER_ARGS)
return;
}
+ /* GR only for dynamic clients */
+ if (client->proto <= ZEBRA_ROUTE_CONNECT) {
+ LOG_GR("%s: GR capabilities for client %s not supported",
+ __func__, zebra_route_string(client->proto));
+ return;
+ }
/* Call the capabilities handler */
zebra_client_capabilities_handler(client, &api);
}
diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c
index fc7804a409..5b721a8eac 100644
--- a/zebra/zebra_mlag.c
+++ b/zebra/zebra_mlag.c
@@ -605,7 +605,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
zsend_capabilities_all_clients();
if (zrouter.mlag_info.role != MLAG_ROLE_NONE) {
if (zrouter.mlag_info.clients_interested_cnt == 0
- && test_mlag_in_progress == false) {
+ && !test_mlag_in_progress) {
if (zrouter.mlag_info.zebra_pth_mlag == NULL)
zebra_mlag_spawn_pthread();
zrouter.mlag_info.clients_interested_cnt++;
@@ -613,7 +613,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
hook_call(zebra_mlag_private_open_channel);
}
} else {
- if (test_mlag_in_progress == true) {
+ if (test_mlag_in_progress) {
test_mlag_in_progress = false;
zrouter.mlag_info.clients_interested_cnt--;
hook_call(zebra_mlag_private_close_channel);
@@ -790,7 +790,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
vrf_name_len);
}
}
- if (cleanup == false) {
+ if (!cleanup) {
Bulk_msg.mroute_add = pay_load;
len = zebra_mlag_mroute_add_bulk__pack(&Bulk_msg,
tmp_buf);
@@ -804,7 +804,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
}
XFREE(MTYPE_MLAG_PBUF, pay_load);
- if (cleanup == true)
+ if (cleanup)
return -1;
} break;
case MLAG_MROUTE_DEL_BULK: {
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index fa6b952244..d373fdf370 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -93,6 +93,8 @@ static void lsp_processq_del(struct work_queue *wq, void *data);
static void lsp_processq_complete(struct work_queue *wq);
static int lsp_processq_add(zebra_lsp_t *lsp);
static void *lsp_alloc(void *p);
+/* Free lsp; sets caller's pointer to NULL */
+static void lsp_free(struct hash *lsp_table, zebra_lsp_t **plsp);
static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size);
static int nhlfe_nhop_match(zebra_nhlfe_t *nhlfe, enum nexthop_types_t gtype,
@@ -250,14 +252,8 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,
if (lsp_processq_add(lsp))
return -1;
} else if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
return 0;
}
@@ -313,14 +309,8 @@ static int lsp_uninstall(struct zebra_vrf *zvrf, mpls_label_t label)
if (lsp_processq_add(lsp))
return -1;
} else if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Del LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
return 0;
}
@@ -1047,14 +1037,8 @@ static void lsp_processq_del(struct work_queue *wq, void *data)
nhlfe_del(nhlfe);
}
- if (!lsp->nhlfe_list) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ if (!lsp->nhlfe_list)
+ lsp_free(lsp_table, &lsp);
}
/*
@@ -1104,6 +1088,37 @@ static void *lsp_alloc(void *p)
}
/*
+ * Dtor for an LSP: remove from ile hash, release any internal allocations,
+ * free LSP object.
+ */
+static void lsp_free(struct hash *lsp_table, zebra_lsp_t **plsp)
+{
+ zebra_lsp_t *lsp;
+ zebra_nhlfe_t *nhlfe, *nhlfe_next;
+
+ if (plsp == NULL || *plsp == NULL)
+ return;
+
+ lsp = *plsp;
+
+ if (IS_ZEBRA_DEBUG_MPLS)
+ zlog_debug("Free LSP in-label %u flags 0x%x",
+ lsp->ile.in_label, lsp->flags);
+
+ /* Free nhlfes, if any. */
+ for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe_next) {
+ nhlfe_next = nhlfe->next;
+
+ nhlfe_del(nhlfe);
+ }
+
+ hash_release(lsp_table, &lsp->ile);
+ XFREE(MTYPE_LSP, lsp);
+
+ *plsp = NULL;
+}
+
+/*
* Create printable string for NHLFE entry.
*/
static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size)
@@ -1334,14 +1349,8 @@ static int mpls_lsp_uninstall_all(struct hash *lsp_table, zebra_lsp_t *lsp,
if (lsp_processq_add(lsp))
return -1;
} else if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
return 0;
}
@@ -2872,14 +2881,9 @@ int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
/* Free LSP entry if no other NHLFEs and not scheduled. */
if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
}
return 0;
}
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 7f81e530fb..8088b78a93 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -1637,7 +1637,16 @@ static unsigned nexthop_active_check(struct route_node *rn,
switch (nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id);
- if (ifp && if_is_operative(ifp))
+ /*
+ * If the interface exists and its operative or its a kernel
+ * route and interface is up, its active. We trust kernel routes
+ * to be good.
+ */
+ if (ifp
+ && (if_is_operative(ifp)
+ || (if_is_up(ifp)
+ && (re->type == ZEBRA_ROUTE_KERNEL
+ || re->type == ZEBRA_ROUTE_SYSTEM))))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 9185c7ad16..6a2e20d05a 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -3172,7 +3172,7 @@ void rib_update(rib_update_event_t event)
&t_rib_update_threads[event]))
rib_update_ctx_fini(&ctx); /* Already scheduled */
else if (IS_ZEBRA_DEBUG_EVENT)
- zlog_debug("%s: Schedued VRF (ALL), event %s", __func__,
+ zlog_debug("%s: Scheduled VRF (ALL), event %s", __func__,
rib_update_event2str(event));
}
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 8c719f4b6a..f903065f44 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -915,8 +915,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
}
}
-static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
- bool use_fib, bool use_json,
+static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf,
+ afi_t afi, bool use_fib, bool use_json,
route_tag_t tag,
const struct prefix *longer_prefix_p,
bool supernets_only, int type,
@@ -934,12 +934,12 @@ static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t
if (zrt->afi != afi ||
zrt->safi != SAFI_UNICAST)
continue;
- if (zrt->table)
- do_show_ip_route(vty, zvrf_name(zvrf), afi,
- SAFI_UNICAST, use_fib, use_json,
- tag, longer_prefix_p,
- supernets_only, type,
- ospf_instance_id, zrt->tableid);
+
+ do_show_ip_route(vty, zvrf_name(zvrf), afi,
+ SAFI_UNICAST, use_fib, use_json,
+ tag, longer_prefix_p,
+ supernets_only, type,
+ ospf_instance_id, zrt->tableid);
}
}
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 2a5352a1da..299c079df1 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -568,7 +568,7 @@ static void zserv_client_free(struct zserv *client)
close(client->sock);
- if (!client->gr_instance_count) {
+ if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
nroutes = rib_score_proto(client->proto,
client->instance);
zlog_notice(
@@ -610,7 +610,7 @@ static void zserv_client_free(struct zserv *client)
* If any instance are graceful restart enabled,
* client is not deleted
*/
- if (!client->gr_instance_count) {
+ if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("%s: Deleting client %s", __func__,
zebra_route_string(client->proto));
diff --git a/zebra/zserv.h b/zebra/zserv.h
index 77ea19202f..6a075cc9a7 100644
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -229,6 +229,10 @@ struct zserv {
DECLARE_HOOK(zserv_client_connect, (struct zserv *client), (client));
DECLARE_KOOH(zserv_client_close, (struct zserv *client), (client));
+#define DYNAMIC_CLIENT_GR_DISABLED(_client) \
+ ((_client->proto <= ZEBRA_ROUTE_CONNECT) \
+ || !(_client->gr_instance_count))
+
/*
* Initialize Zebra API server.
*