summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-01-30 10:05:41 -0500
committerDonald Sharp <sharpd@nvidia.com>2023-01-31 12:29:08 -0500
commit58cf0823bf41e104b51f2f350ee370d51734b314 (patch)
tree0d2eb4c70486471d114c2986fdca7380d736c965
parentca411e386fa819e56ca4d63242b16821c81e8905 (diff)
bgpd: Add missing enum's to case statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--bgpd/bgp_addpath.c4
-rw-r--r--bgpd/bgp_evpn.c9
-rw-r--r--bgpd/bgp_flowspec_util.c6
-rw-r--r--bgpd/bgp_fsm.c2
-rw-r--r--bgpd/bgp_mplsvpn_snmp.c10
-rw-r--r--bgpd/bgp_open.c12
-rw-r--r--bgpd/bgp_route.c15
-rw-r--r--bgpd/bgp_vty.c35
-rw-r--r--bgpd/bgpd.h23
-rw-r--r--bgpd/rfapi/rfapi_encap_tlv.c8
-rw-r--r--bgpd/rfapi/rfapi_import.c40
-rw-r--r--bgpd/rfapi/rfapi_monitor.c16
-rw-r--r--bgpd/rfapi/rfapi_vty.c7
13 files changed, 139 insertions, 48 deletions
diff --git a/bgpd/bgp_addpath.c b/bgpd/bgp_addpath.c
index 461e60dbfc..748fcc92b4 100644
--- a/bgpd/bgp_addpath.c
+++ b/bgpd/bgp_addpath.c
@@ -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,
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index c993707206..d8acbcd19a 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -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;
}
diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c
index 9f3ea499ff..191b9f16fd 100644
--- a/bgpd/bgp_flowspec_util.c
+++ b/bgpd/bgp_flowspec_util.c
@@ -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;
}
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 9624adfbe2..faf3a4994d 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -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;
}
}
diff --git a/bgpd/bgp_mplsvpn_snmp.c b/bgpd/bgp_mplsvpn_snmp.c
index 8d5daa49c8..ea147e55b9 100644
--- a/bgpd/bgp_mplsvpn_snmp.c
+++ b/bgpd/bgp_mplsvpn_snmp.c
@@ -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);
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 659e93bdfa..3e361fccfd 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -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;
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index c9cfc44da0..1016e8d735 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -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;
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index d837601f32..daa435bb2d 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -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,
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 4c4c81f997..61119ab6e0 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -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 */
diff --git a/bgpd/rfapi/rfapi_encap_tlv.c b/bgpd/rfapi/rfapi_encap_tlv.c
index d4e875df2a..dc0c382dc1 100644
--- a/bgpd/rfapi/rfapi_encap_tlv.c
+++ b/bgpd/rfapi/rfapi_encap_tlv.c
@@ -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");
}
}
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 2aae0bc616..5db40be362 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -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) {
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index 0e71d5d7e1..f333e8cc55 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -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);
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index d04d1ee750..e04938fde3 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -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");