diff options
73 files changed, 226 insertions, 299 deletions
diff --git a/babeld/babeld.c b/babeld/babeld.c index a1e00bfb85..dfdc924cbd 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -31,6 +31,7 @@ THE SOFTWARE. #include "plist.h" #include "lib_errors.h" #include "network.h" +#include "if.h" #include "babel_main.h" #include "babeld.h" @@ -251,7 +252,7 @@ babel_get_myid(void) /* We failed to get a global EUI64 from the interfaces we were given. Let's try to find an interface with a MAC address. */ for(i = 1; i < 256; i++) { - char buf[IF_NAMESIZE], *ifname; + char buf[INTERFACE_NAMSIZ], *ifname; unsigned char eui[8]; ifname = if_indextoname(i, buf); if(ifname == NULL) diff --git a/bfdd/bfd.h b/bfdd/bfd.h index 00cc431e10..6aa9e00586 100644 --- a/bfdd/bfd.h +++ b/bfdd/bfd.h @@ -190,8 +190,8 @@ struct bfd_key { uint16_t mhop; struct in6_addr peer; struct in6_addr local; - char ifname[MAXNAMELEN]; - char vrfname[MAXNAMELEN]; + char ifname[INTERFACE_NAMSIZ]; + char vrfname[VRF_NAMSIZ]; } __attribute__((packed)); struct bfd_session_stats { @@ -290,7 +290,6 @@ struct bfd_session { struct peer_label *pl; struct bfd_dplane_ctx *bdc; - struct sockaddr_any local_address; struct interface *ifp; struct vrf *vrf; diff --git a/bfdd/bfd_packet.c b/bfdd/bfd_packet.c index 34b171f409..c717a333a6 100644 --- a/bfdd/bfd_packet.c +++ b/bfdd/bfd_packet.c @@ -639,9 +639,16 @@ void bfd_recv_cb(struct thread *t) return; } + /* Ensure that existing good sessions are not overridden. */ + if (!cp->discrs.remote_discr && bfd->ses_state != PTM_BFD_DOWN && + bfd->ses_state != PTM_BFD_ADM_DOWN) { + cp_debug(is_mhop, &peer, &local, ifindex, vrfid, + "'remote discriminator' is zero, not overridden"); + return; + } + /* * Multi hop: validate packet TTL. - * Single hop: set local address that received the packet. */ if (is_mhop) { if (ttl < bfd->mh_ttl) { @@ -650,8 +657,6 @@ void bfd_recv_cb(struct thread *t) bfd->mh_ttl, ttl); return; } - } else if (bfd->local_address.sa_sin.sin_family == AF_UNSPEC) { - bfd->local_address = local; } bfd->stats.rx_ctrl_pkt++; diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index dc0958fb33..a9fc716177 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -486,21 +486,12 @@ static void _display_peer_brief(struct vty *vty, struct bfd_session *bs) { char addr_buf[INET6_ADDRSTRLEN]; - if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_MH)) { - vty_out(vty, "%-10u", bs->discrs.my_discr); - inet_ntop(bs->key.family, &bs->key.local, addr_buf, sizeof(addr_buf)); - vty_out(vty, " %-40s", addr_buf); - inet_ntop(bs->key.family, &bs->key.peer, addr_buf, sizeof(addr_buf)); - vty_out(vty, " %-40s", addr_buf); - vty_out(vty, "%-15s\n", state_list[bs->ses_state].str); - } else { - vty_out(vty, "%-10u", bs->discrs.my_discr); - vty_out(vty, " %-40s", satostr(&bs->local_address)); - inet_ntop(bs->key.family, &bs->key.peer, addr_buf, sizeof(addr_buf)); - vty_out(vty, " %-40s", addr_buf); - - vty_out(vty, "%-15s\n", state_list[bs->ses_state].str); - } + vty_out(vty, "%-10u", bs->discrs.my_discr); + inet_ntop(bs->key.family, &bs->key.local, addr_buf, sizeof(addr_buf)); + vty_out(vty, " %-40s", addr_buf); + inet_ntop(bs->key.family, &bs->key.peer, addr_buf, sizeof(addr_buf)); + vty_out(vty, " %-40s", addr_buf); + vty_out(vty, "%-15s\n", state_list[bs->ses_state].str); } static void _display_peer_brief_iter(struct hash_bucket *hb, void *arg) diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 880e15fadb..41166de050 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -861,9 +861,6 @@ struct aspath *aspath_parse(struct stream *s, size_t length, int use32bit) /* If already same aspath exist then return it. */ find = hash_get(ashash, &as, aspath_hash_alloc); - /* bug! should not happen, let the daemon crash below */ - assert(find); - /* if the aspath was already hashed free temporary memory. */ if (find->refcnt) { assegment_free_all(as.segments); diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 0631f8b95a..34d4be8c93 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -184,7 +184,7 @@ community_list_insert(struct community_list_handler *ch, const char *name, new->name_hash = bgp_clist_hash_key_community_list(new); /* Save for later */ - hash_get(cm->hash, new, hash_alloc_intern); + (void)hash_get(cm->hash, new, hash_alloc_intern); /* If name is made by all digit character. We treat it as number. */ diff --git a/bgpd/bgp_community_alias.c b/bgpd/bgp_community_alias.c index caf469c0f7..431e6e00a4 100644 --- a/bgpd/bgp_community_alias.c +++ b/bgpd/bgp_community_alias.c @@ -106,12 +106,12 @@ int bgp_community_alias_write(struct vty *vty) void bgp_ca_community_insert(struct community_alias *ca) { - hash_get(bgp_ca_community_hash, ca, bgp_community_alias_alloc); + (void)hash_get(bgp_ca_community_hash, ca, bgp_community_alias_alloc); } void bgp_ca_alias_insert(struct community_alias *ca) { - hash_get(bgp_ca_alias_hash, ca, bgp_community_alias_alloc); + (void)hash_get(bgp_ca_alias_hash, ca, bgp_community_alias_alloc); } void bgp_ca_community_delete(struct community_alias *ca) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 78d7bf20eb..4a1e302925 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -167,10 +167,7 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt) irt->vrfs = list_new(); /* Add to hash */ - if (!hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern)) { - XFREE(MTYPE_BGP_EVPN_VRF_IMPORT_RT, irt); - return NULL; - } + (void)hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern); return irt; } @@ -263,19 +260,13 @@ static struct irt_node *import_rt_new(struct bgp *bgp, { struct irt_node *irt; - if (!bgp) - return NULL; - irt = XCALLOC(MTYPE_BGP_EVPN_IMPORT_RT, sizeof(struct irt_node)); irt->rt = *rt; irt->vnis = list_new(); /* Add to hash */ - if (!hash_get(bgp->import_rt_hash, irt, hash_alloc_intern)) { - XFREE(MTYPE_BGP_EVPN_IMPORT_RT, irt); - return NULL; - } + (void)hash_get(bgp->import_rt_hash, irt, hash_alloc_intern); return irt; } @@ -442,10 +433,8 @@ static void map_vni_to_rt(struct bgp *bgp, struct bgpevpn *vpn, /* Already mapped. */ return; - if (!irt) { + if (!irt) irt = import_rt_new(bgp, &eval_tmp); - assert(irt); - } /* Add VNI to the hash list for this RT. */ listnode_add(irt->vnis, vpn); @@ -2153,7 +2142,7 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) * Delete all type-2 (MACIP) local routes for this VNI - only from the * global routing table. These are also scheduled for withdraw from peers. */ -static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) +static void delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) { afi_t afi; safi_t safi; @@ -2166,7 +2155,7 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) rddest = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd); - if (rddest && bgp_dest_has_bgp_path_info_data(rddest)) { + if (rddest) { table = bgp_dest_get_bgp_table_info(rddest); for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) { @@ -2181,13 +2170,10 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) if (pi) bgp_process(bgp, dest, afi, safi); } - } - /* Unlock RD node. */ - if (rddest) + /* Unlock RD node. */ bgp_dest_unlock_node(rddest); - - return 0; + } } /* @@ -3692,8 +3678,8 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) es = bgp_evpn_es_find(&evp->prefix.ead_addr.esi); bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, - global_dest, attr, 1, - &global_pi, &route_changed); + global_dest, attr, &global_pi, + &route_changed); } /* Schedule for processing and unlock node. */ @@ -3710,7 +3696,6 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) */ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) { - int ret; struct prefix_evpn p; struct bgp_dest *global_dest; struct bgp_path_info *pi; @@ -3720,9 +3705,7 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) /* Delete and withdraw locally learnt type-2 routes (MACIP) * for this VNI - from the global table. */ - ret = delete_global_type2_routes(bgp, vpn); - if (ret) - return ret; + delete_global_type2_routes(bgp, vpn); /* Remove type-3 route for this VNI from global table. */ build_evpn_type3_prefix(&p, vpn->originator_ip); @@ -5308,9 +5291,6 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni, { struct bgpevpn *vpn; - if (!bgp) - return NULL; - vpn = XCALLOC(MTYPE_BGP_EVPN, sizeof(struct bgpevpn)); /* Set values - RD and RT set to defaults. */ @@ -5336,10 +5316,7 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni, vpn->route_table = bgp_table_init(bgp, AFI_L2VPN, SAFI_EVPN); /* Add to hash */ - if (!hash_get(bgp->vnihash, vpn, hash_alloc_intern)) { - XFREE(MTYPE_BGP_EVPN, vpn); - return NULL; - } + (void)hash_get(bgp->vnihash, vpn, hash_alloc_intern); bgp_evpn_remote_ip_hash_init(vpn); bgp_evpn_link_to_vni_svi_hash(bgp, vpn); @@ -5891,19 +5868,10 @@ int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni, */ if (is_vni_live(vpn)) update_routes_for_vni(bgp, vpn); - } - - /* Create or update as appropriate. */ - if (!vpn) { + } else { + /* Create or update as appropriate. */ vpn = bgp_evpn_new(bgp, vni, originator_ip, tenant_vrf_id, - mcast_grp, svi_ifindex); - if (!vpn) { - flog_err( - EC_BGP_VNI, - "%u: Failed to allocate VNI entry for VNI %u - at Add", - bgp->vrf_id, vni); - return -1; - } + mcast_grp, svi_ifindex); } /* if the VNI is live already, there is nothing more to do */ @@ -6217,9 +6185,6 @@ static void bgp_evpn_remote_ip_hash_add(struct bgpevpn *vpn, } ip = hash_get(vpn->remote_ip_hash, &tmp, bgp_evpn_remote_ip_hash_alloc); - if (!ip) - return; - (void)listnode_add(ip->macip_path_list, pi); bgp_evpn_remote_ip_process_nexthops(vpn, &ip->addr, true); @@ -6352,7 +6317,7 @@ static void bgp_evpn_link_to_vni_svi_hash(struct bgp *bgp, struct bgpevpn *vpn) if (vpn->svi_ifindex == 0) return; - hash_get(bgp->vni_svi_hash, vpn, hash_alloc_intern); + (void)hash_get(bgp->vni_svi_hash, vpn, hash_alloc_intern); } static void bgp_evpn_unlink_from_vni_svi_hash(struct bgp *bgp, diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index 39b31c0c1a..6ce97d22c4 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -351,7 +351,7 @@ static void bgp_evpn_es_route_del_all(struct bgp *bgp, struct bgp_evpn_es *es) */ int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es, struct bgpevpn *vpn, afi_t afi, safi_t safi, - struct bgp_dest *dest, struct attr *attr, int add, + struct bgp_dest *dest, struct attr *attr, struct bgp_path_info **ri, int *route_changed) { struct bgp_path_info *tmp_pi = NULL; @@ -390,9 +390,6 @@ int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es, return -1; } - if (!local_pi && !add) - return 0; - /* create or update the entry */ if (!local_pi) { @@ -652,7 +649,7 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp, dest = bgp_node_get(es->route_table, (struct prefix *)p); /* Create or update route entry. */ - ret = bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest, &attr, 1, + ret = bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest, &attr, &pi, &route_changed); if (ret != 0) flog_err( @@ -681,8 +678,7 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp, dest = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi, safi, p, &es->es_base_frag->prd); bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest, - attr_new, 1, &global_pi, - &route_changed); + attr_new, &global_pi, &route_changed); /* Schedule for processing and unlock node. */ bgp_process(bgp, dest, afi, safi); @@ -968,7 +964,7 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp, struct bgp_evpn_es *es, /* Create or update route entry. */ ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest, - &attr, 1, &pi, &route_changed); + &attr, &pi, &route_changed); if (ret != 0) flog_err( EC_BGP_ES_INVALID, @@ -990,7 +986,7 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp, struct bgp_evpn_es *es, /* Create or update route entry. */ ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest, - &attr, 1, &pi, &route_changed); + &attr, &pi, &route_changed); if (ret != 0) { flog_err( EC_BGP_ES_INVALID, @@ -1022,8 +1018,7 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp, struct bgp_evpn_es *es, dest = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi, safi, p, global_rd); bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest, - attr_new, 1, &global_pi, - &route_changed); + attr_new, &global_pi, &route_changed); /* Schedule for processing and unlock node. */ bgp_process(bgp, dest, afi, safi); diff --git a/bgpd/bgp_evpn_mh.h b/bgpd/bgp_evpn_mh.h index dc3fe44776..11030e323f 100644 --- a/bgpd/bgp_evpn_mh.h +++ b/bgpd/bgp_evpn_mh.h @@ -420,7 +420,7 @@ extern int delete_global_ead_evi_routes(struct bgp *bgp, struct bgpevpn *vpn); extern int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es, struct bgpevpn *vpn, afi_t afi, safi_t safi, struct bgp_dest *dest, struct attr *attr, - int add, struct bgp_path_info **ri, + struct bgp_path_info **ri, int *route_changed); int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi, struct attr *attr, uint8_t *pfx, int psize, diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 109de1efb2..0c9cd3b721 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -2279,13 +2279,6 @@ static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni) * zebra */ vpn = bgp_evpn_new(bgp, vni, bgp->router_id, 0, mcast_grp, 0); - if (!vpn) { - flog_err( - EC_BGP_VNI, - "%u: Failed to allocate VNI entry for VNI %u - at Config", - bgp->vrf_id, vni); - return NULL; - } } /* Mark as configured. */ diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index fe5f04ba11..cc3505333b 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -2272,7 +2272,7 @@ static int bgp_establish(struct peer *peer) * so the hash_release is the same for either. */ hash_release(peer->bgp->peerhash, peer); - hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); + (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); /* Start BFD peer if not already running. */ if (peer->bfd_config) diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c index 3a5adae874..4cb7bd788a 100644 --- a/bgpd/bgp_keepalives.c +++ b/bgpd/bgp_keepalives.c @@ -256,7 +256,7 @@ void bgp_keepalives_on(struct peer *peer) holder.peer = peer; if (!hash_lookup(peerhash, &holder)) { struct pkat *pkat = pkat_new(peer); - hash_get(peerhash, pkat, hash_alloc_intern); + (void)hash_get(peerhash, pkat, hash_alloc_intern); peer_lock(peer); } SET_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON); diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 0c325b6781..e702ee4fdd 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -539,7 +539,7 @@ static void bgp_accept(struct thread *thread) peer = peer_create(&su, peer1->conf_if, peer1->bgp, peer1->local_as, peer1->as, peer1->as_type, NULL); hash_release(peer->bgp->peerhash, peer); - hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); + (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); peer_xfer_config(peer, peer1); bgp_peer_gr_flags_update(peer); diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index e7bad42f97..de48c97513 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -191,9 +191,6 @@ void bgp_tip_add(struct bgp *bgp, struct in_addr *tip) tmp.addr = *tip; addr = hash_get(bgp->tip_hash, &tmp, bgp_tip_hash_alloc); - if (!addr) - return; - addr->refcnt++; } @@ -399,8 +396,7 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc) bgp_address_add(bgp, ifc, addr); - dest = bgp_node_get(bgp->connected_table[AFI_IP], - (struct prefix *)&p); + dest = bgp_node_get(bgp->connected_table[AFI_IP], &p); bc = bgp_dest_get_bgp_connected_ref_info(dest); if (bc) bc->refcnt++; @@ -433,8 +429,7 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc) bgp_address_add(bgp, ifc, addr); - dest = bgp_node_get(bgp->connected_table[AFI_IP6], - (struct prefix *)&p); + dest = bgp_node_get(bgp->connected_table[AFI_IP6], &p); bc = bgp_dest_get_bgp_connected_ref_info(dest); if (bc) diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index bfa1506afe..fa3fa3fcee 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1435,12 +1435,17 @@ static void bgp_peer_send_gr_capability(struct stream *s, struct peer *peer, restart_time = peer->bgp->restart_time; if (peer->bgp->t_startup) { SET_FLAG(restart_time, GRACEFUL_RESTART_R_BIT); - SET_FLAG(restart_time, GRACEFUL_RESTART_N_BIT); SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV); - SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV); + if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) + zlog_debug("[BGP_GR] Sending R-Bit for peer: %s", + peer->host); + } + if (CHECK_FLAG(peer->bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION)) { + SET_FLAG(restart_time, GRACEFUL_RESTART_N_BIT); + SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV); if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) - zlog_debug("[BGP_GR] Sending R-Bit/N-Bit for peer: %s", + zlog_debug("[BGP_GR] Sending N-Bit for peer: %s", peer->host); } diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 54db4da0c2..88eeab6ed1 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1973,8 +1973,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) */ static int bgp_notify_receive(struct peer *peer, bgp_size_t size) { - struct bgp_notify outer; - struct bgp_notify inner; + struct bgp_notify outer = {}; + struct bgp_notify inner = {}; bool hard_reset = false; if (peer->notify.data) { @@ -2039,12 +2039,13 @@ static int bgp_notify_receive(struct peer *peer, bgp_size_t size) } bgp_notify_print(peer, &inner, "received", hard_reset); - if (inner.data) { + if (inner.length) { XFREE(MTYPE_BGP_NOTIFICATION, inner.data); inner.length = 0; } if (outer.length) { XFREE(MTYPE_BGP_NOTIFICATION, outer.data); + XFREE(MTYPE_BGP_NOTIFICATION, outer.raw_data); outer.length = 0; } } diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index d3609cb017..352670e6c1 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -2350,7 +2350,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp, pbr_rule.action = bpa; bpr = hash_get(bgp->pbr_rule_hash, &pbr_rule, bgp_pbr_rule_alloc_intern); - if (bpr && bpr->unique == 0) { + if (bpr->unique == 0) { bpr->unique = ++bgp_pbr_action_counter_unique; bpr->installed = false; bpr->install_in_progress = false; @@ -2359,7 +2359,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp, } else bpr_found = true; /* already installed */ - if (bpr_found && bpr) { + if (bpr_found) { struct bgp_path_info_extra *extra = bgp_path_info_extra_get(path); @@ -2376,7 +2376,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp, bgp_pbr_bpa_add(bpa); /* ip rule add */ - if (bpr && !bpr->installed) + if (!bpr->installed) bgp_send_pbr_rule_action(bpa, bpr, true); /* A previous entry may already exist diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index e85118e588..fb3f9aae43 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -754,8 +754,6 @@ static struct update_group *update_group_create(struct peer_af *paf) updgrp = hash_get(paf->peer->bgp->update_groups[paf->afid], &tmp, updgrp_hash_alloc); - if (!updgrp) - return NULL; update_group_checkin(updgrp); if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0cbb341ff3..192af2216a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -123,6 +123,10 @@ FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, { .val_bool = false, .match_version = "< 7.6", }, { .val_bool = true }, ); +FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, + { .val_bool = false, .match_version = "< 8.3", }, + { .val_bool = true }, +); DEFINE_HOOK(bgp_inst_config_write, (struct bgp *bgp, struct vty *vty), @@ -569,6 +573,8 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); if (DFLT_BGP_SUPPRESS_DUPLICATES) SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); + if (DFLT_BGP_GRACEFUL_NOTIFICATION) + SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); ret = BGP_SUCCESS; } @@ -2868,6 +2874,24 @@ DEFUN (no_bgp_graceful_restart_preserve_fw, return CMD_SUCCESS; } +DEFPY (bgp_graceful_restart_notification, + bgp_graceful_restart_notification_cmd, + "[no$no] bgp graceful-restart notification", + NO_STR + BGP_STR + "Graceful restart capability parameters\n" + "Indicate Graceful Restart support for BGP NOTIFICATION messages\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + + if (no) + UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); + else + SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); + + return CMD_SUCCESS; +} + DEFUN (bgp_graceful_restart_disable, bgp_graceful_restart_disable_cmd, "bgp graceful-restart-disable", @@ -5273,6 +5297,12 @@ DEFUN (neighbor_capability_enhe, "Advertise extended next-hop capability to the peer\n") { int idx_peer = 1; + struct peer *peer; + + peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); + if (peer && peer->conf_if) + return CMD_SUCCESS; + return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); } @@ -5287,6 +5317,16 @@ DEFUN (no_neighbor_capability_enhe, "Advertise extended next-hop capability to the peer\n") { int idx_peer = 2; + struct peer *peer; + + peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); + if (peer && peer->conf_if) { + vty_out(vty, + "Peer %s cannot have capability extended-nexthop turned off\n", + argv[idx_peer]->arg); + return CMD_WARNING_CONFIG_FAILED; + } + return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); } @@ -16614,7 +16654,8 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, /* capability extended-nexthop */ if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { - if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) + if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE) && + !peer->conf_if) vty_out(vty, " no neighbor %s capability extended-nexthop\n", addr); @@ -17258,6 +17299,14 @@ int bgp_config_write(struct vty *vty) vty_out(vty, " bgp graceful-restart restart-time %u\n", bgp->restart_time); + if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != + SAVE_BGP_GRACEFUL_NOTIFICATION) + vty_out(vty, " %sbgp graceful-restart notification\n", + CHECK_FLAG(bgp->flags, + BGP_FLAG_GRACEFUL_NOTIFICATION) + ? "" + : "no "); + if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) vty_out(vty, " bgp graceful-restart select-defer-time %u\n", @@ -17890,6 +17939,7 @@ void bgp_vty_init(void) &no_bgp_graceful_restart_select_defer_time_cmd); install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); + install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 38fc51f507..33ed7d1d94 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1650,7 +1650,7 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer) /* * Since our su changed we need to del/add peer to the peerhash */ - hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); + (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); } void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi, safi_t safi) @@ -1737,7 +1737,7 @@ struct peer *peer_create(union sockunion *su, const char *conf_if, peer = peer_lock(peer); /* bgp peer list reference */ peer->group = group; listnode_add_sort(bgp->peer, peer); - hash_get(bgp->peerhash, peer, hash_alloc_intern); + (void)hash_get(bgp->peerhash, peer, hash_alloc_intern); /* Adjust update-group coalesce timer heuristics for # peers. */ if (bgp->heuristic_coalesce) { @@ -4487,7 +4487,9 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set) if (set) { bgp_zebra_initiate_radv(peer->bgp, peer); } else if (peer_group_active(peer)) { - if (!CHECK_FLAG(peer->group->conf->flags, flag)) + if (!CHECK_FLAG(peer->group->conf->flags, + flag) && + !peer->conf_if) bgp_zebra_terminate_radv(peer->bgp, peer); } else @@ -4525,7 +4527,7 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set) /* Update flag on peer-group member. */ COND_FLAG(member->flags, flag, set != member_invert); - if (flag == PEER_FLAG_CAPABILITY_ENHE) + if (flag == PEER_FLAG_CAPABILITY_ENHE && !member->conf_if) set ? bgp_zebra_initiate_radv(member->bgp, member) : bgp_zebra_terminate_radv(member->bgp, member); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index e43c529f35..a0de2dab69 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -453,7 +453,7 @@ struct bgp { #define BGP_LINK_BW_REF_BW 1 /* BGP flags. */ - uint32_t flags; + uint64_t flags; #define BGP_FLAG_ALWAYS_COMPARE_MED (1 << 0) #define BGP_FLAG_DETERMINISTIC_MED (1 << 1) #define BGP_FLAG_MED_MISSING_AS_WORST (1 << 2) @@ -488,6 +488,8 @@ struct bgp { #define BGP_FLAG_SUPPRESS_FIB_PENDING (1 << 26) #define BGP_FLAG_SUPPRESS_DUPLICATES (1 << 27) #define BGP_FLAG_PEERTYPE_MULTIPATH_RELAX (1 << 29) +/* Indicate Graceful Restart support for BGP NOTIFICATION messages */ +#define BGP_FLAG_GRACEFUL_NOTIFICATION (1 << 30) /* BGP default address-families. * New peers inherit enabled afi/safis from bgp instance. @@ -2448,7 +2450,7 @@ static inline uint32_t bgp_vrf_interfaces(struct bgp *bgp, bool active) if (vrf == NULL) return 0; RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) { - if (strncmp(ifp->name, bgp->name, VRF_NAMSIZ) == 0) + if (strcmp(ifp->name, bgp->name) == 0) continue; if (!active || if_is_up(ifp)) count++; diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index ba0c576f1e..44eebe961c 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -2108,10 +2108,9 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, sl); for (cursor = NULL, - rc = skiplist_next(sl, NULL, (void **)&m, - (void **)&cursor); + rc = skiplist_next(sl, NULL, (void **)&m, &cursor); !rc; rc = skiplist_next(sl, NULL, (void **)&m, - (void **)&cursor)) { + &cursor)) { #if DEBUG_PENDING_DELETE_ROUTE vnc_zlog_debug_verbose("%s: eth monitor rfd=%p", diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 6f99b41140..68d6d8714b 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -947,6 +947,15 @@ However, it MUST defer route selection for an address family until it either. expires. The stale path timer is started when the router receives a Route-Refresh BoRR message. +.. clicmd:: bgp graceful-restart notification + + Indicate Graceful Restart support for BGP NOTIFICATION messages. + + After changing this parameter, you have to reset the peers in order to advertise + N-bit in Graceful Restart capability. + + Enabled by default. + .. _bgp-per-peer-graceful-restart: BGP Per Peer Graceful Restart diff --git a/isisd/isis_lfa.c b/isisd/isis_lfa.c index 348381ee74..800cac8521 100644 --- a/isisd/isis_lfa.c +++ b/isisd/isis_lfa.c @@ -267,8 +267,8 @@ void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level) void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, const char *ifname) { - hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname, - lfa_excl_interface_hash_alloc); + (void)hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname, + lfa_excl_interface_hash_alloc); } /** diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index b5fce35b1e..49c62d2cf5 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -527,14 +527,14 @@ static void vertex_add_parent_firsthop(struct hash_bucket *bucket, void *arg) struct isis_vertex *vertex = arg; struct isis_vertex *hop = bucket->data; - hash_get(vertex->firsthops, hop, hash_alloc_intern); + (void)hash_get(vertex->firsthops, hop, hash_alloc_intern); } static void vertex_update_firsthops(struct isis_vertex *vertex, struct isis_vertex *parent) { if (vertex->d_N <= 2) - hash_get(vertex->firsthops, vertex, hash_alloc_intern); + (void)hash_get(vertex->firsthops, vertex, hash_alloc_intern); if (vertex->d_N < 2 || !parent) return; @@ -606,8 +606,8 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id, if (vertex->N.ip.sr.label != MPLS_INVALID_LABEL) vertex->N.ip.sr.present = true; - hash_get(spftree->prefix_sids, vertex, - hash_alloc_intern); + (void)hash_get(spftree->prefix_sids, vertex, + hash_alloc_intern); } } @@ -706,7 +706,7 @@ static void process_N(struct isis_spftree *spftree, enum vertextype vtype, if (vtype >= VTYPE_IPREACH_INTERNAL) { memcpy(&p, id, sizeof(p)); apply_mask(&p.dest); - apply_mask((struct prefix *)&p.src); + apply_mask(&p.src); id = &p; } diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 1a1e0dc294..579ae6aaba 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -439,7 +439,7 @@ static struct ls_vertex *lsp_to_vertex(struct ls_ted *ted, struct isis_lsp *lsp) SET_FLAG(lnode.flags, LS_NODE_ROUTER_ID6); } if (tlvs->hostname) { - memcpy(&lnode.name, tlvs->hostname, MAX_NAME_LENGTH); + strlcpy(lnode.name, tlvs->hostname, MAX_NAME_LENGTH); SET_FLAG(lnode.flags, LS_NODE_NAME); } if (tlvs->router_cap) { @@ -909,7 +909,7 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, p.u.prefix6 = std->local6; } if (!std) - p = *prefix; + prefix_copy(&p, prefix); else te_debug(" |- Adjust prefix %pFX with local address to: %pFX", prefix, &p); diff --git a/isisd/isis_tlvs.h b/isisd/isis_tlvs.h index 364e38aba1..157450dc6c 100644 --- a/isisd/isis_tlvs.h +++ b/isisd/isis_tlvs.h @@ -31,10 +31,8 @@ DECLARE_MTYPE(ISIS_SUBTLV); struct lspdb_head; -struct isis_subtlvs; struct sr_prefix_cfg; -struct isis_area_address; struct isis_area_address { struct isis_area_address *next; @@ -45,7 +43,6 @@ struct isis_area_address { #define ISIS_WIDE_METRIC_INFINITY 0xFFFFFE #define ISIS_NARROW_METRIC_INFINITY 62 -struct isis_oldstyle_reach; struct isis_oldstyle_reach { struct isis_oldstyle_reach *next; @@ -53,7 +50,6 @@ struct isis_oldstyle_reach { uint8_t metric; }; -struct isis_oldstyle_ip_reach; struct isis_oldstyle_ip_reach { struct isis_oldstyle_ip_reach *next; @@ -61,7 +57,6 @@ struct isis_oldstyle_ip_reach { struct prefix_ipv4 prefix; }; -struct isis_lsp_entry; struct isis_lsp_entry { struct isis_lsp_entry *next; @@ -73,8 +68,6 @@ struct isis_lsp_entry { struct isis_lsp *lsp; }; -struct isis_extended_reach; -struct isis_ext_subtlvs; struct isis_extended_reach { struct isis_extended_reach *next; @@ -84,7 +77,6 @@ struct isis_extended_reach { struct isis_ext_subtlvs *subtlvs; }; -struct isis_extended_ip_reach; struct isis_extended_ip_reach { struct isis_extended_ip_reach *next; @@ -95,7 +87,6 @@ struct isis_extended_ip_reach { struct isis_subtlvs *subtlvs; }; -struct isis_ipv6_reach; struct isis_ipv6_reach { struct isis_ipv6_reach *next; @@ -162,7 +153,6 @@ struct isis_sr_block { #define ISIS_PREFIX_SID_VALUE 0x08 #define ISIS_PREFIX_SID_LOCAL 0x04 -struct isis_prefix_sid; struct isis_prefix_sid { struct isis_prefix_sid *next; @@ -179,7 +169,6 @@ struct isis_prefix_sid { #define EXT_SUBTLV_LINK_ADJ_SID_SFLG 0x08 #define EXT_SUBTLV_LINK_ADJ_SID_PFLG 0x04 -struct isis_adj_sid; struct isis_adj_sid { struct isis_adj_sid *next; @@ -189,7 +178,6 @@ struct isis_adj_sid { uint32_t sid; }; -struct isis_lan_adj_sid; struct isis_lan_adj_sid { struct isis_lan_adj_sid *next; @@ -230,33 +218,28 @@ struct isis_router_cap { uint8_t msd; }; -struct isis_item; struct isis_item { struct isis_item *next; }; -struct isis_lan_neighbor; struct isis_lan_neighbor { struct isis_lan_neighbor *next; uint8_t mac[6]; }; -struct isis_ipv4_address; struct isis_ipv4_address { struct isis_ipv4_address *next; struct in_addr addr; }; -struct isis_ipv6_address; struct isis_ipv6_address { struct isis_ipv6_address *next; struct in6_addr addr; }; -struct isis_mt_router_info; struct isis_mt_router_info { struct isis_mt_router_info *next; @@ -265,7 +248,6 @@ struct isis_mt_router_info { uint16_t mtid; }; -struct isis_auth; struct isis_auth { struct isis_auth *next; @@ -279,7 +261,6 @@ struct isis_auth { size_t offset; /* Only valid after packing */ }; -struct isis_item_list; struct isis_item_list { struct isis_item *head; struct isis_item **tail; diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index fd0097ca5e..02eaf10eb7 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -352,7 +352,7 @@ struct iface_ldp_sync { struct iface { RB_ENTRY(iface) entry; - char name[IF_NAMESIZE]; + char name[INTERFACE_NAMSIZ]; ifindex_t ifindex; struct if_addr_head addr_list; struct in6_addr linklocal; @@ -458,7 +458,7 @@ struct ldp_entity_stats { struct l2vpn_if { RB_ENTRY(l2vpn_if) entry; struct l2vpn *l2vpn; - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; int operative; uint8_t mac[ETH_ALEN]; @@ -475,7 +475,7 @@ struct l2vpn_pw { int af; union ldpd_addr addr; uint32_t pwid; - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; bool enabled; uint32_t remote_group; @@ -507,7 +507,7 @@ struct l2vpn { int type; int pw_type; int mtu; - char br_ifname[IF_NAMESIZE]; + char br_ifname[INTERFACE_NAMSIZ]; ifindex_t br_ifindex; struct l2vpn_if_head if_tree; struct l2vpn_pw_head pw_tree; @@ -629,7 +629,7 @@ struct kroute { }; struct kaddr { - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; int af; union ldpd_addr addr; @@ -638,7 +638,7 @@ struct kaddr { }; struct kif { - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; int flags; int operative; @@ -656,7 +656,7 @@ struct acl_check { /* control data structures */ struct ctl_iface { int af; - char name[IF_NAMESIZE]; + char name[INTERFACE_NAMSIZ]; ifindex_t ifindex; int state; enum iface_type type; @@ -667,7 +667,7 @@ struct ctl_iface { }; struct ctl_disc_if { - char name[IF_NAMESIZE]; + char name[INTERFACE_NAMSIZ]; int active_v4; int active_v6; int no_adj; @@ -683,7 +683,7 @@ struct ctl_adj { int af; struct in_addr id; enum hello_type type; - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; union ldpd_addr src_addr; uint16_t holdtime; uint16_t holdtime_remaining; @@ -723,7 +723,7 @@ struct ctl_rt { struct ctl_pw { uint16_t type; char l2vpn_name[L2VPN_NAME_LEN]; - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; uint32_t pwid; struct in_addr lsr_id; uint32_t local_label; @@ -739,7 +739,7 @@ struct ctl_pw { }; struct ctl_ldp_sync { - char name[IF_NAMESIZE]; + char name[INTERFACE_NAMSIZ]; ifindex_t ifindex; bool in_sync; bool timer_running; diff --git a/lib/command.c b/lib/command.c index a429510059..c4db045633 100644 --- a/lib/command.c +++ b/lib/command.c @@ -315,7 +315,7 @@ void _install_element(enum node_type ntype, const struct cmd_element *cmd) return; } - assert(hash_get(cnode->cmd_hash, (void *)cmd, hash_alloc_intern)); + (void)hash_get(cnode->cmd_hash, (void *)cmd, hash_alloc_intern); if (cnode->graph_built || !defer_cli_tree) { struct graph *graph = graph_new(); diff --git a/lib/ferr.c b/lib/ferr.c index e5b6d7552d..9d79f38b7c 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -86,7 +86,7 @@ void log_ref_add(struct log_ref *ref) frr_with_mutex(&refs_mtx) { while (ref[i].code != END_FERR) { - hash_get(refs, &ref[i], hash_alloc_intern); + (void)hash_get(refs, &ref[i], hash_alloc_intern); i++; } } diff --git a/lib/frrscript.c b/lib/frrscript.c index 8add44c19e..a19bd0c3db 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -333,7 +333,7 @@ void frrscript_register_type_codec(struct frrscript_codec *codec) assert(!"Type codec double-registered."); } - assert(hash_get(codec_hash, &c, codec_alloc)); + (void)hash_get(codec_hash, &c, codec_alloc); } void frrscript_register_type_codecs(struct frrscript_codec *codecs) @@ -399,7 +399,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name, /* Add the Lua function state to frrscript */ struct lua_function_state key = {.name = function_name, .L = L}; - hash_get(fs->lua_function_hash, &key, lua_function_alloc); + (void)hash_get(fs->lua_function_hash, &key, lua_function_alloc); return 0; fail: @@ -103,7 +103,7 @@ enum zebra_link_type { #define IFNAMSIZ 16 */ -#define INTERFACE_NAMSIZ 20 +#define INTERFACE_NAMSIZ IFNAMSIZ #define INTERFACE_HWADDR_MAX 20 typedef signed int ifindex_t; diff --git a/lib/northbound.c b/lib/northbound.c index 2cc7ac6ea1..ccfc3840ec 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -2216,7 +2216,8 @@ void nb_running_move_tree(const char *xpath_from, const char *xpath_to) strlcpy(entry->xpath, newpath, sizeof(entry->xpath)); XFREE(MTYPE_TMP, newpath); - hash_get(running_config_entries, entry, hash_alloc_intern); + (void)hash_get(running_config_entries, entry, + hash_alloc_intern); } list_delete(&entries); diff --git a/lib/zclient.c b/lib/zclient.c index 0c34214151..a933b6bb2b 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -3551,7 +3551,7 @@ enum zclient_send_status zebra_send_pw(struct zclient *zclient, int command, stream_reset(s); zclient_create_header(s, command, VRF_DEFAULT); - stream_write(s, pw->ifname, IF_NAMESIZE); + stream_write(s, pw->ifname, INTERFACE_NAMSIZ); stream_putl(s, pw->ifindex); /* Put type */ @@ -3598,7 +3598,7 @@ int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS, struct zapi_pw_status *pw) s = zclient->ibuf; /* Get data. */ - stream_get(pw->ifname, s, IF_NAMESIZE); + stream_get(pw->ifname, s, INTERFACE_NAMSIZ); STREAM_GETL(s, pw->ifindex); STREAM_GETL(s, pw->status); diff --git a/lib/zclient.h b/lib/zclient.h index 78eb73c530..9756923a69 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -618,7 +618,7 @@ struct zapi_sr_policy { }; struct zapi_pw { - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; int type; int af; @@ -631,7 +631,7 @@ struct zapi_pw { }; struct zapi_pw_status { - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; uint32_t status; }; diff --git a/nhrpd/reqid.c b/nhrpd/reqid.c index e56bbe3bf7..738e935ec2 100644 --- a/nhrpd/reqid.c +++ b/nhrpd/reqid.c @@ -29,7 +29,7 @@ uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r, if (++p->next_request_id == 0) p->next_request_id = 1; r->cb = cb; - hash_get(p->reqid_hash, r, hash_alloc_intern); + (void)hash_get(p->reqid_hash, r, hash_alloc_intern); } return r->request_id; } diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 63444f8e57..0ca4eb3d5d 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1562,7 +1562,7 @@ static void ospf6_link_route_to_aggr(struct ospf6_external_aggr_rt *aggr, struct ospf6_route *rt) { - hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern); + (void)hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern); rt->aggr_route = aggr; } diff --git a/ospf6d/ospf6_auth_trailer.c b/ospf6d/ospf6_auth_trailer.c index 1095473f4a..1f3f87751a 100644 --- a/ospf6d/ospf6_auth_trailer.c +++ b/ospf6d/ospf6_auth_trailer.c @@ -144,8 +144,6 @@ unsigned char *ospf6_hash_message_xor(unsigned char *mes1, uint32_t i; result = XCALLOC(MTYPE_OSPF6_AUTH_HASH_XOR, len); - if (!result) - return NULL; for (i = 0; i < len; i++) result[i] = mes1[i] ^ mes2[i]; diff --git a/ospf6d/ospf6_gr_helper.c b/ospf6d/ospf6_gr_helper.c index 7b5ffc920b..493dc6f093 100644 --- a/ospf6d/ospf6_gr_helper.c +++ b/ospf6d/ospf6_gr_helper.c @@ -831,8 +831,8 @@ static void ospf6_gr_helper_support_set_per_routerid(struct ospf6 *ospf6, } else { /* Add the routerid to the enable router hash table */ - hash_get(ospf6->ospf6_helper_cfg.enable_rtr_list, &temp, - ospf6_enable_rtr_hash_alloc); + (void)hash_get(ospf6->ospf6_helper_cfg.enable_rtr_list, &temp, + ospf6_enable_rtr_hash_alloc); } } diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 2a6d7cd099..634eabbf70 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -1761,8 +1761,8 @@ bool ospf6_is_valid_summary_addr(struct vty *vty, struct prefix *p) memset(&addr_zero, 0, sizeof(struct in6_addr)); /* Default prefix validation*/ - if ((is_default_prefix((struct prefix *)p)) - || (!memcmp(&p->u.prefix6, &addr_zero, sizeof(struct in6_addr)))) { + if ((is_default_prefix(p)) || + (!memcmp(&p->u.prefix6, &addr_zero, sizeof(struct in6_addr)))) { vty_out(vty, "Default address should not be configured as summary address.\n"); return false; } @@ -1802,7 +1802,7 @@ DEFPY (ospf6_external_route_aggregation, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!ospf6_is_valid_summary_addr(vty, &p)) return CMD_WARNING_CONFIG_FAILED; @@ -1850,7 +1850,7 @@ DEFPY(no_ospf6_external_route_aggregation, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!ospf6_is_valid_summary_addr(vty, &p)) return CMD_WARNING_CONFIG_FAILED; @@ -1881,7 +1881,7 @@ DEFPY (ospf6_external_route_aggregation_no_advertise, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!ospf6_is_valid_summary_addr(vty, &p)) return CMD_WARNING_CONFIG_FAILED; @@ -1913,7 +1913,7 @@ DEFPY (no_ospf6_external_route_aggregation_no_advertise, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!ospf6_is_valid_summary_addr(vty, &p)) return CMD_WARNING_CONFIG_FAILED; diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 70581b9085..9d4ce97fa5 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -595,7 +595,7 @@ static void ospf_link_ei_to_aggr(struct ospf_external_aggr_rt *aggr, "%s: Linking extrenal route(%pI4/%d) to aggregator(%pI4/%d)", __func__, &ei->p.prefix, ei->p.prefixlen, &aggr->p.prefix, aggr->p.prefixlen); - hash_get(aggr->match_extnl_hash, ei, hash_alloc_intern); + (void)hash_get(aggr->match_extnl_hash, ei, hash_alloc_intern); ei->aggr_route = aggr; } diff --git a/ospfd/ospf_gr_helper.c b/ospfd/ospf_gr_helper.c index 92236cf44f..624133ad6b 100644 --- a/ospfd/ospf_gr_helper.c +++ b/ospfd/ospf_gr_helper.c @@ -933,8 +933,8 @@ void ospf_gr_helper_support_set_per_routerid(struct ospf *ospf, } else { /* Add the routerid to the enable router hash table */ - hash_get(ospf->enable_rtr_list, &temp, - ospf_enable_rtr_hash_alloc); + (void)hash_get(ospf->enable_rtr_list, &temp, + ospf_enable_rtr_hash_alloc); } } diff --git a/ospfd/ospf_ldp_sync.c b/ospfd/ospf_ldp_sync.c index b4d770d48a..330a433627 100644 --- a/ospfd/ospf_ldp_sync.c +++ b/ospfd/ospf_ldp_sync.c @@ -326,7 +326,7 @@ void ospf_ldp_sync_if_remove(struct interface *ifp, bool remove) if (!CHECK_FLAG(ldp_sync_info->flags, LDP_SYNC_FLAG_IF_CONFIG)) ldp_sync_info->enabled = LDP_IGP_SYNC_DEFAULT; if (remove) { - ldp_sync_info_free((struct ldp_sync_info **)&(ldp_sync_info)); + ldp_sync_info_free(&ldp_sync_info); params->ldp_sync_info = NULL; } } diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index c861685f4e..090a655cee 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -1463,14 +1463,6 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa) srn = (struct sr_node *)hash_get(OspfSR.neighbors, &lsah->adv_router, (void *)sr_node_new); - /* Sanity check */ - if (srn == NULL) { - flog_err( - EC_OSPF_SR_NODE_CREATE, - "SR (%s): Abort! can't create SR node in hash table", - __func__); - return; - } /* update LSA ID */ srn->instance = ntohl(lsah->id.s_addr); /* Copy SRGB */ @@ -1582,14 +1574,6 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa) (void *)&(lsah->adv_router), (void *)sr_node_new); - /* Sanity check */ - if (srn == NULL) { - flog_err(EC_OSPF_SR_NODE_CREATE, - "SR (%s): Abort! can't create SR node in hash table", - __func__); - return; - } - /* Initialize TLV browsing */ length = lsa->size - OSPF_LSA_HEADER_SIZE; for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh; @@ -1814,15 +1798,6 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa) srn = (struct sr_node *)hash_get(OspfSR.neighbors, (void *)&(lsah->adv_router), (void *)sr_node_new); - - /* Sanity check */ - if (srn == NULL) { - flog_err(EC_OSPF_SR_NODE_CREATE, - "SR (%s): Abort! can't create SR node in hash table", - __func__); - return; - } - /* Initialize TLV browsing */ length = lsa->size - OSPF_LSA_HEADER_SIZE; for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 3bd4a9bb68..20b9180cff 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10036,7 +10036,7 @@ DEFUN (ospf_external_route_aggregation, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!is_valid_summary_addr(&p)) { vty_out(vty, "Not a valid summary address.\n"); @@ -10077,7 +10077,7 @@ DEFUN (no_ospf_external_route_aggregation, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!is_valid_summary_addr(&p)) { vty_out(vty, "Not a valid summary address.\n"); @@ -10377,7 +10377,7 @@ DEFUN (ospf_external_route_aggregation_no_adrvertise, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!is_valid_summary_addr(&p)) { vty_out(vty, "Not a valid summary address.\n"); @@ -10413,7 +10413,7 @@ DEFUN (no_ospf_external_route_aggregation_no_adrvertise, } /* Apply mask for given prefix. */ - apply_mask((struct prefix *)&p); + apply_mask(&p); if (!is_valid_summary_addr(&p)) { vty_out(vty, "Not a valid summary address.\n"); diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c index 7710f3277d..5daac55deb 100644 --- a/pbrd/pbr_map.c +++ b/pbrd/pbr_map.c @@ -408,8 +408,7 @@ struct pbr_map_sequence *pbrms_lookup_unique(uint32_t unique, char *ifname, RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps) { for (ALL_LIST_ELEMENTS_RO(pbrm->incoming, inode, pmi)) { - if (strncmp(pmi->ifp->name, ifname, INTERFACE_NAMSIZ) - != 0) + if (strcmp(pmi->ifp->name, ifname) != 0) continue; if (ppmi) diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index fb0bd72585..cbff4832a4 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -1041,8 +1041,9 @@ static int pbr_nht_individual_nexthop_vrf_handle(struct hash_bucket *b, nhrcvi.nhrc); nhrcvi.nhrc->nexthop.vrf_id = pbr_vrf_id(pnhi->pbr_vrf); - hash_get(pbr_nhrc_hash, nhrcvi.nhrc, - hash_alloc_intern); + (void)hash_get(pbr_nhrc_hash, + nhrcvi.nhrc, + hash_alloc_intern); pbr_send_rnh(&nhrcvi.nhrc->nexthop, true); } } while (nhrcvi.nhrc); @@ -1087,7 +1088,8 @@ static void pbr_nht_nexthop_vrf_handle(struct hash_bucket *b, void *data) if (pnhi.pnhc) { pnhi.pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf); - hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern); + (void)hash_get(pnhgc->nhh, pnhi.pnhc, + hash_alloc_intern); } else pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf); @@ -1141,11 +1143,11 @@ static void pbr_nht_nexthop_interface_handle(struct hash_bucket *b, void *data) if (nhrc) { hash_release(pbr_nhrc_hash, nhrc); nhrc->nexthop.ifindex = ifp->ifindex; - hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern); + (void)hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern); } pnhi.pnhc->nexthop.ifindex = ifp->ifindex; - hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern); + (void)hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern); pbr_map_check_interface_nh_group_change(pnhgc->name, ifp, old_ifindex); @@ -1290,7 +1292,7 @@ uint32_t pbr_nht_reserve_next_table_id(struct pbr_nexthop_group_cache *nhgc) nhgc->table_id = pbr_next_unallocated_table_id; /* Mark table id as allocated in id-indexed hash */ - hash_get(pbr_nhg_allocated_id_hash, nhgc, hash_alloc_intern); + (void)hash_get(pbr_nhg_allocated_id_hash, nhgc, hash_alloc_intern); /* Pre-compute the next unallocated table id */ pbr_nht_update_next_unallocated_table_id(); diff --git a/pceplib/pcep_msg_objects.c b/pceplib/pcep_msg_objects.c index e253fcc540..ce41ee953f 100644 --- a/pceplib/pcep_msg_objects.c +++ b/pceplib/pcep_msg_objects.c @@ -674,8 +674,9 @@ pcep_obj_create_ro_subobj_sr_ipv4_node(bool loose_hop, bool sid_absent, } obj->nai_list = dll_initialize(); /* Since the IP has to be stored in the list, copy it so the caller - * doesnt have any restrictions about the type of memory used externally - * for the IP. This memory will be freed with the object is freed. */ + * doesn't have any restrictions about the type of memory used + * externally for the IP. This memory will be freed with the object is + * freed. */ struct in_addr *ipv4_node_id_copy = pceplib_malloc(PCEPLIB_MESSAGES, sizeof(struct in_addr)); ipv4_node_id_copy->s_addr = ipv4_node_id->s_addr; diff --git a/pceplib/pcep_msg_objects_encoding.c b/pceplib/pcep_msg_objects_encoding.c index 69420f8e7a..75eb112e2e 100644 --- a/pceplib/pcep_msg_objects_encoding.c +++ b/pceplib/pcep_msg_objects_encoding.c @@ -463,7 +463,7 @@ uint16_t pcep_encode_obj_bandwidth(struct pcep_object_header *hdr, struct pcep_object_bandwidth *bandwidth = (struct pcep_object_bandwidth *)hdr; uint32_t *uint32_ptr = (uint32_t *)obj_body_buf; - /* Seems like the compiler doesnt correctly copy the float, so memcpy() + /* Seems like the compiler doesn't correctly copy the float, so memcpy() * it */ memcpy(uint32_ptr, &(bandwidth->bandwidth), sizeof(uint32_t)); *uint32_ptr = htonl(*uint32_ptr); @@ -481,7 +481,7 @@ uint16_t pcep_encode_obj_metric(struct pcep_object_header *hdr, | (metric->flag_b ? OBJECT_METRIC_FLAC_B : 0x00)); obj_body_buf[3] = metric->type; uint32_t *uint32_ptr = (uint32_t *)(obj_body_buf + 4); - /* Seems like the compiler doesnt correctly copy the float, so memcpy() + /* Seems like the compiler doesn't correctly copy the float, so memcpy() * it */ memcpy(uint32_ptr, &(metric->value), sizeof(uint32_t)); *uint32_ptr = htonl(*uint32_ptr); @@ -1206,7 +1206,7 @@ pcep_decode_obj_bandwidth(struct pcep_object_header *hdr, hdr, sizeof(struct pcep_object_bandwidth)); uint32_t value = ntohl(*((uint32_t *)obj_buf)); - /* Seems like the compiler doesnt correctly copy to the float, so + /* Seems like the compiler doesn't correctly copy to the float, so * memcpy() it */ memcpy(&obj->bandwidth, &value, sizeof(uint32_t)); @@ -1223,7 +1223,7 @@ pcep_decode_obj_metric(struct pcep_object_header *hdr, const uint8_t *obj_buf) obj->flag_c = (obj_buf[2] & OBJECT_METRIC_FLAC_C); obj->type = obj_buf[3]; uint32_t value = ntohl(*((uint32_t *)(obj_buf + 4))); - /* Seems like the compiler doesnt correctly copy to the float, so + /* Seems like the compiler doesn't correctly copy to the float, so * memcpy() it */ memcpy(&obj->value, &value, sizeof(uint32_t)); diff --git a/pceplib/pcep_msg_tlvs_encoding.c b/pceplib/pcep_msg_tlvs_encoding.c index c46e859c49..b5a65d457b 100644 --- a/pceplib/pcep_msg_tlvs_encoding.c +++ b/pceplib/pcep_msg_tlvs_encoding.c @@ -1185,8 +1185,7 @@ pcep_decode_tlv_pol_id(struct pcep_object_tlv_header *tlv_hdr, return (struct pcep_object_tlv_header *)ipv4; } else { ipv4->is_ipv4 = false; - struct pcep_object_tlv_srpag_pol_id *ipv6 = - (struct pcep_object_tlv_srpag_pol_id *)ipv4; + struct pcep_object_tlv_srpag_pol_id *ipv6 = ipv4; ipv6->color = ntohl(uint32_ptr[0]); decode_ipv6(&uint32_ptr[1], &ipv6->end_point.ipv6); return (struct pcep_object_tlv_header *)ipv6; diff --git a/pceplib/pcep_socket_comm_loop.c b/pceplib/pcep_socket_comm_loop.c index d9a6b9ae48..ed8037d074 100644 --- a/pceplib/pcep_socket_comm_loop.c +++ b/pceplib/pcep_socket_comm_loop.c @@ -354,7 +354,7 @@ void handle_writes(pcep_socket_comm_handle *socket_comm_handle) if (comm_session->close_after_write == true) { if (comm_session->message_queue->num_entries == 0) { /* TODO check to make sure modifying the - * write_list while iterating it doesnt cause + * write_list while iterating it doesn't cause * problems. */ pcep_log( LOG_DEBUG, diff --git a/pceplib/test/pcep_session_logic_states_test.c b/pceplib/test/pcep_session_logic_states_test.c index e967d74e48..17ddae669f 100644 --- a/pceplib/test/pcep_session_logic_states_test.c +++ b/pceplib/test/pcep_session_logic_states_test.c @@ -281,7 +281,7 @@ void test_handle_timer_event_open_keep_alive() void test_handle_socket_comm_event_null_params() { - /* Verify it doesnt core dump */ + /* Verify it doesn't core dump */ handle_socket_comm_event(NULL); verify_socket_comm_times_called(0, 0, 0, 0, 0, 0, 0); reset_mock_socket_comm_info(); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index b58727d9b5..55e58f2d9a 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -887,7 +887,7 @@ static void pim_show_interface_traffic(struct pim_instance *pim, json_object_int_add(json_row, "registerRx", pim_ifp->pim_ifstat_reg_recv); json_object_int_add(json_row, "registerTx", - pim_ifp->pim_ifstat_reg_recv); + pim_ifp->pim_ifstat_reg_send); json_object_int_add(json_row, "registerStopRx", pim_ifp->pim_ifstat_reg_stop_recv); json_object_int_add(json_row, "registerStopTx", @@ -980,7 +980,7 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim, json_object_int_add(json_row, "registerRx", pim_ifp->pim_ifstat_reg_recv); json_object_int_add(json_row, "registerTx", - pim_ifp->pim_ifstat_reg_recv); + pim_ifp->pim_ifstat_reg_send); json_object_int_add(json_row, "registerStopRx", pim_ifp->pim_ifstat_reg_stop_recv); json_object_int_add(json_row, "registerStopTx", diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index eec763a4ff..c1242e1509 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -151,7 +151,7 @@ int pim_find_or_track_nexthop(struct pim_instance *pim, struct prefix *addr, } if (up != NULL) - hash_get(pnc->upstream_hash, up, hash_alloc_intern); + (void)hash_get(pnc->upstream_hash, up, hash_alloc_intern); if (CHECK_FLAG(pnc->flags, PIM_NEXTHOP_VALID)) { if (out_pnc) diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index e103cdc3a8..5fc1e34592 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -217,7 +217,7 @@ int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to, msg.msg_namelen = sizeof(struct sockaddr_in6); msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = (void *)adata; + msg.msg_control = adata; msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); iov.iov_base = buf; diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c index 3cc9a63072..ef1fcf5cec 100644 --- a/tests/bgpd/test_aspath.c +++ b/tests/bgpd/test_aspath.c @@ -1012,7 +1012,7 @@ static int validate(struct aspath *as, const struct test_spec *sp) fails++; printf("firstas: %d, got %d\n", sp->first, aspath_firstas_check(as, sp->first)); - printf("loop does: %d %d, doesnt: %d %d\n", sp->does_loop, + printf("loop does: %d %d, doesn't: %d %d\n", sp->does_loop, aspath_loop_check(as, sp->does_loop), sp->doesnt_loop, aspath_loop_check(as, sp->doesnt_loop)); printf("private check: %d %d\n", sp->private_as, diff --git a/tests/lib/test_srcdest_table.c b/tests/lib/test_srcdest_table.c index 097da113ab..2d8f024d16 100644 --- a/tests/lib/test_srcdest_table.c +++ b/tests/lib/test_srcdest_table.c @@ -160,7 +160,7 @@ static void test_state_add_route(struct test_state *test, } rn->info = (void *)0xdeadbeef; - hash_get(test->log, hash_entry, log_alloc); + (void)hash_get(test->log, hash_entry, log_alloc); }; static void test_state_del_route(struct test_state *test, @@ -328,7 +328,7 @@ static void get_rand_prefix(struct prng *prng, struct prefix_ipv6 *p) p->prefixlen = prng_rand(prng) % 129; p->family = AF_INET6; - apply_mask((struct prefix *)p); + apply_mask(p); } static void get_rand_prefix_pair(struct prng *prng, struct prefix_ipv6 *dst_p, diff --git a/tests/lib/test_timer_correctness.c b/tests/lib/test_timer_correctness.c index 4172ca3001..475fabd2d7 100644 --- a/tests/lib/test_timer_correctness.c +++ b/tests/lib/test_timer_correctness.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) prng = prng_new(0); - timers = XMALLOC(MTYPE_TMP, SCHEDULE_TIMERS * sizeof(*timers)); + timers = XCALLOC(MTYPE_TMP, SCHEDULE_TIMERS * sizeof(*timers)); for (i = 0; i < SCHEDULE_TIMERS; i++) { long interval_msec; @@ -159,7 +159,7 @@ int main(int argc, char **argv) * representing the expected "output" of the timers when they * are run. */ j = 0; - alarms = XMALLOC(MTYPE_TMP, timers_pending * sizeof(*alarms)); + alarms = XCALLOC(MTYPE_TMP, timers_pending * sizeof(*alarms)); for (i = 0; i < SCHEDULE_TIMERS; i++) { if (!timers[i]) continue; diff --git a/tests/topotests/lib/micronet.py b/tests/topotests/lib/micronet.py index 59dd80ff7b..d7b680da18 100644 --- a/tests/topotests/lib/micronet.py +++ b/tests/topotests/lib/micronet.py @@ -266,7 +266,7 @@ class Commander(object): # pylint: disable=R0205 ) if raises: # error = Exception("stderr: {}".format(stderr)) - # This annoyingly doesnt' show stderr when printed normally + # This annoyingly doesn't' show stderr when printed normally error = subprocess.CalledProcessError(rc, actual_cmd) error.stdout, error.stderr = stdout, stderr raise error diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index dae1e4894e..3081c0d955 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -654,7 +654,7 @@ struct vrrp_vrouter *vrrp_vrouter_create(struct interface *ifp, uint8_t vrid, vrrp_set_advertisement_interval(vr, vd.advertisement_interval); - hash_get(vrrp_vrouters_hash, vr, hash_alloc_intern); + (void)hash_get(vrrp_vrouters_hash, vr, hash_alloc_intern); return vr; } diff --git a/zebra/table_manager.c b/zebra/table_manager.c index ffc7a48eb9..a3daca6c59 100644 --- a/zebra/table_manager.c +++ b/zebra/table_manager.c @@ -119,8 +119,6 @@ struct table_manager_chunk *assign_table_chunk(uint8_t proto, uint16_t instance, } /* otherwise create a new one */ tmc = XCALLOC(MTYPE_TM_CHUNK, sizeof(struct table_manager_chunk)); - if (!tmc) - return NULL; if (zvrf->tbl_mgr->start || zvrf->tbl_mgr->end) manual_conf = true; diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index e996f6c956..9972d32fb7 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1040,7 +1040,7 @@ int zsend_pw_update(struct zserv *client, struct zebra_pw *pw) struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ); zclient_create_header(s, ZEBRA_PW_STATUS_UPDATE, pw->vrf_id); - stream_write(s, pw->ifname, IF_NAMESIZE); + stream_write(s, pw->ifname, INTERFACE_NAMSIZ); stream_putl(s, pw->ifindex); stream_putl(s, pw->status); @@ -2998,7 +2998,7 @@ static void zread_srv6_manager_request(ZAPI_HANDLER_ARGS) static void zread_pseudowire(ZAPI_HANDLER_ARGS) { struct stream *s; - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; int type; int af; @@ -3014,8 +3014,8 @@ static void zread_pseudowire(ZAPI_HANDLER_ARGS) s = msg; /* Get data. */ - STREAM_GET(ifname, s, IF_NAMESIZE); - ifname[IF_NAMESIZE - 1] = '\0'; + STREAM_GET(ifname, s, INTERFACE_NAMSIZ); + ifname[INTERFACE_NAMSIZ - 1] = '\0'; STREAM_GETL(s, ifindex); STREAM_GETL(s, type); STREAM_GETL(s, af); diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index d223a21eda..121092a55b 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -1022,7 +1022,6 @@ struct zebra_evpn *zebra_evpn_add(vni_t vni) memset(&tmp_zevpn, 0, sizeof(struct zebra_evpn)); tmp_zevpn.vni = vni; zevpn = hash_get(zvrf->evpn_table, &tmp_zevpn, zebra_evpn_alloc); - assert(zevpn); zebra_evpn_es_evi_init(zevpn); diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index 128d233969..5a1f5af5d7 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -1105,7 +1105,6 @@ struct zebra_mac *zebra_evpn_mac_add(struct zebra_evpn *zevpn, memset(&tmp_mac, 0, sizeof(struct zebra_mac)); memcpy(&tmp_mac.macaddr, macaddr, ETH_ALEN); mac = hash_get(zevpn->mac_table, &tmp_mac, zebra_evpn_mac_alloc); - assert(mac); mac->zevpn = zevpn; mac->dad_mac_auto_recovery_timer = NULL; diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index b1e48374c4..7728f50123 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -570,10 +570,7 @@ zebra_evpn_acc_vl_new(vlanid_t vid, struct interface *br_if) acc_bd->mbr_zifs = list_new(); /* Add to hash */ - if (!hash_get(zmh_info->evpn_vlan_table, acc_bd, hash_alloc_intern)) { - XFREE(MTYPE_ZACC_BD, acc_bd); - return NULL; - } + (void)hash_get(zmh_info->evpn_vlan_table, acc_bd, hash_alloc_intern); /* check if an svi exists for the vlan */ if (br_if) { @@ -1091,10 +1088,7 @@ static uint32_t zebra_evpn_nhid_alloc(struct zebra_evpn_es *es) nh_id = id | EVPN_NHG_ID_TYPE_BIT; /* Add to NHG hash */ es->nhg_id = nh_id; - if (!hash_get(zmh_info->nhg_table, es, hash_alloc_intern)) { - bf_release_index(zmh_info->nh_id_bitmap, id); - return 0; - } + (void)hash_get(zmh_info->nhg_table, es, hash_alloc_intern); } else { nh_id = id | EVPN_NH_ID_TYPE_BIT; } @@ -1361,10 +1355,7 @@ static struct zebra_evpn_l2_nh *zebra_evpn_l2_nh_alloc(struct in_addr vtep_ip) nh = XCALLOC(MTYPE_L2_NH, sizeof(*nh)); nh->vtep_ip = vtep_ip; - if (!hash_get(zmh_info->nh_ip_table, nh, hash_alloc_intern)) { - XFREE(MTYPE_L2_NH, nh); - return NULL; - } + (void)hash_get(zmh_info->nh_ip_table, nh, hash_alloc_intern); nh->nh_id = zebra_evpn_nhid_alloc(NULL); if (!nh->nh_id) { diff --git a/zebra/zebra_evpn_neigh.c b/zebra/zebra_evpn_neigh.c index ed224151ba..734a53c571 100644 --- a/zebra/zebra_evpn_neigh.c +++ b/zebra/zebra_evpn_neigh.c @@ -553,7 +553,6 @@ static struct zebra_neigh *zebra_evpn_neigh_add(struct zebra_evpn *zevpn, memset(&tmp_n, 0, sizeof(struct zebra_neigh)); memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr)); n = hash_get(zevpn->neigh_table, &tmp_n, zebra_evpn_neigh_alloc); - assert(n); n->state = ZEBRA_NEIGH_INACTIVE; n->zevpn = zevpn; diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 6766c752ad..7c57dfac6a 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1596,12 +1596,9 @@ static int zfpm_trigger_rmac_update(struct zebra_mac *rmac, UNSET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM); return 0; } - } else { + } else fpm_mac = hash_get(zfpm_g->fpm_mac_info_table, &key, zfpm_mac_info_alloc); - if (!fpm_mac) - return 0; - } fpm_mac->r_vtep_ip.s_addr = rmac->fwd_info.r_vtep_ip.s_addr; fpm_mac->zebra_flags = rmac->flags; diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 924a43049b..de7b6a177d 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -188,8 +188,6 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label, /* Locate or allocate LSP entry. */ tmp_ile.in_label = label; lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc); - if (!lsp) - return -1; /* For each active nexthop, create NHLFE. Note that we deliberately skip * recursive nexthops right now, because intermediate hops won't @@ -2920,8 +2918,6 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf, /* Find or create LSP object */ tmp_ile.in_label = zl->local_label; lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc); - if (!lsp) - return -1; } /* Prep for route/FEC update if requested */ @@ -3199,8 +3195,6 @@ int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type, /* Find or create LSP object */ tmp_ile.in_label = in_label; lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc); - if (!lsp) - return -1; nhlfe = lsp_add_nhlfe(lsp, type, num_out_labels, out_labels, gtype, gate, ifindex, false /*backup*/); @@ -3562,8 +3556,6 @@ int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label, /* Find or create LSP. */ tmp_ile.in_label = in_label; lsp = hash_get(slsp_table, &tmp_ile, lsp_alloc); - if (!lsp) - return -1; nhlfe = nhlfe_find(&lsp->nhlfe_list, ZEBRA_LSP_STATIC, gtype, gate, ifindex); diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index a9cb096aee..219e4d028a 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -248,7 +248,7 @@ lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args *args) if (args->list_entry == NULL) rn = route_top(zrt->table); else - rn = srcdest_route_next((struct route_node *)rn); + rn = srcdest_route_next(rn); /* Optimization: skip empty route nodes. */ while (rn && rn->info == NULL) rn = route_next(rn); diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 069d35c6a3..cf09902d52 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -329,7 +329,7 @@ static int zebra_nhg_insert_id(struct nhg_hash_entry *nhe) return -1; } - hash_get(zrouter.nhgs_id, nhe, hash_alloc_intern); + (void)hash_get(zrouter.nhgs_id, nhe, hash_alloc_intern); return 0; } diff --git a/zebra/zebra_pw.h b/zebra/zebra_pw.h index 0da8203802..9800c5853a 100644 --- a/zebra/zebra_pw.h +++ b/zebra/zebra_pw.h @@ -38,7 +38,7 @@ extern "C" { struct zebra_pw { RB_ENTRY(zebra_pw) pw_entry, static_pw_entry; vrf_id_t vrf_id; - char ifname[IF_NAMESIZE]; + char ifname[INTERFACE_NAMSIZ]; ifindex_t ifindex; int type; int af; diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index fc7eb8c87a..020ff6f3c0 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -1078,9 +1078,7 @@ static int zevpn_build_hash_table_zns(struct ns *ns, static void zevpn_build_hash_table(void) { - ns_walk_func(zevpn_build_hash_table_zns, - (void *)NULL, - (void **)NULL); + ns_walk_func(zevpn_build_hash_table_zns, NULL, NULL); } /* @@ -1189,8 +1187,6 @@ static struct zebra_mac *zl3vni_rmac_add(struct zebra_l3vni *zl3vni, memset(&tmp_rmac, 0, sizeof(struct zebra_mac)); memcpy(&tmp_rmac.macaddr, rmac, ETH_ALEN); zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc); - assert(zrmac); - zrmac->nh_list = list_new(); zrmac->nh_list->cmp = (int (*)(void *, void *))l3vni_rmac_nh_list_cmp; zrmac->nh_list->del = (void (*)(void *))l3vni_rmac_nh_free; @@ -1466,7 +1462,6 @@ static struct zebra_neigh *zl3vni_nh_add(struct zebra_l3vni *zl3vni, memset(&tmp_n, 0, sizeof(struct zebra_neigh)); memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr)); n = hash_get(zl3vni->nh_table, &tmp_n, zl3vni_nh_alloc); - assert(n); RB_INIT(host_rb_tree_entry, &n->host_rb); @@ -1696,7 +1691,6 @@ static struct zebra_l3vni *zl3vni_add(vni_t vni, vrf_id_t vrf_id) tmp_zl3vni.vni = vni; zl3vni = hash_get(zrouter.l3vni_table, &tmp_zl3vni, zl3vni_alloc); - assert(zl3vni); zl3vni->vrf_id = vrf_id; zl3vni->svi_if = NULL; @@ -6039,11 +6033,6 @@ static struct zebra_vxlan_sg *zebra_vxlan_sg_add(struct zebra_vrf *zvrf, } vxlan_sg = zebra_vxlan_sg_new(zvrf, sg); - if (!vxlan_sg) { - if (parent) - zebra_vxlan_sg_do_deref(zvrf, sip, sg->grp); - return vxlan_sg; - } zebra_vxlan_sg_send(zvrf, sg, vxlan_sg->sg_str, ZEBRA_VXLAN_SG_ADD); |
