Merge pull request #11804 from donaldsharp/aug_coverity_update

Aug coverity update
This commit is contained in:
Russ White 2022-08-15 18:10:03 -04:00 committed by GitHub
commit 261e70c66a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 47 deletions

View File

@ -4036,6 +4036,9 @@ DEFUN (no_bgp_evpn_advertise_type5,
afi_t afi = 0;
safi_t safi = 0;
if (!bgp_vrf)
return CMD_WARNING;
argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
argv_find_and_parse_safi(argv, argc, &idx_safi, &safi);

View File

@ -1791,9 +1791,10 @@ struct ls_edge *ls_msg2edge(struct ls_ted *ted, struct ls_message *msg,
case LS_MSG_EVENT_DELETE:
edge = ls_find_edge_by_source(ted, attr);
if (edge) {
if (delete)
if (delete) {
ls_edge_del_all(ted, edge);
else
edge = NULL;
} else
edge->status = DELETE;
}
break;

View File

@ -17,6 +17,7 @@
#include "memory.h"
#include "thread.h"
#include "hash.h"
#include "network.h"
#include "nhrpd.h"
#include "nhrp_protocol.h"
@ -334,7 +335,7 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)
&p->t_fallback);
} else {
/* Maximum timeout is 1 second */
int r_time_ms = rand() % 1000;
int r_time_ms = frr_weak_random() % 1000;
debugf(NHRP_DEBUG_COMMON,
"Initiating IPsec connection request to %pSU after %d ms:",

View File

@ -1326,9 +1326,9 @@ void handle_pcep_lsp_initiate(struct ctrl_state *ctrl_state,
* possibly disconnect and blacklist */
flog_warn(EC_PATH_PCEP_UNSUPPORTED_PCEP_FEATURE,
"Unsupported PCEP protocol feature: %s", err);
pcep_free_path(path);
send_pcep_error(pcc_state, PCEP_ERRT_INVALID_OPERATION,
PCEP_ERRV_LSP_NOT_PCE_INITIATED, path);
pcep_free_path(path);
}
}

View File

@ -137,6 +137,9 @@ DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (pbrms->dst && pbrms->family && prefix->family != pbrms->family) {
vty_out(vty, "Cannot mismatch families within match src/dst\n");
return CMD_WARNING_CONFIG_FAILED;
@ -170,6 +173,9 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (pbrms->src && pbrms->family && prefix->family != pbrms->family) {
vty_out(vty, "Cannot mismatch families within match src/dst\n");
return CMD_WARNING_CONFIG_FAILED;
@ -204,6 +210,9 @@ DEFPY(pbr_map_match_ip_proto, pbr_map_match_ip_proto_cmd,
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
struct protoent *p;
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no) {
p = getprotobyname(ip_proto);
if (!p) {
@ -228,6 +237,9 @@ DEFPY(pbr_map_match_src_port, pbr_map_match_src_port_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no) {
if (pbrms->src_prt == port)
return CMD_SUCCESS;
@ -250,6 +262,9 @@ DEFPY(pbr_map_match_dst_port, pbr_map_match_dst_port_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no) {
if (pbrms->dst_prt == port)
return CMD_SUCCESS;
@ -274,6 +289,9 @@ DEFPY(pbr_map_match_dscp, pbr_map_match_dscp_cmd,
char dscpname[100];
uint8_t rawDscp;
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
/* Discriminate dscp enums (cs0, cs1 etc.) and numbers */
bool isANumber = true;
for (int i = 0; i < (int)strlen(dscp); i++) {
@ -333,6 +351,9 @@ DEFPY(pbr_map_match_ecn, pbr_map_match_ecn_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no) {
if ((pbrms->dsfield & PBR_DSFIELD_ECN) == ecn)
return CMD_SUCCESS;
@ -357,6 +378,9 @@ DEFPY(pbr_map_match_mark, pbr_map_match_mark_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
#ifndef GNU_LINUX
vty_out(vty, "pbr marks are not supported on this platform\n");
return CMD_WARNING_CONFIG_FAILED;
@ -417,6 +441,9 @@ DEFPY(pbr_map_action_queue_id, pbr_map_action_queue_id_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no)
pbrms->action_queue_id = queue_id;
else if ((uint32_t)queue_id == pbrms->action_queue_id)
@ -435,6 +462,9 @@ DEFPY(pbr_map_action_pcp, pbr_map_action_pcp_cmd, "[no] set pcp <(0-7)$pcp>",
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no)
pbrms->action_pcp = pcp;
else if (pcp == pbrms->action_pcp)
@ -454,6 +484,9 @@ DEFPY(pbr_map_action_vlan_id, pbr_map_action_vlan_id_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no)
pbrms->action_vlan_id = vlan_id;
else if (pbrms->action_vlan_id == vlan_id)
@ -472,6 +505,9 @@ DEFPY(pbr_map_action_strip_vlan, pbr_map_action_strip_vlan_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (!no)
pbrms->action_vlan_flags = PBR_MAP_STRIP_INNER_ANY;
else
@ -492,6 +528,9 @@ DEFPY(pbr_map_nexthop_group, pbr_map_nexthop_group_cmd,
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
struct nexthop_group_cmd *nhgc;
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
nhgc = nhgc_find(name);
if (!nhgc) {
vty_out(vty, "Specified nexthop-group %s does not exist\n",
@ -522,6 +561,9 @@ DEFPY(no_pbr_map_nexthop_group, no_pbr_map_nexthop_group_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
pbrms_clear_set_config(pbrms);
return CMD_SUCCESS;
@ -548,6 +590,9 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
struct nexthop nhop;
struct nexthop *nh = NULL;
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
if (vrf_name)
vrf = vrf_lookup_by_name(vrf_name);
else
@ -670,6 +715,9 @@ DEFPY(no_pbr_map_nexthop, no_pbr_map_nexthop_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
pbrms_clear_set_config(pbrms);
return CMD_SUCCESS;
@ -684,6 +732,9 @@ DEFPY(pbr_map_vrf, pbr_map_vrf_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
/*
* If an equivalent set vrf * exists, just return success.
*/
@ -722,6 +773,9 @@ DEFPY(no_pbr_map_vrf, no_pbr_map_vrf_cmd,
{
struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
if (!pbrms)
return CMD_WARNING_CONFIG_FAILED;
pbrms_clear_set_config(pbrms);
return CMD_SUCCESS;

View File

@ -5526,12 +5526,13 @@ DEFUN (show_ip_msdp_mesh_group,
int idx = 2;
struct pim_msdp_mg *mg;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
struct pim_instance *pim = vrf->info;
struct pim_instance *pim;
struct json_object *json = NULL;
if (!vrf)
return CMD_WARNING;
pim = vrf->info;
/* Quick case: list is empty. */
if (SLIST_EMPTY(&pim->msdp.mglist)) {
if (uj)

View File

@ -539,10 +539,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, pim_sgaddr *sg,
if (up_flags == PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
PIM_IF_FLAG_SET_PROTO_IGMP(ch->flags);
if (ch->upstream)
ch->upstream->flags |= up_flags;
else if (PIM_DEBUG_EVENTS)
zlog_debug("%s:%pSG No Upstream found", __func__, sg);
ch->upstream->flags |= up_flags;
return ch;
}
@ -637,8 +634,7 @@ static void ifjoin_to_noinfo(struct pim_ifchannel *ch)
pim_ifchannel_ifjoin_switch(__func__, ch, PIM_IFJOIN_NOINFO);
pim_forward_stop(ch);
if (ch->upstream)
PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(ch->upstream->flags);
PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(ch->upstream->flags);
PIM_IF_FLAG_UNSET_PROTO_PIM(ch->flags);
@ -696,31 +692,29 @@ static void on_ifjoin_prune_pending_timer(struct thread *t)
* message on RP path upon prune timer expiry.
*/
ch->ifjoin_state = PIM_IFJOIN_PRUNE;
if (ch->upstream) {
struct pim_upstream *parent =
ch->upstream->parent;
struct pim_upstream *parent =
ch->upstream->parent;
pim_upstream_update_join_desired(pim_ifp->pim,
ch->upstream);
pim_upstream_update_join_desired(pim_ifp->pim,
ch->upstream);
pim_jp_agg_single_upstream_send(&parent->rpf,
parent, true);
/*
* SGRpt prune pending expiry has to install
* SG entry with empty olist to drop the SG
* traffic incase no other intf exists.
* On that scenario, SG entry wouldn't have
* got installed until Prune pending timer
* expired. So install now.
*/
pim_channel_del_oif(
ch->upstream->channel_oil, ifp,
PIM_OIF_FLAG_PROTO_STAR, __func__);
if (!ch->upstream->channel_oil->installed)
pim_upstream_mroute_add(
ch->upstream->channel_oil,
__func__);
}
pim_jp_agg_single_upstream_send(&parent->rpf,
parent, true);
/*
* SGRpt prune pending expiry has to install
* SG entry with empty olist to drop the SG
* traffic incase no other intf exists.
* On that scenario, SG entry wouldn't have
* got installed until Prune pending timer
* expired. So install now.
*/
pim_channel_del_oif(
ch->upstream->channel_oil, ifp,
PIM_OIF_FLAG_PROTO_STAR, __func__);
if (!ch->upstream->channel_oil->installed)
pim_upstream_mroute_add(
ch->upstream->channel_oil,
__func__);
}
/* from here ch may have been deleted */
}

View File

@ -1061,15 +1061,13 @@ struct pim_upstream *pim_upstream_add(struct pim_instance *pim, pim_sgaddr *sg,
}
if (PIM_DEBUG_PIM_TRACE) {
if (up)
zlog_debug("%s(%s): %s, iif %pPA (%s) found: %d: ref_count: %d",
__func__, name,
up->sg_str, &up->rpf.rpf_addr, up->rpf.source_nexthop.interface ?
up->rpf.source_nexthop.interface->name : "Unknown" ,
found, up->ref_count);
else
zlog_debug("%s(%s): (%pSG) failure to create", __func__,
name, sg);
zlog_debug(
"%s(%s): %s, iif %pPA (%s) found: %d: ref_count: %d",
__func__, name, up->sg_str, &up->rpf.rpf_addr,
up->rpf.source_nexthop.interface ? up->rpf.source_nexthop
.interface->name
: "Unknown",
found, up->ref_count);
}
return up;

View File

@ -1429,7 +1429,7 @@ int main(int argc, char **argv)
if ((sscanf(optarg, "%ld%1s", &gs.operational_timeout,
garbage) != 1) ||
(gs.max_restart_interval < 0)) {
(gs.operational_timeout < 0)) {
fprintf(stderr,
"Invalid Operational_timeout argument: %s\n",
optarg);

View File

@ -3422,7 +3422,7 @@ static enum zebra_dplane_result
dplane_nexthop_update_internal(struct nhg_hash_entry *nhe, enum dplane_op_e op)
{
enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
int ret = EINVAL;
int ret;
struct zebra_dplane_ctx *ctx = NULL;
/* Obtain context block */
@ -3700,7 +3700,7 @@ dplane_lsp_notif_update(struct zebra_lsp *lsp, enum dplane_op_e op,
struct zebra_dplane_ctx *notif_ctx)
{
enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
int ret = EINVAL;
int ret;
struct zebra_dplane_ctx *ctx = NULL;
struct nhlfe_list_head *head;
struct zebra_nhlfe *nhlfe, *new_nhlfe;
@ -4075,7 +4075,7 @@ static enum zebra_dplane_result
dplane_intf_update_internal(const struct interface *ifp, enum dplane_op_e op)
{
enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
int ret = EINVAL;
int ret;
struct zebra_dplane_ctx *ctx = NULL;
/* Obtain context block */