bfdd: Use pass by reference instead of pass by value for a struct

The function bfd_key_lookup is currently sending by value for
a now very large structure.  Let's convert this over to pass
by reference.  This is noticed by coverity.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2025-02-05 08:42:00 -05:00
parent 3fabd4f4f9
commit 6d80d0c595
4 changed files with 12 additions and 12 deletions

View file

@ -280,7 +280,7 @@ struct bfd_session *bs_peer_find(struct bfd_peer_cfg *bpc)
gen_bfd_key(&key, &bpc->bpc_peer, &bpc->bpc_local, bpc->bpc_mhop, bpc->bpc_localif,
bpc->bpc_vrfname, bpc->bfd_name);
return bfd_key_lookup(key);
return bfd_key_lookup(&key);
}
/*
@ -770,7 +770,7 @@ struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *cp,
vrf ? vrf->name : VRF_DEFAULT_NAME, NULL);
/* XXX maybe remoteDiscr should be checked for remoteHeard cases. */
return bfd_key_lookup(key);
return bfd_key_lookup(&key);
}
void bfd_xmt_cb(struct event *t)
@ -1962,11 +1962,11 @@ struct bfd_session *bfd_id_lookup(uint32_t id)
return hash_lookup(bfd_id_hash, &bs);
}
struct bfd_session *bfd_key_lookup(struct bfd_key key)
struct bfd_session *bfd_key_lookup(struct bfd_key *key)
{
struct bfd_session bs;
bs.key = key;
bs.key = *key;
return hash_lookup(bfd_key_hash, &bs);
}

View file

@ -698,7 +698,7 @@ void bfd_vrf_init(void);
void bfd_vrf_terminate(void);
struct bfd_vrf_global *bfd_vrf_look_by_session(struct bfd_session *bfd);
struct bfd_session *bfd_id_lookup(uint32_t id);
struct bfd_session *bfd_key_lookup(struct bfd_key key);
struct bfd_session *bfd_key_lookup(struct bfd_key *key);
struct sbfd_reflector *sbfd_discr_lookup(uint32_t discr);
struct bfd_session *bfd_id_delete(uint32_t id);
struct bfd_session *bfd_key_delete(struct bfd_key key);

View file

@ -220,7 +220,7 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop, uint32_
case NB_EV_PREPARE:
if (bfd_mode == BFD_MODE_TYPE_BFD) {
bfd_session_get_key(mhop, args->dnode, &bk);
bs = bfd_key_lookup(bk);
bs = bfd_key_lookup(&bk);
/* This session was already configured by another daemon. */
if (bs != NULL) {
@ -249,7 +249,7 @@ static int bfd_session_create(struct nb_cb_create_args *args, bool mhop, uint32_
} else if (bfd_mode == BFD_MODE_TYPE_SBFD_ECHO ||
bfd_mode == BFD_MODE_TYPE_SBFD_INIT) {
sbfd_session_get_key(mhop, args->dnode, &bk);
bs = bfd_key_lookup(bk);
bs = bfd_key_lookup(&bk);
/* This session was already configured by another daemon. */
if (bs != NULL) {
@ -369,7 +369,7 @@ static int bfd_session_destroy(enum nb_event event, const struct lyd_node *dnode
else
sbfd_session_get_key(mhop, dnode, &bk);
if (bfd_key_lookup(bk) == NULL)
if (bfd_key_lookup(&bk) == NULL)
return NB_ERR_INCONSISTENCY;
break;

View file

@ -52,7 +52,7 @@ bfdd_bfd_sessions_single_hop_lookup_entry(struct nb_cb_lookup_entry_args *args)
memset(&lsa, 0, sizeof(lsa));
gen_bfd_key(&bk, &psa, &lsa, false, ifname, vrf, NULL);
return bfd_key_lookup(bk);
return bfd_key_lookup(&bk);
}
/*
@ -356,7 +356,7 @@ bfdd_bfd_sessions_multi_hop_lookup_entry(struct nb_cb_lookup_entry_args *args)
strtosa(source_addr, &lsa);
gen_bfd_key(&bk, &psa, &lsa, true, NULL, vrf, NULL);
return bfd_key_lookup(bk);
return bfd_key_lookup(&bk);
}
/*
@ -394,7 +394,7 @@ const void *bfdd_bfd_sessions_sbfd_echo_lookup_entry(struct nb_cb_lookup_entry_a
memset(&psa, 0, sizeof(psa));
gen_bfd_key(&bk, &psa, &lsa, true, NULL, vrf, bfdname);
return bfd_key_lookup(bk);
return bfd_key_lookup(&bk);
}
/*
@ -436,5 +436,5 @@ const void *bfdd_bfd_sessions_sbfd_init_lookup_entry(struct nb_cb_lookup_entry_a
strtosa(dest_addr, &psa);
gen_bfd_key(&bk, &psa, &lsa, true, NULL, vrf, bfdname);
return bfd_key_lookup(bk);
return bfd_key_lookup(&bk);
}