From 1f7038386e34fac1731014535bfea6a0b3892abc Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 May 2023 19:30:12 -0400 Subject: [PATCH 1/6] bgpd: community_list_set str is always non null When calling community_list_set the str variable is always non NULL. As such let's treat it as such. Signed-off-by: Donald Sharp --- bgpd/bgp_clist.c | 14 ++++++-------- bgpd/bgp_vty.c | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 1d2ba3bf58..ac5cdd6acb 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -899,15 +899,13 @@ int community_list_set(struct community_list_handler *ch, const char *name, } } - if (str) { - if (style == COMMUNITY_LIST_STANDARD) - com = community_str2com(str); - else - regex = bgp_regcomp(str); + if (style == COMMUNITY_LIST_STANDARD) + com = community_str2com(str); + else + regex = bgp_regcomp(str); - if (!com && !regex) - return COMMUNITY_LIST_ERR_MALFORMED_VAL; - } + if (!com && !regex) + return COMMUNITY_LIST_ERR_MALFORMED_VAL; entry = community_entry_new(); entry->direct = direct; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 7ef9db9f0d..89a5333a2c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -20663,6 +20663,7 @@ DEFUN (community_list_standard, argv_find(argv, argc, "AA:NN", &idx); char *str = argv_concat(argv, argc, idx); + assert(str); int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, direct, style); @@ -20775,6 +20776,7 @@ DEFUN (community_list_expanded_all, argv_find(argv, argc, "AA:NN", &idx); char *str = argv_concat(argv, argc, idx); + assert(str); int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, direct, style); From c2cf5223477114b428077a07eb370e52b59da2e5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 May 2023 19:40:22 -0400 Subject: [PATCH 2/6] zebra: No need to set msg to NULL The msg value is always reset to something new before it is used inside the mutex. No need to set it to NULL. Signed-off-by: Donald Sharp --- zebra/zserv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/zebra/zserv.c b/zebra/zserv.c index 6abd49310c..d2367007cf 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -507,8 +507,6 @@ static void zserv_process_messages(struct event *thread) stream_fifo_push(cache, msg); } - msg = NULL; - /* Need to reschedule processing work if there are still * packets in the fifo. */ From 3ddf7680fd64134b32f1304d6cf33b9971b8a1e5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 May 2023 19:43:24 -0400 Subject: [PATCH 3/6] zebra: Consolidate the stream_failure section with normal return Signed-off-by: Donald Sharp --- zebra/zebra_mlag.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c index 6713dbc967..7715eab0a8 100644 --- a/zebra/zebra_mlag.c +++ b/zebra/zebra_mlag.c @@ -338,8 +338,6 @@ static void zebra_mlag_post_data_from_main_thread(struct event *thread) } } - stream_free(s); - return; stream_failure: stream_free(s); if (zebra_s) From 6e233c77d878efefff39990b4ddd9c6a52d57f3f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 May 2023 19:44:36 -0400 Subject: [PATCH 4/6] bgpd: blnc cannot be NULL at if statement time It is impossible for the blnc statement to ever be NULL at line 1470 as that the if statement at 1453 guarantees it to be set to something. Signed-off-by: Donald Sharp --- bgpd/bgp_mplsvpn.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index ecc84533b0..dc9bd3cff5 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1467,13 +1467,12 @@ static mpls_label_t _vpn_leak_from_vrf_get_per_nexthop_label( /* Unlink from any existing nexthop cache. Free the entry if unused. */ bgp_mplsvpn_path_nh_label_unlink(pi); - if (blnc) { - /* updates NHT pi list reference */ - LIST_INSERT_HEAD(&(blnc->paths), pi, label_nh_thread); - pi->label_nexthop_cache = blnc; - pi->label_nexthop_cache->path_count++; - blnc->last_update = monotime(NULL); - } + + /* updates NHT pi list reference */ + LIST_INSERT_HEAD(&(blnc->paths), pi, label_nh_thread); + pi->label_nexthop_cache = blnc; + pi->label_nexthop_cache->path_count++; + blnc->last_update = monotime(NULL); /* then add or update the selected nexthop */ if (!blnc->nh) From c36bd47d767d1e45a8bc3af99bd5f8832c6e6a57 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 May 2023 19:47:32 -0400 Subject: [PATCH 5/6] bgpd: vpn_policy_getafi can return AFI_MAX Let's account for vpn_policy_getafi having a failure situation and back out of the whole thing gracefully. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 89a5333a2c..04bdba1345 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9199,6 +9199,8 @@ DEFPY(af_label_vpn_export_allocation_mode, bool old_per_nexthop, new_per_nexthop; afi = vpn_policy_getafi(vty, bgp, false); + if (afi == AFI_MAX) + return CMD_WARNING_CONFIG_FAILED; old_per_nexthop = !!CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_LABEL_PER_NEXTHOP); From 56cc0c247838f6058c5b6aba513c31dca63dc7c7 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 May 2023 19:48:55 -0400 Subject: [PATCH 6/6] eigrpd: dest_addr does not need to be set to NULL All paths of the loop set dest_addr at the start of the loop. No need to set it to NULL to immediately set it too something else. Signed-off-by: Donald Sharp --- eigrpd/eigrp_update.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c index 2237a611e8..a056267bf7 100644 --- a/eigrpd/eigrp_update.c +++ b/eigrpd/eigrp_update.c @@ -842,9 +842,6 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) eigrp_fsm_event(&fsm_msg); } - /* NULL the pointer */ - dest_addr = NULL; - /* delete processed prefix from list */ listnode_delete(prefixes, pe);