Merge pull request #10322 from iqras23/coverity

bgpd: Addressing few coverity issues
This commit is contained in:
Igor Ryzhov 2022-02-01 16:27:04 +03:00 committed by GitHub
commit aa6e3cef62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 41 deletions

View file

@ -404,9 +404,8 @@ static bool overlay_index_same(const struct attr *a1, const struct attr *a2)
if (!a1 && !a2)
return true;
return !memcmp(bgp_attr_get_evpn_overlay(a1),
bgp_attr_get_evpn_overlay(a2),
sizeof(struct bgp_route_evpn));
return bgp_route_evpn_same(bgp_attr_get_evpn_overlay(a1),
bgp_attr_get_evpn_overlay(a2));
}
/* Unknown transit attribute. */

View file

@ -36,6 +36,14 @@
#include "bgpd/bgp_evpn.h"
#include "bgpd/bgp_evpn_private.h"
bool bgp_route_evpn_same(const struct bgp_route_evpn *e1,
const struct bgp_route_evpn *e2)
{
return (e1->type == e2->type &&
!memcmp(&(e1->eth_s_id), &(e2->eth_s_id), sizeof(esi_t)) &&
!ipaddr_cmp(&(e1->gw_ip), &(e2->gw_ip)));
}
void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
{
struct ecommunity_val routermac_ecom;

View file

@ -59,4 +59,7 @@ extern void bgp_attr_evpn_na_flag(struct attr *attr, uint8_t *router_flag,
bool *proxy);
extern uint16_t bgp_attr_df_pref_from_ec(struct attr *attr, uint8_t *alg);
extern bool bgp_route_evpn_same(const struct bgp_route_evpn *e1,
const struct bgp_route_evpn *e2);
#endif /* _QUAGGA_BGP_ATTR_EVPN_H */

View file

@ -6146,7 +6146,7 @@ static bool bgp_evpn_remote_ip_hash_cmp(const void *p1, const void *p2)
const struct evpn_remote_ip *ip1 = p1;
const struct evpn_remote_ip *ip2 = p2;
return (memcmp(&ip1->addr, &ip2->addr, sizeof(struct ipaddr)) == 0);
return !ipaddr_cmp(&ip1->addr, &ip2->addr);
}
static void bgp_evpn_remote_ip_hash_init(struct bgpevpn *vpn)

View file

@ -175,7 +175,6 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)
/* not expected */
return BGP_IPV4_NODE;
}
break;
case AFI_IP6:
switch (safi) {
case SAFI_UNICAST:
@ -192,7 +191,6 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)
/* not expected */
return BGP_IPV4_NODE;
}
break;
case AFI_L2VPN:
return BGP_EVPN_NODE;
case AFI_UNSPEC:
@ -13599,49 +13597,58 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p));
json_object_object_add(json_neigh, "messageStats", json_stat);
} else {
atomic_size_t outq_count, inq_count;
atomic_size_t outq_count, inq_count, open_out, open_in,
notify_out, notify_in, update_out, update_in,
keepalive_out, keepalive_in, refresh_out, refresh_in,
dynamic_cap_out, dynamic_cap_in;
outq_count = atomic_load_explicit(&p->obuf->count,
memory_order_relaxed);
inq_count = atomic_load_explicit(&p->ibuf->count,
memory_order_relaxed);
open_out = atomic_load_explicit(&p->open_out,
memory_order_relaxed);
open_in =
atomic_load_explicit(&p->open_in, memory_order_relaxed);
notify_out = atomic_load_explicit(&p->notify_out,
memory_order_relaxed);
notify_in = atomic_load_explicit(&p->notify_in,
memory_order_relaxed);
update_out = atomic_load_explicit(&p->update_out,
memory_order_relaxed);
update_in = atomic_load_explicit(&p->update_in,
memory_order_relaxed);
keepalive_out = atomic_load_explicit(&p->keepalive_out,
memory_order_relaxed);
keepalive_in = atomic_load_explicit(&p->keepalive_in,
memory_order_relaxed);
refresh_out = atomic_load_explicit(&p->refresh_out,
memory_order_relaxed);
refresh_in = atomic_load_explicit(&p->refresh_in,
memory_order_relaxed);
dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out,
memory_order_relaxed);
dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in,
memory_order_relaxed);
/* Packet counts. */
vty_out(vty, " Message statistics:\n");
vty_out(vty, " Inq depth is %zu\n", inq_count);
vty_out(vty, " Outq depth is %zu\n", outq_count);
vty_out(vty, " Sent Rcvd\n");
vty_out(vty, " Opens: %10d %10d\n",
atomic_load_explicit(&p->open_out,
memory_order_relaxed),
atomic_load_explicit(&p->open_in,
memory_order_relaxed));
vty_out(vty, " Notifications: %10d %10d\n",
atomic_load_explicit(&p->notify_out,
memory_order_relaxed),
atomic_load_explicit(&p->notify_in,
memory_order_relaxed));
vty_out(vty, " Updates: %10d %10d\n",
atomic_load_explicit(&p->update_out,
memory_order_relaxed),
atomic_load_explicit(&p->update_in,
memory_order_relaxed));
vty_out(vty, " Keepalives: %10d %10d\n",
atomic_load_explicit(&p->keepalive_out,
memory_order_relaxed),
atomic_load_explicit(&p->keepalive_in,
memory_order_relaxed));
vty_out(vty, " Route Refresh: %10d %10d\n",
atomic_load_explicit(&p->refresh_out,
memory_order_relaxed),
atomic_load_explicit(&p->refresh_in,
memory_order_relaxed));
vty_out(vty, " Capability: %10d %10d\n",
atomic_load_explicit(&p->dynamic_cap_out,
memory_order_relaxed),
atomic_load_explicit(&p->dynamic_cap_in,
memory_order_relaxed));
vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p),
PEER_TOTAL_RX(p));
vty_out(vty, " Opens: %10zu %10zu\n", open_out,
open_in);
vty_out(vty, " Notifications: %10zu %10zu\n", notify_out,
notify_in);
vty_out(vty, " Updates: %10zu %10zu\n", update_out,
update_in);
vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out,
keepalive_in);
vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out,
refresh_in);
vty_out(vty, " Capability: %10zu %10zu\n",
dynamic_cap_out, dynamic_cap_in);
vty_out(vty, " Total: %10u %10u\n",
(uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p));
}
if (use_json) {

View file

@ -2843,8 +2843,8 @@ static int bgp_zebra_process_local_es_evi(ZAPI_CALLBACK_ARGS)
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx %s ESI %s VNI %u",
ZEBRA_VNI_ADD ? "add" : "del",
esi_to_str(&esi, buf, sizeof(buf)), vni);
(cmd == ZEBRA_VNI_ADD) ? "add" : "del",
esi_to_str(&esi, buf, sizeof(buf)), vni);
if (cmd == ZEBRA_LOCAL_ES_EVI_ADD) {
frrtrace(2, frr_bgp, evpn_mh_local_es_evi_add_zrecv, &esi, vni);