]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Add missing enum's to case statement
authorDonald Sharp <sharpd@nvidia.com>
Mon, 30 Jan 2023 15:05:41 +0000 (10:05 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 31 Jan 2023 17:29:08 +0000 (12:29 -0500)
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
13 files changed:
bgpd/bgp_addpath.c
bgpd/bgp_evpn.c
bgpd/bgp_flowspec_util.c
bgpd/bgp_fsm.c
bgpd/bgp_mplsvpn_snmp.c
bgpd/bgp_open.c
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgpd.h
bgpd/rfapi/rfapi_encap_tlv.c
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/rfapi_monitor.c
bgpd/rfapi/rfapi_vty.c

index 461e60dbfcf3147bb96200a060e7410404c7ebac..748fcc92b4b7c9f1c7fb9f6907672080283e5f1d 100644 (file)
@@ -174,9 +174,11 @@ bool bgp_addpath_tx_path(enum bgp_addpath_strat strat, struct bgp_path_info *pi)
                        return true;
                else
                        return false;
-       default:
+       case BGP_ADDPATH_MAX:
                return false;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 static void bgp_addpath_flush_type_rn(struct bgp *bgp, afi_t afi, safi_t safi,
index c993707206847cdb687830006d21c157e925f8c4..d8acbcd19a302ddb99d1ef7851cfe9457125f998 100644 (file)
@@ -1228,7 +1228,7 @@ static int evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn,
 {
        int ret;
        uint8_t flags;
-       int flood_control;
+       int flood_control = VXLAN_FLOOD_DISABLED;
        uint32_t seq;
 
        if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) {
@@ -1298,7 +1298,12 @@ static int evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn,
                        flood_control = VXLAN_FLOOD_PIM_SM;
                        break;
 
-               default:
+               case PMSI_TNLTYPE_NO_INFO:
+               case PMSI_TNLTYPE_RSVP_TE_P2MP:
+               case PMSI_TNLTYPE_MLDP_P2MP:
+               case PMSI_TNLTYPE_PIM_SSM:
+               case PMSI_TNLTYPE_PIM_BIDIR:
+               case PMSI_TNLTYPE_MLDP_MP2MP:
                        flood_control = VXLAN_FLOOD_DISABLED;
                        break;
                }
index 9f3ea499ff2018b96fb034e256e699fe87f1a1ee..191b9f16fd5fdfd7d21d7c3c77114cdee804eeef 100644 (file)
@@ -231,7 +231,7 @@ int bgp_flowspec_ip_address(enum bgp_flowspec_util_nlri_t type,
                        prefix_copy(prefix, &prefix_local);
                break;
        case BGP_FLOWSPEC_VALIDATE_ONLY:
-       default:
+       case BGP_FLOWSPEC_RETURN_JSON:
                break;
        }
        return offset;
@@ -326,7 +326,7 @@ int bgp_flowspec_op_decode(enum bgp_flowspec_util_nlri_t type,
                        mval++;
                        break;
                case BGP_FLOWSPEC_VALIDATE_ONLY:
-               default:
+               case BGP_FLOWSPEC_RETURN_JSON:
                        /* no action */
                        break;
                }
@@ -436,7 +436,7 @@ int bgp_flowspec_bitmask_decode(enum bgp_flowspec_util_nlri_t type,
                        mval++;
                        break;
                case BGP_FLOWSPEC_VALIDATE_ONLY:
-               default:
+               case BGP_FLOWSPEC_RETURN_JSON:
                        /* no action */
                        break;
                }
index 9624adfbe25a8aa6fb0c8bb03bd42edfd4ffbdaf..faf3a4994dd914814aace12e87465c874d89784b 100644 (file)
@@ -2397,7 +2397,7 @@ void bgp_fsm_nht_update(struct peer *peer, bool has_valid_nexthops)
                        BGP_EVENT_ADD(peer, TCP_fatal_error);
        case Clearing:
        case Deleted:
-       default:
+       case BGP_STATUS_MAX:
                break;
        }
 }
index 8d5daa49c81f19a1153618821acff45fd8c162f2..ea147e55b97107f26b4a246957e2d75143cd47e8 100644 (file)
@@ -1264,7 +1264,7 @@ bgp_lookup_route(struct bgp *l3vpn_bgp, struct bgp_dest **dest,
                            == 0)
                                return pi;
                        break;
-               default:
+               case IPADDR_NONE:
                        return pi;
                }
        }
@@ -1627,13 +1627,13 @@ static uint8_t *mplsL3vpnRteTable(struct variable *v, oid name[],
                                case BLACKHOLE_REJECT:
                                        return SNMP_INTEGER(
                                                MPLSL3VPNVRFRTECIDRTYPEREJECT);
-                               default:
+                               case BLACKHOLE_UNSPEC:
+                               case BLACKHOLE_NULL:
+                               case BLACKHOLE_ADMINPROHIB:
                                        return SNMP_INTEGER(
                                                MPLSL3VPNVRFRTECIDRTYPEBLACKHOLE);
                                }
-                       default:
-                               return SNMP_INTEGER(
-                                       MPLSL3VPNVRFRTECIDRTYPEOTHER);
+                               break;
                        }
                } else
                        return SNMP_INTEGER(MPLSL3VPNVRFRTECIDRTYPEOTHER);
index 659e93bdfab9fb7c8f6d316a8ba9cf9706d72c33..3e361fccfd1c36e1f2be219b0e1e2fc71778506f 100644 (file)
@@ -167,7 +167,8 @@ void bgp_capability_vty_out(struct vty *vty, struct peer *peer, bool use_json,
                                                "capabilityErrorMultiProtocolAfi",
                                                "L2VPN");
                                        break;
-                               default:
+                               case AFI_UNSPEC:
+                               case AFI_MAX:
                                        json_object_int_add(
                                                json_cap,
                                                "capabilityErrorMultiProtocolAfiUnknown",
@@ -217,7 +218,8 @@ void bgp_capability_vty_out(struct vty *vty, struct peer *peer, bool use_json,
                                                "capabilityErrorMultiProtocolSafi",
                                                "flowspec");
                                        break;
-                               default:
+                               case SAFI_UNSPEC:
+                               case SAFI_MAX:
                                        json_object_int_add(
                                                json_cap,
                                                "capabilityErrorMultiProtocolSafiUnknown",
@@ -237,7 +239,8 @@ void bgp_capability_vty_out(struct vty *vty, struct peer *peer, bool use_json,
                                case AFI_L2VPN:
                                        vty_out(vty, "AFI L2VPN, ");
                                        break;
-                               default:
+                               case AFI_UNSPEC:
+                               case AFI_MAX:
                                        vty_out(vty, "AFI Unknown %d, ",
                                                ntohs(mpc.afi));
                                        break;
@@ -264,7 +267,8 @@ void bgp_capability_vty_out(struct vty *vty, struct peer *peer, bool use_json,
                                case SAFI_EVPN:
                                        vty_out(vty, "SAFI EVPN");
                                        break;
-                               default:
+                               case SAFI_UNSPEC:
+                               case SAFI_MAX:
                                        vty_out(vty, "SAFI Unknown %d ",
                                                mpc.safi);
                                        break;
index c9cfc44da0bea544497040247656a533634a3718..1016e8d7358240157f92c63ffd561257e1671b9a 100644 (file)
@@ -12056,9 +12056,16 @@ const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest,
        case SAFI_ENCAP:
        case SAFI_EVPN:
                return (struct prefix_rd *)(bgp_dest_get_prefix(dest));
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_UNICAST:
+       case SAFI_MULTICAST:
+       case SAFI_LABELED_UNICAST:
+       case SAFI_FLOWSPEC:
+       case SAFI_MAX:
                return NULL;
        }
+
+       assert(!"Reached end of function when we were not expecting it");
 }
 
 /* Display specified route of BGP table. */
@@ -13283,7 +13290,8 @@ static void bgp_table_stats_walker(struct thread *t)
        case AFI_L2VPN:
                space = EVPN_ROUTE_PREFIXLEN;
                break;
-       default:
+       case AFI_UNSPEC:
+       case AFI_MAX:
                return;
        }
 
@@ -13538,7 +13546,8 @@ static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi,
        case AFI_L2VPN:
                bitlen = EVPN_ROUTE_PREFIXLEN;
                break;
-       default:
+       case AFI_UNSPEC:
+       case AFI_MAX:
                break;
        }
 
index d837601f3264dbabc80838a25de0853230cf7837..daa435bb2d5c8281ebc3345fafbaf08681456b40 100644 (file)
@@ -178,10 +178,14 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)
                        return BGP_VPNV4_NODE;
                case SAFI_FLOWSPEC:
                        return BGP_FLOWSPECV4_NODE;
-               default:
+               case SAFI_UNSPEC:
+               case SAFI_ENCAP:
+               case SAFI_EVPN:
+               case SAFI_MAX:
                        /* not expected */
                        return BGP_IPV4_NODE;
                }
+               break;
        case AFI_IP6:
                switch (safi) {
                case SAFI_UNICAST:
@@ -194,10 +198,14 @@ static enum node_type bgp_node_type(afi_t afi, safi_t safi)
                        return BGP_VPNV6_NODE;
                case SAFI_FLOWSPEC:
                        return BGP_FLOWSPECV6_NODE;
-               default:
-                       /* not expected */
+               case SAFI_UNSPEC:
+               case SAFI_ENCAP:
+               case SAFI_EVPN:
+               case SAFI_MAX:
+                       /* not expected and the return value seems wrong */
                        return BGP_IPV4_NODE;
                }
+               break;
        case AFI_L2VPN:
                return BGP_EVPN_NODE;
        case AFI_UNSPEC:
@@ -535,7 +543,9 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)
                        return "ipv4-labeled-unicast";
                case SAFI_FLOWSPEC:
                        return "ipv4-flowspec";
-               default:
+               case SAFI_UNSPEC:
+               case SAFI_EVPN:
+               case SAFI_MAX:
                        return "unknown-afi/safi";
                }
                break;
@@ -553,7 +563,9 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)
                        return "ipv6-labeled-unicast";
                case SAFI_FLOWSPEC:
                        return "ipv6-flowspec";
-               default:
+               case SAFI_UNSPEC:
+               case SAFI_EVPN:
+               case SAFI_MAX:
                        return "unknown-afi/safi";
                }
                break;
@@ -561,15 +573,24 @@ static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi)
                switch (safi) {
                case SAFI_EVPN:
                        return "l2vpn-evpn";
-               default:
+               case SAFI_UNICAST:
+               case SAFI_MULTICAST:
+               case SAFI_MPLS_VPN:
+               case SAFI_ENCAP:
+               case SAFI_LABELED_UNICAST:
+               case SAFI_FLOWSPEC:
+               case SAFI_UNSPEC:
+               case SAFI_MAX:
                        return "unknown-afi/safi";
                }
+               break;
        case AFI_UNSPEC:
        case AFI_MAX:
                return "unknown-afi/safi";
        }
        /* all AFIs are accounted for above, so this shouldn't happen */
-       return "unknown-afi/safi";
+
+       assert(!"Reached end of function where we did not expect to");
 }
 
 int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,
index 4c4c81f997a0e18a68f517499c7d70365bbcc78e..61119ab6e0b96370836ec386cff57630f968873c 100644 (file)
@@ -2421,7 +2421,9 @@ static inline int afindex(afi_t afi, safi_t safi)
                        return BGP_AF_IPV4_ENCAP;
                case SAFI_FLOWSPEC:
                        return BGP_AF_IPV4_FLOWSPEC;
-               default:
+               case SAFI_EVPN:
+               case SAFI_UNSPEC:
+               case SAFI_MAX:
                        return BGP_AF_MAX;
                }
                break;
@@ -2439,7 +2441,9 @@ static inline int afindex(afi_t afi, safi_t safi)
                        return BGP_AF_IPV6_ENCAP;
                case SAFI_FLOWSPEC:
                        return BGP_AF_IPV6_FLOWSPEC;
-               default:
+               case SAFI_EVPN:
+               case SAFI_UNSPEC:
+               case SAFI_MAX:
                        return BGP_AF_MAX;
                }
                break;
@@ -2447,12 +2451,23 @@ static inline int afindex(afi_t afi, safi_t safi)
                switch (safi) {
                case SAFI_EVPN:
                        return BGP_AF_L2VPN_EVPN;
-               default:
+               case SAFI_UNICAST:
+               case SAFI_MULTICAST:
+               case SAFI_LABELED_UNICAST:
+               case SAFI_MPLS_VPN:
+               case SAFI_ENCAP:
+               case SAFI_FLOWSPEC:
+               case SAFI_UNSPEC:
+               case SAFI_MAX:
                        return BGP_AF_MAX;
                }
-       default:
+               break;
+       case AFI_UNSPEC:
+       case AFI_MAX:
                return BGP_AF_MAX;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 /* If the peer is not a peer-group but is bound to a peer-group return 1 */
index d4e875df2ad601b6b1ee4b7407add38a0454201e..dc0c382dc157256005f94b42d0d11ea1a853397e 100644 (file)
@@ -150,8 +150,8 @@ rfapi_tunneltype_option_to_tlv(struct bgp *bgp, struct rfapi_ip_addr *ea,
                bgp_encap_type_pbb_to_tlv(&tto->bgpinfo.pbb, attr);
                break;
 
-       default:
-               assert(0);
+       case BGP_ENCAP_TYPE_RESERVED:
+               assert(!"Cannot process BGP_ENCAP_TYPE_RESERVED");
        }
        return tto->type;
 }
@@ -737,7 +737,7 @@ void rfapi_print_tunneltype_option(void *stream, int column_offset,
                print_encap_type_pbb(stream, column_offset, &tto->bgpinfo.pbb);
                break;
 
-       default:
-               assert(0);
+       case BGP_ENCAP_TYPE_RESERVED:
+               assert(!"Cannot process BGP_ENCAP_TYPE_RESERVED");
        }
 }
index 2aae0bc6167260596e3a08961fb3f40d9addbc4d..5db40be362a9154653cba8c0a28c6c0ffd082183 100644 (file)
@@ -260,8 +260,14 @@ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset)
                        }
                        break;
 
-               default:
-                       assert(0);
+               case SAFI_UNSPEC:
+               case SAFI_UNICAST:
+               case SAFI_MULTICAST:
+               case SAFI_EVPN:
+               case SAFI_LABELED_UNICAST:
+               case SAFI_FLOWSPEC:
+               case SAFI_MAX:
+                       assert(!"Passed in safi should be impossible");
                }
        }
 
@@ -2967,7 +2973,9 @@ static void rfapiBgpInfoFilteredImportEncap(
                rt = import_table->imported_encap[afi];
                break;
 
-       default:
+       case AFI_UNSPEC:
+       case AFI_L2VPN:
+       case AFI_MAX:
                flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", __func__, afi);
                return;
        }
@@ -3416,7 +3424,8 @@ void rfapiBgpInfoFilteredImportVPN(
                rt = import_table->imported_vpn[afi];
                break;
 
-       default:
+       case AFI_UNSPEC:
+       case AFI_MAX:
                flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", __func__, afi);
                return;
        }
@@ -3808,11 +3817,19 @@ rfapiBgpInfoFilteredImportFunction(safi_t safi)
        case SAFI_ENCAP:
                return rfapiBgpInfoFilteredImportEncap;
 
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_UNICAST:
+       case SAFI_MULTICAST:
+       case SAFI_EVPN:
+       case SAFI_LABELED_UNICAST:
+       case SAFI_FLOWSPEC:
+       case SAFI_MAX:
                /* not expected */
                flog_err(EC_LIB_DEVELOPMENT, "%s: bad safi %d", __func__, safi);
                return rfapiBgpInfoFilteredImportBadSafi;
        }
+
+       assert(!"Reached end of function when we were not expecting to");
 }
 
 void rfapiProcessUpdate(struct peer *peer,
@@ -4028,8 +4045,8 @@ static void rfapiProcessPeerDownRt(struct peer *peer,
 {
        struct agg_node *rn;
        struct bgp_path_info *bpi;
-       struct agg_table *rt;
-       void (*timer_service_func)(struct thread *);
+       struct agg_table *rt = NULL;
+       void (*timer_service_func)(struct thread *) = NULL;
 
        assert(afi == AFI_IP || afi == AFI_IP6);
 
@@ -4044,14 +4061,19 @@ static void rfapiProcessPeerDownRt(struct peer *peer,
                rt = import_table->imported_encap[afi];
                timer_service_func = rfapiWithdrawTimerEncap;
                break;
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_UNICAST:
+       case SAFI_MULTICAST:
+       case SAFI_EVPN:
+       case SAFI_LABELED_UNICAST:
+       case SAFI_FLOWSPEC:
+       case SAFI_MAX:
                /* Suppress uninitialized variable warning */
                rt = NULL;
                timer_service_func = NULL;
                assert(0);
        }
 
-
        for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
                for (bpi = rn->info; bpi; bpi = bpi->next) {
                        if (bpi->peer == peer) {
index 0e71d5d7e196e0ed7aea994aceee2e5fcce31896..f333e8cc5502a3ec20c49bd299ae89e6b0df8f77 100644 (file)
@@ -244,7 +244,13 @@ void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn)
                }
                break;
 
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_UNICAST:
+       case SAFI_MULTICAST:
+       case SAFI_EVPN:
+       case SAFI_LABELED_UNICAST:
+       case SAFI_FLOWSPEC:
+       case SAFI_MAX:
                assert(0);
        }
        XFREE(MTYPE_RFAPI_IT_EXTRA, hie);
@@ -306,7 +312,13 @@ void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn)
                }
                break;
 
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_UNICAST:
+       case SAFI_MULTICAST:
+       case SAFI_EVPN:
+       case SAFI_LABELED_UNICAST:
+       case SAFI_FLOWSPEC:
+       case SAFI_MAX:
                assert(0);
        }
        XFREE(MTYPE_RFAPI_IT_EXTRA, hie);
index d04d1ee7500f3ede7e87c5057812f384be1c2b02..e04938fde36d9824637a9ee3f8ab322a64ebc06a 100644 (file)
@@ -1863,7 +1863,7 @@ void rfapiPrintNhl(void *stream, struct rfapi_next_hop_entry *next_hops)
                                           vo->v.local_nexthop.cost, HVTYNL);
                                        break;
 
-                               default:
+                               case RFAPI_VN_OPTION_TYPE_INTERNAL_RD:
                                        fp(out,
                                           "%svn option type %d (unknown)%s",
                                           offset, vo->type, HVTYNL);
@@ -1881,7 +1881,7 @@ void rfapiPrintNhl(void *stream, struct rfapi_next_hop_entry *next_hops)
                                        rfapi_print_tunneltype_option(
                                                stream, 8, &uo->v.tunnel);
                                        break;
-                               default:
+                               case RFAPI_UN_OPTION_TYPE_PROVISIONAL:
                                        fp(out, "%sUN Option type %d%s", offset,
                                           uo->type, vty_newline);
                                        break;
@@ -4175,7 +4175,8 @@ static int rfapi_vty_show_nve_summary(struct vty *vty,
                case SHOW_NVE_SUMMARY_RESPONSES:
                        rfapiRibShowResponsesSummary(vty);
 
-               default:
+               case SHOW_NVE_SUMMARY_UNKNOWN_NVES:
+               case SHOW_NVE_SUMMARY_MAX:
                        break;
                }
                vty_out(vty, "\n");