diff options
author | Donald Sharp <sharpd@nvidia.com> | 2022-08-15 18:01:02 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2022-08-15 21:45:05 +0200 |
commit | 702198367015d37bc7bbcf60ea6c981ba5ea67fb (patch) | |
tree | dcd60e586dfb33d759cfb15d9e182539ffc872fa /pbrd | |
parent | pathd: Ensure path is free'd after we no longer need it. (diff) | |
download | frr-702198367015d37bc7bbcf60ea6c981ba5ea67fb.tar.xz frr-702198367015d37bc7bbcf60ea6c981ba5ea67fb.zip |
pbrd: VTY_GET_CONTEXT can fail
Although VTY_GET_CONTEXT can return a failed value, it will
never happen in pbrd because of how context work. In
any event add some code to make coverity happy
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'pbrd')
-rw-r--r-- | pbrd/pbr_vty.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index d68bcfa16..a2b3431b9 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -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; |