summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--babeld/babel_interface.c2
-rw-r--r--babeld/message.c2
-rw-r--r--babeld/neighbour.c2
-rw-r--r--babeld/util.c2
-rw-r--r--bgpd/bgp_mpath.c2
-rw-r--r--bgpd/bgp_mplsvpn.c3
-rw-r--r--bgpd/bgp_rpki.c2
-rw-r--r--bgpd/bgp_updgrp.c4
-rw-r--r--bgpd/bgp_vpn.c8
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c6
-rw-r--r--bgpd/rfapi/rfapi.c67
-rw-r--r--bgpd/rfapi/rfapi_vty.c3
-rw-r--r--eigrpd/eigrp_network.c5
-rw-r--r--eigrpd/eigrp_packet.c2
-rw-r--r--eigrpd/eigrp_snmp.c8
-rw-r--r--eigrpd/eigrp_update.c1
-rw-r--r--isisd/isis_adjacency.c3
-rw-r--r--isisd/isis_circuit.c4
-rw-r--r--ldpd/packet.c2
-rw-r--r--lib/csv.c8
-rw-r--r--lib/frr_pthread.c1
-rw-r--r--lib/frr_zmq.c6
-rw-r--r--lib/hash.c12
-rw-r--r--lib/prefix.c3
-rw-r--r--lib/ptm_lib.c8
-rw-r--r--lib/sigevent.c2
-rw-r--r--lib/thread.c42
-rw-r--r--nhrpd/resolver.c2
-rw-r--r--ospfd/ospf_dump.c20
-rw-r--r--ospfd/ospf_interface.c2
-rw-r--r--ospfd/ospf_packet.c2
-rw-r--r--ospfd/ospf_snmp.c6
-rw-r--r--pimd/mtracebis.c4
-rw-r--r--pimd/pim_oil.c1
-rw-r--r--tests/lib/test_checksum.c2
-rw-r--r--tests/lib/test_graph.c2
-rw-r--r--tests/lib/test_srcdest_table.c4
-rw-r--r--tests/lib/test_timer_performance.c4
-rw-r--r--vtysh/vtysh.c29
-rw-r--r--zebra/interface.c6
40 files changed, 151 insertions, 143 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index d4958ddf24..453fd8e04e 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -1001,7 +1001,7 @@ show_babel_routes_sub(struct babel_route *route, struct vty *vty,
break;
if(k > 0)
channels[j++] = ',';
- snprintf(channels + j, 100 - j, "%d", route->channels[k]);
+ snprintf(channels + j, 100 - j, "%u", route->channels[k]);
j = strlen(channels);
}
snprintf(channels + j, 100 - j, ")");
diff --git a/babeld/message.c b/babeld/message.c
index 1ff4867908..95b4e87cc7 100644
--- a/babeld/message.c
+++ b/babeld/message.c
@@ -662,7 +662,7 @@ static int
check_bucket(struct interface *ifp)
{
babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
- if(babel_ifp->bucket <= 0) {
+ if(babel_ifp->bucket == 0) {
int seconds = babel_now.tv_sec - babel_ifp->bucket_time;
if(seconds > 0) {
babel_ifp->bucket = MIN(BUCKET_TOKENS_MAX,
diff --git a/babeld/neighbour.c b/babeld/neighbour.c
index 48a32c4a9c..3db121fd26 100644
--- a/babeld/neighbour.c
+++ b/babeld/neighbour.c
@@ -120,7 +120,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
int rc = 0;
if(hello < 0) {
- if(neigh->hello_interval <= 0)
+ if(neigh->hello_interval == 0)
return rc;
missed_hellos =
((int)timeval_minus_msec(&babel_now, &neigh->hello_time) -
diff --git a/babeld/util.c b/babeld/util.c
index 7dff11d124..4a3ecace0c 100644
--- a/babeld/util.c
+++ b/babeld/util.c
@@ -303,7 +303,7 @@ format_thousands(unsigned int value)
static char buf[4][15];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], 15, "%d.%.3d", value / 1000, value % 1000);
+ snprintf(buf[i], 15, "%u.%.3u", value / 1000, value % 1000);
return buf[i];
}
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 915387ca2d..333d09806e 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -471,7 +471,7 @@ void bgp_info_mpath_update(struct bgp_node *rn, struct bgp_info *new_best,
zlog_debug(
"%s: starting mpath update, newbest %s num candidates %d old-mpath-count %d",
pfx_buf, new_best ? new_best->peer->host : "NONE",
- listcount(mp_list), old_mpath_count);
+ mp_list ? listcount(mp_list) : 0, old_mpath_count);
/*
* We perform an ordered walk through both lists in parallel.
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index eef711aa59..28e8ceb15d 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1335,6 +1335,9 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
struct bgp_node *prn;
safi_t safi = SAFI_MPLS_VPN;
+ if (!bgp_vpn)
+ return;
+
/*
* Walk vpn table
*/
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index a23d5d03c4..ac4dabc164 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -384,7 +384,7 @@ static int reset(bool force)
static struct rtr_mgr_group *get_connected_group(void)
{
- if (list_isempty(cache_list))
+ if (!cache_list || list_isempty(cache_list))
return NULL;
return rtr_mgr_get_first_group(rtr_config);
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index d2e89a6785..6a65f982e0 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -812,7 +812,7 @@ static void update_subgroup_delete(struct update_subgroup *subgrp)
THREAD_TIMER_OFF(subgrp->t_coalesce);
sync_delete(subgrp);
- if (BGP_DEBUG(update_groups, UPDATE_GROUPS))
+ if (BGP_DEBUG(update_groups, UPDATE_GROUPS) && subgrp->update_group)
zlog_debug("delete subgroup u%" PRIu64 ":s%" PRIu64,
subgrp->update_group->id, subgrp->id);
@@ -905,7 +905,7 @@ static void update_subgroup_add_peer(struct update_subgroup *subgrp,
static void update_subgroup_remove_peer_internal(struct update_subgroup *subgrp,
struct peer_af *paf)
{
- assert(subgrp && paf);
+ assert(subgrp && paf && subgrp->update_group);
if (bgp_debug_peer_updout_enabled(paf->peer->host)) {
UPDGRP_PEER_DBG_DIS(subgrp->update_group);
diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c
index 80bd2cd799..351f91dd1a 100644
--- a/bgpd/bgp_vpn.c
+++ b/bgpd/bgp_vpn.c
@@ -228,15 +228,13 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
use_json, json_array);
}
}
- if (use_json) {
- struct prefix *p;
+ if (use_json && rm) {
char buf_a[BUFSIZ];
char buf_b[BUFSIZ];
- p = &rm->p;
sprintf(buf_a, "%s/%d",
- inet_ntop(p->family, &p->u.prefix,
+ inet_ntop(rm->p.family, rm->p.u.val,
buf_b, BUFSIZ),
- p->prefixlen);
+ rm->p.prefixlen);
json_object_object_add(json_routes, buf_a,
json_array);
}
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index 2f93328887..72255e54fb 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -662,7 +662,8 @@ static int rfapi_str2route_type(const char *l3str, const char *pstr, afi_t *afi,
vnc_import_bgp_exterior_redist_enable((bgp), (afi)); \
break; \
default: \
- vnc_redistribute_set((bgp), (afi), (type)); \
+ if ((type) < ZEBRA_ROUTE_MAX) \
+ vnc_redistribute_set((bgp), (afi), (type)); \
break; \
} \
} while (0)
@@ -677,7 +678,8 @@ static int rfapi_str2route_type(const char *l3str, const char *pstr, afi_t *afi,
vnc_import_bgp_exterior_redist_disable((bgp), (afi)); \
break; \
default: \
- vnc_redistribute_unset((bgp), (afi), (type)); \
+ if ((type) < ZEBRA_ROUTE_MAX) \
+ vnc_redistribute_unset((bgp), (afi), (type)); \
break; \
} \
} while (0)
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 8d782864c8..177244d277 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -3368,13 +3368,7 @@ DEFUN (debug_rfapi_query_vn_un_l2o,
{
struct rfapi_ip_addr vn;
struct rfapi_ip_addr un;
- struct rfapi_ip_addr target;
- rfapi_handle handle;
int rc;
- struct rfapi_next_hop_entry *pNextHopEntry;
- struct rfapi_l2address_option l2o_buf;
- struct bgp_tea_options hopt;
- uint8_t valbuf[14];
/*
* Get VN addr
@@ -3389,69 +3383,8 @@ DEFUN (debug_rfapi_query_vn_un_l2o,
if ((rc = rfapiCliGetRfapiIpAddr(vty, argv[6]->arg, &un)))
return rc;
-
-#if 0 /* there is no IP target arg here ?????? */
- /*
- * Get target addr
- */
- if ((rc = rfapiCliGetRfapiIpAddr (vty, argv[2], &target)))
- return rc;
-#else
vty_out(vty, "%% This command is broken.\n");
return CMD_WARNING_CONFIG_FAILED;
-#endif
-
- if (rfapi_find_handle_vty(vty, &vn, &un, &handle)) {
- vty_out(vty, "can't locate handle matching vn=%s, un=%s\n",
- argv[4]->arg, argv[6]->arg);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- /*
- * Set up L2 parameters
- */
- memset(&l2o_buf, 0, sizeof(l2o_buf));
- if (rfapiStr2EthAddr(argv[10]->arg, &l2o_buf.macaddr)) {
- vty_out(vty, "Bad mac address \"%s\"\n", argv[10]->arg);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- l2o_buf.logical_net_id = strtoul(argv[8]->arg, NULL, 10);
-
- /* construct option chain */
-
- memset(valbuf, 0, sizeof(valbuf));
- memcpy(valbuf, &l2o_buf.macaddr.octet, ETH_ALEN);
- valbuf[11] = (l2o_buf.logical_net_id >> 16) & 0xff;
- valbuf[12] = (l2o_buf.logical_net_id >> 8) & 0xff;
- valbuf[13] = l2o_buf.logical_net_id & 0xff;
-
- memset(&hopt, 0, sizeof(hopt));
- hopt.options_count = 1;
- hopt.options_length = sizeof(valbuf); /* is this right? */
- hopt.type = RFAPI_VN_OPTION_TYPE_L2ADDR;
- hopt.length = sizeof(valbuf);
- hopt.value = valbuf;
-
-
- /*
- * options parameter not used? Set to NULL for now
- */
- rc = rfapi_query(handle, &target, &l2o_buf, &pNextHopEntry);
-
- if (rc) {
- vty_out(vty, "rfapi_query failed with rc=%d (%s)\n", rc,
- strerror(rc));
- } else {
- /*
- * print nexthop list
- */
- /* TBD enhance to print L2 information */
- test_nexthops_callback(/*&target, */ pNextHopEntry,
- vty); /* frees nh list! */
- }
-
- return CMD_SUCCESS;
}
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index ccaa472092..18a979e531 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -1733,7 +1733,8 @@ void rfapiPrintMatchingDescriptors(struct vty *vty, struct prefix *vn_prefix,
int rfapiCliGetPrefixAddr(struct vty *vty, const char *str, struct prefix *p)
{
if (!str2prefix(str, p)) {
- vty_out(vty, "Malformed address \"%s\"%s", str, HVTYNL);
+ vty_out(vty, "Malformed address \"%s\"%s", str ? str : "null",
+ HVTYNL);
return CMD_WARNING;
}
switch (p->family) {
diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c
index 2578fecb35..629beddec3 100644
--- a/eigrpd/eigrp_network.c
+++ b/eigrpd/eigrp_network.c
@@ -55,7 +55,10 @@ static void eigrp_network_run_interface(struct eigrp *, struct prefix *,
int eigrp_sock_init(void)
{
int eigrp_sock;
- int ret, hincl = 1;
+ int ret;
+#ifdef IP_HDRINCL
+ int hincl = 1;
+#endif
if (eigrpd_privs.change(ZPRIVS_RAISE))
zlog_err("eigrp_sock_init: could not raise privs, %s",
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index 59864532cf..fab21e5201 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -944,8 +944,6 @@ void eigrp_packet_free(struct eigrp_packet *ep)
THREAD_OFF(ep->t_retrans_timer);
XFREE(MTYPE_EIGRP_PACKET, ep);
-
- ep = NULL;
}
/* EIGRP Header verification. */
diff --git a/eigrpd/eigrp_snmp.c b/eigrpd/eigrp_snmp.c
index 7dd95b7bc6..21c92386ae 100644
--- a/eigrpd/eigrp_snmp.c
+++ b/eigrpd/eigrp_snmp.c
@@ -514,7 +514,6 @@ eigrp_snmp_nbr_lookup_next(struct in_addr *nbr_addr, unsigned int *ifindex,
struct listnode *node, *nnode, *node2, *nnode2;
struct eigrp_interface *ei;
struct eigrp_neighbor *nbr;
- struct route_node *rn;
struct eigrp_neighbor *min = NULL;
struct eigrp *eigrp;
@@ -573,7 +572,7 @@ static struct eigrp_neighbor *eigrpNbrLookup(struct variable *v, oid *name,
first = 0;
len = *length - v->namelen;
- if (len <= 0)
+ if (len == 0)
first = 1;
if (len > IN_ADDR_SIZE)
@@ -918,8 +917,6 @@ static uint8_t *eigrpTopologyEntry(struct variable *v, oid *name,
WriteMethod **write_method)
{
struct eigrp *eigrp;
- struct eigrp_interface *ei;
- struct listnode *node, *nnode;
eigrp = eigrp_lookup();
@@ -1067,7 +1064,6 @@ static uint8_t *eigrpPeerEntry(struct variable *v, oid *name, size_t *length,
{
struct eigrp *eigrp;
struct eigrp_interface *ei;
- struct listnode *node, *nnode;
struct eigrp_neighbor *nbr;
struct in_addr nbr_addr;
unsigned int ifindex;
@@ -1199,11 +1195,9 @@ static uint8_t *eigrpInterfaceEntry(struct variable *v, oid *name,
WriteMethod **write_method)
{
struct eigrp *eigrp;
- struct eigrp_interface *ei;
struct listnode *node, *nnode;
struct keychain *keychain;
struct list *keylist;
- int counter;
eigrp = eigrp_lookup();
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index a3080136b5..e0142f6b32 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -757,7 +757,6 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
prefixes = nbr->nbr_gr_prefixes_send;
send_prefixes = 0;
- length = EIGRP_HEADER_LEN;
/* if there already were last packet chunk, we won't continue */
if (nbr->nbr_gr_packet_type == EIGRP_PACKET_PART_LAST)
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c
index 81495d0a79..4b3d78421e 100644
--- a/isisd/isis_adjacency.c
+++ b/isisd/isis_adjacency.c
@@ -288,7 +288,6 @@ void isis_adj_state_change(struct isis_adjacency *adj,
if (del)
isis_delete_adj(adj);
- adj = NULL;
} else if (circuit->circ_type == CIRCUIT_T_P2P) {
del = false;
for (level = IS_LEVEL_1; level <= IS_LEVEL_2; level++) {
@@ -326,8 +325,6 @@ void isis_adj_state_change(struct isis_adjacency *adj,
if (del)
isis_delete_adj(adj);
-
- adj = NULL;
}
return;
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 6f4d72cb1f..f8df33d3ee 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -357,14 +357,14 @@ void isis_circuit_del_addr(struct isis_circuit *circuit,
for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node,
ip6)) {
prefix2str((struct prefix *)ip6, (char *)buf,
- BUFSIZ);
+ sizeof(buf));
zlog_warn(" %s", buf);
}
zlog_warn(" -----");
for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node,
ip6)) {
prefix2str((struct prefix *)ip6, (char *)buf,
- BUFSIZ);
+ sizeof(buf));
zlog_warn(" %s", buf);
}
zlog_warn("End of addresses");
diff --git a/ldpd/packet.c b/ldpd/packet.c
index 4a4b258b91..b0f9c5eb14 100644
--- a/ldpd/packet.c
+++ b/ldpd/packet.c
@@ -144,7 +144,7 @@ disc_recv_packet(struct thread *thread)
/* reschedule read */
*threadp = NULL;
- thread_add_read(master, disc_recv_packet, threadp, fd, &*threadp);
+ thread_add_read(master, disc_recv_packet, threadp, fd, threadp);
/* setup buffer */
memset(&m, 0, sizeof(m));
diff --git a/lib/csv.c b/lib/csv.c
index e6a5eae2e2..ce84783aa6 100644
--- a/lib/csv.c
+++ b/lib/csv.c
@@ -663,8 +663,8 @@ int main()
log_verbose("Mem: %d\n", get_memory_usage(getpid()));
csv_init(&csv, buf, 256);
- sprintf(hdr1, "%4u", 0);
- sprintf(hdr2, "%4u", 1);
+ sprintf(hdr1, "%4d", 0);
+ sprintf(hdr2, "%4d", 1);
log_verbose("(%zu/%zu/%d/%d)\n", strlen(hdr1), strlen(hdr2), atoi(hdr1),
atoi(hdr2));
rec = csv_encode(&csv, 2, hdr1, hdr2);
@@ -676,8 +676,8 @@ int main()
}
csv_encode(&csv, 2, "pdfadfadfadsadsaddfdfdsfdsd", "35444554545454545");
log_verbose("%s\n", buf);
- sprintf(hdr1, "%4u", csv.csv_len);
- sprintf(hdr2, "%4u", 1);
+ sprintf(hdr1, "%4d", csv.csv_len);
+ sprintf(hdr2, "%4d", 1);
log_verbose("(%zu/%zu/%d/%d)\n", strlen(hdr1), strlen(hdr2), atoi(hdr1),
atoi(hdr2));
rec = csv_encode_record(&csv, rec, 2, hdr1, hdr2);
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index 36a89168c2..00681b9db8 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -269,7 +269,6 @@ static int fpt_halt(struct frr_pthread *fpt, void **res)
{
thread_add_event(fpt->master, &fpt_finish, fpt, 0, NULL);
pthread_join(fpt->thread, res);
- fpt = NULL;
return 0;
}
diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c
index 8f190a3a09..3153e697fa 100644
--- a/lib/frr_zmq.c
+++ b/lib/frr_zmq.c
@@ -174,9 +174,10 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
cb = *cbp;
else {
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
- cb->write.cancelled = 1;
if (!cb)
return -1;
+
+ cb->write.cancelled = 1;
*cbp = cb;
}
@@ -282,9 +283,10 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
cb = *cbp;
else {
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
- cb->read.cancelled = 1;
if (!cb)
return -1;
+
+ cb->read.cancelled = 1;
*cbp = cb;
}
diff --git a/lib/hash.c b/lib/hash.c
index ee5401b236..37f6cdcc8f 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -241,15 +241,21 @@ void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *),
unsigned int i;
struct hash_backet *hb;
struct hash_backet *hbnext;
+ uint32_t count = 0;
- for (i = 0; i < hash->size; i++)
+ for (i = 0; i < hash->size; i++) {
for (hb = hash->index[i]; hb; hb = hbnext) {
/* get pointer to next hash backet here, in case (*func)
* decides to delete hb by calling hash_release
*/
hbnext = hb->next;
(*func)(hb, arg);
+ count++;
+
}
+ if (count == hash->count)
+ return;
+ }
}
void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
@@ -259,6 +265,7 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
struct hash_backet *hb;
struct hash_backet *hbnext;
int ret = HASHWALK_CONTINUE;
+ uint32_t count = 0;
for (i = 0; i < hash->size; i++) {
for (hb = hash->index[i]; hb; hb = hbnext) {
@@ -269,7 +276,10 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
ret = (*func)(hb, arg);
if (ret == HASHWALK_ABORT)
return;
+ count++;
}
+ if (count == hash->count)
+ return;
}
}
diff --git a/lib/prefix.c b/lib/prefix.c
index ed0774e774..b129665e7b 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1197,6 +1197,9 @@ int str2prefix(const char *str, struct prefix *p)
{
int ret;
+ if (!str || !p)
+ return 0;
+
/* First we try to convert string to struct prefix_ipv4. */
ret = str2prefix_ipv4(str, (struct prefix_ipv4 *)p);
if (ret)
diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c
index fea5a8cc40..69fd61e2a0 100644
--- a/lib/ptm_lib.c
+++ b/lib/ptm_lib.c
@@ -60,10 +60,10 @@ static csv_record_t *_ptm_lib_encode_header(csv_t *csv, csv_record_t *rec,
char client_buf[32];
csv_record_t *rec1;
- sprintf(msglen_buf, "%4u", msglen);
- sprintf(vers_buf, "%4u", version);
- sprintf(type_buf, "%4u", type);
- sprintf(cmdid_buf, "%4u", cmd_id);
+ sprintf(msglen_buf, "%4d", msglen);
+ sprintf(vers_buf, "%4d", version);
+ sprintf(type_buf, "%4d", type);
+ sprintf(cmdid_buf, "%4d", cmd_id);
snprintf(client_buf, 17, "%16.16s", client_name);
if (rec) {
rec1 = csv_encode_record(csv, rec, 5, msglen_buf, vers_buf,
diff --git a/lib/sigevent.c b/lib/sigevent.c
index d299760fab..59eaa80370 100644
--- a/lib/sigevent.c
+++ b/lib/sigevent.c
@@ -119,8 +119,6 @@ int quagga_sigevent_process(void)
int quagga_signal_timer(struct thread *t)
{
struct quagga_sigevent_master_t *sigm;
- struct quagga_signal_t *sig;
- int i;
sigm = THREAD_ARG(t);
sigm->t = NULL;
diff --git a/lib/thread.c b/lib/thread.c
index 18e1c92280..1c5e838772 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -296,6 +296,47 @@ DEFUN (show_thread_cpu,
return CMD_SUCCESS;
}
+static void show_thread_poll_helper(struct vty *vty, struct thread_master *m)
+{
+ const char *name = m->name ? m->name : "main";
+ char underline[strlen(name) + 1];
+ uint32_t i;
+
+ memset(underline, '-', sizeof(underline));
+ underline[sizeof(underline) - 1] = '\0';
+
+ vty_out(vty, "\nShowing poll FD's for %s\n", name);
+ vty_out(vty, "----------------------%s\n", underline);
+ vty_out(vty, "Count: %u\n", (uint32_t)m->handler.pfdcount);
+ for (i = 0; i < m->handler.pfdcount; i++)
+ vty_out(vty, "\t%6d fd:%6d events:%2d revents:%2d\n", i,
+ m->handler.pfds[i].fd,
+ m->handler.pfds[i].events,
+ m->handler.pfds[i].revents);
+}
+
+DEFUN (show_thread_poll,
+ show_thread_poll_cmd,
+ "show thread poll",
+ SHOW_STR
+ "Thread information\n"
+ "Show poll FD's and information\n")
+{
+ struct listnode *node;
+ struct thread_master *m;
+
+ pthread_mutex_lock(&masters_mtx);
+ {
+ for (ALL_LIST_ELEMENTS_RO(masters, node, m)) {
+ show_thread_poll_helper(vty, m);
+ }
+ }
+ pthread_mutex_unlock(&masters_mtx);
+
+ return CMD_SUCCESS;
+}
+
+
DEFUN (clear_thread_cpu,
clear_thread_cpu_cmd,
"clear thread cpu [FILTER]",
@@ -325,6 +366,7 @@ DEFUN (clear_thread_cpu,
void thread_cmd_init(void)
{
install_element(VIEW_NODE, &show_thread_cpu_cmd);
+ install_element(VIEW_NODE, &show_thread_poll_cmd);
install_element(ENABLE_NODE, &clear_thread_cpu_cmd);
}
/* CLI end ------------------------------------------------------------------ */
diff --git a/nhrpd/resolver.c b/nhrpd/resolver.c
index 6349224adc..415e7523de 100644
--- a/nhrpd/resolver.c
+++ b/nhrpd/resolver.c
@@ -164,7 +164,7 @@ static void ares_address_cb(void *arg, int status, int timeouts,
return;
}
- for (i = 0; he->h_addr_list[i] != NULL && i < ZEBRA_NUM_OF(addr); i++) {
+ for (i = 0; i < ZEBRA_NUM_OF(addr) && he->h_addr_list[i] != NULL; i++) {
memset(&addr[i], 0, sizeof(addr[i]));
addr[i].sa.sa_family = he->h_addrtype;
switch (he->h_addrtype) {
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index 08bedadf41..d8742943c0 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -146,8 +146,6 @@ void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size)
else
state = ISM_DROther;
- memset(buf, 0, size);
-
snprintf(buf, size, "%s/%s",
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
lookup_msg(ospf_ism_state_msg, state, NULL));
@@ -201,17 +199,17 @@ const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size)
}
if (w > 99)
- snprintf(buf, size, "%ldw%1ldd", w, d);
+ snprintf(buf, size, "%luw%1lud", w, d);
else if (w)
- snprintf(buf, size, "%ldw%1ldd%02ldh", w, d, h);
+ snprintf(buf, size, "%luw%1lud%02luh", w, d, h);
else if (d)
- snprintf(buf, size, "%1ldd%02ldh%02ldm", d, h, m);
+ snprintf(buf, size, "%1lud%02luh%02lum", d, h, m);
else if (h)
- snprintf(buf, size, "%ldh%02ldm%02lds", h, m, (long)t->tv_sec);
+ snprintf(buf, size, "%luh%02lum%02lds", h, m, (long)t->tv_sec);
else if (m)
- snprintf(buf, size, "%ldm%02lds", m, (long)t->tv_sec);
+ snprintf(buf, size, "%lum%02lds", m, (long)t->tv_sec);
else if (ms)
- snprintf(buf, size, "%ld.%03lds", (long)t->tv_sec, ms);
+ snprintf(buf, size, "%ld.%03lus", (long)t->tv_sec, ms);
else
snprintf(buf, size, "%ld usecs", (long)t->tv_usec);
@@ -254,8 +252,6 @@ static void ospf_packet_hello_dump(struct stream *s, uint16_t length)
static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size)
{
- memset(buf, 0, size);
-
snprintf(buf, size, "%s|%s|%s", (flags & OSPF_DD_FLAG_I) ? "I" : "-",
(flags & OSPF_DD_FLAG_M) ? "M" : "-",
(flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
@@ -265,8 +261,6 @@ static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size)
static char *ospf_router_lsa_flags_dump(uint8_t flags, char *buf, size_t size)
{
- memset(buf, 0, size);
-
snprintf(buf, size, "%s|%s|%s",
(flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
(flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
@@ -1689,7 +1683,7 @@ static int config_write_debug(struct vty *vty)
return CMD_SUCCESS;
if (ospf->instance)
- sprintf(str, " %d", ospf->instance);
+ sprintf(str, " %u", ospf->instance);
/* debug ospf ism (status|events|timers). */
if (IS_CONF_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM)
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index ea31d8c2ca..23353b3c30 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -857,7 +857,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
"ospf_vl_new(): creating pseudo zebra interface vrf id %u",
ospf->vrf_id);
- snprintf(ifname, sizeof(ifname), "VLINK%d", vlink_count);
+ snprintf(ifname, sizeof(ifname), "VLINK%u", vlink_count);
vi = if_create(ifname, ospf->vrf_id);
/*
* if_create sets ZEBRA_INTERFACE_LINKDETECTION
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 1f67c0d5ad..486ef3335d 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -144,8 +144,6 @@ void ospf_packet_free(struct ospf_packet *op)
stream_free(op->s);
XFREE(MTYPE_OSPF_PACKET, op);
-
- op = NULL;
}
struct ospf_fifo *ospf_fifo_new()
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 6825be83ac..c90db031dc 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -1626,7 +1626,7 @@ static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
len = *length - v->namelen;
if (len >= IN_ADDR_SIZE)
len = IN_ADDR_SIZE;
- if (len <= 0)
+ if (len == 0)
ifaddr_next = 1;
oid2in_addr(name + v->namelen, len, ifaddr);
@@ -1990,7 +1990,7 @@ ospfVirtIfLookup(struct variable *v, oid *name, size_t *length,
first = 0;
len = *length - v->namelen;
- if (len <= 0)
+ if (len == 0)
first = 1;
if (len > IN_ADDR_SIZE)
len = IN_ADDR_SIZE;
@@ -2176,7 +2176,7 @@ static struct ospf_neighbor *ospfNbrLookup(struct variable *v, oid *name,
first = 0;
len = *length - v->namelen;
- if (len <= 0)
+ if (len == 0)
first = 1;
if (len > IN_ADDR_SIZE)
diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c
index a073fa70be..731fdb1beb 100644
--- a/pimd/mtracebis.c
+++ b/pimd/mtracebis.c
@@ -296,6 +296,10 @@ static int recv_response(int fd, int *hops, struct igmp_mtrace *mtracer)
mtrace_len = ntohs(ip->ip_len) - ip->ip_hl * 4;
+ if ((char *)mtrace + mtrace_len
+ > (char *)mtrace_buf + IP_AND_MTRACE_BUF_LEN)
+ return -1;
+
if (mtrace_len < (int)MTRACE_HDR_SIZE)
return -1;
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c
index fd3c04e8ca..d49484f869 100644
--- a/pimd/pim_oil.c
+++ b/pimd/pim_oil.c
@@ -40,7 +40,6 @@ char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)
struct prefix_sg sg;
int i;
- memset(buf, 0, size);
sg.src = c_oil->oil.mfcc_origin;
sg.grp = c_oil->oil.mfcc_mcastgrp;
sprintf(buf, "%s IIF: %d, OIFS: ", pim_str_sg_dump(&sg),
diff --git a/tests/lib/test_checksum.c b/tests/lib/test_checksum.c
index 3972f76763..13d35b0e99 100644
--- a/tests/lib/test_checksum.c
+++ b/tests/lib/test_checksum.c
@@ -506,7 +506,7 @@ int main(int argc, char **argv)
printf("verify: lib failed\n");
if (ospfd != lib) {
- printf("Mismatch in values at size %u\n"
+ printf("Mismatch in values at size %d\n"
"ospfd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
"isisd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
"lib: 0x%04x\n",
diff --git a/tests/lib/test_graph.c b/tests/lib/test_graph.c
index f21f8b793c..2801c48bc5 100644
--- a/tests/lib/test_graph.c
+++ b/tests/lib/test_graph.c
@@ -46,7 +46,7 @@ int main(int argc, char **argv)
/* create vertices */
for (unsigned int i = 0; i < NUMNODES; i++) {
- snprintf(names[i], sizeof(names[i]), "%d", i);
+ snprintf(names[i], sizeof(names[i]), "%u", i);
gn[i] = graph_new_node(g, names[i], NULL);
}
diff --git a/tests/lib/test_srcdest_table.c b/tests/lib/test_srcdest_table.c
index 408f4e0581..04e85435d1 100644
--- a/tests/lib/test_srcdest_table.c
+++ b/tests/lib/test_srcdest_table.c
@@ -104,9 +104,7 @@ static unsigned int log_key(void *data)
static int log_cmp(const void *a, const void *b)
{
- if (a == NULL && b != NULL)
- return 0;
- if (b == NULL && a != NULL)
+ if (a == NULL || b == NULL)
return 0;
return !memcmp(a, b, 2 * sizeof(struct prefix));
diff --git a/tests/lib/test_timer_performance.c b/tests/lib/test_timer_performance.c
index f9a244e259..d5f4badc85 100644
--- a/tests/lib/test_timer_performance.c
+++ b/tests/lib/test_timer_performance.c
@@ -92,9 +92,9 @@ int main(int argc, char **argv)
t_remove = 1000 * (tv_stop.tv_sec - tv_lap.tv_sec);
t_remove += (tv_stop.tv_usec - tv_lap.tv_usec) / 1000;
- printf("Scheduling %d random timers took %ld.%03ld seconds.\n",
+ printf("Scheduling %d random timers took %lu.%03lu seconds.\n",
SCHEDULE_TIMERS, t_schedule / 1000, t_schedule % 1000);
- printf("Removing %d random timers took %ld.%03ld seconds.\n",
+ printf("Removing %d random timers took %lu.%03lu seconds.\n",
REMOVE_TIMERS, t_remove / 1000, t_remove % 1000);
fflush(stdout);
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index c6e060500b..309493b13e 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -816,7 +816,7 @@ int vtysh_mark_file(const char *filename)
vty_out(vty, "%s", vty->buf);
break;
case CMD_SUCCESS_DAEMON: {
- int cmd_stat = CMD_SUCCESS;
+ int cmd_stat;
vty_out(vty, "%s", vty->buf);
cmd_stat = vtysh_client_execute(&vtysh_client[0],
@@ -2136,6 +2136,28 @@ DEFUNSH(VTYSH_INTERFACE, vtysh_quit_interface, vtysh_quit_interface_cmd, "quit",
return vtysh_exit_interface(self, vty, argc, argv);
}
+DEFUN (vtysh_show_poll,
+ vtysh_show_poll_cmd,
+ "show thread poll",
+ SHOW_STR
+ "Thread information\n"
+ "Thread Poll Information\n")
+{
+ unsigned int i;
+ int ret = CMD_SUCCESS;
+ char line[100];
+
+ snprintf(line, sizeof(line), "do show thread poll\n");
+ for (i = 0; i < array_size(vtysh_client); i++)
+ if (vtysh_client[i].fd >= 0) {
+ vty_out(vty, "Thread statistics for %s:\n",
+ vtysh_client[i].name);
+ ret = vtysh_client_execute(&vtysh_client[i], line);
+ vty_out(vty, "\n");
+ }
+ return ret;
+}
+
DEFUN (vtysh_show_thread,
vtysh_show_thread_cmd,
"show thread cpu [FILTER]",
@@ -2623,8 +2645,12 @@ int vtysh_write_config_integrated(void)
char line[] = "do write terminal\n";
FILE *fp;
int fd;
+#ifdef FRR_USER
struct passwd *pwentry;
+#endif
+#ifdef FRR_GROUP
struct group *grentry;
+#endif
uid_t uid = -1;
gid_t gid = -1;
struct stat st;
@@ -3720,6 +3746,7 @@ void vtysh_init_vty(void)
install_element(VIEW_NODE, &vtysh_show_work_queues_cmd);
install_element(VIEW_NODE, &vtysh_show_work_queues_daemon_cmd);
install_element(VIEW_NODE, &vtysh_show_thread_cmd);
+ install_element(VIEW_NODE, &vtysh_show_poll_cmd);
/* Logging */
install_element(VIEW_NODE, &vtysh_show_logging_cmd);
diff --git a/zebra/interface.c b/zebra/interface.c
index 7de18d683c..6125ff9a16 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -934,6 +934,12 @@ void if_up(struct interface *ifp)
/* Install connected routes to the kernel. */
if_install_connected(ifp);
+ /* Install any static routes using this vrf interface */
+ if (IS_ZEBRA_IF_VRF(ifp)) {
+ static_fixup_vrf_ids(zvrf);
+ static_config_install_delayed_routes(zvrf);
+ }
+
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%u: IF %s up, scheduling RIB processing",
ifp->vrf_id, ifp->name);