summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-08-04 13:19:36 -0400
committerDonald Sharp <sharpd@nvidia.com>2021-08-04 13:34:03 -0400
commit10cc80cafdc26e6afca4e435aafad924ff2f46b6 (patch)
tree45f13ffedba3e22a527f5e1970ccb3894c822c97 /zebra/zebra_mpls.c
parent1ae0e1b315edf256d41760bcbb631b5d2be0d087 (diff)
zebra: don't use default case when switching over enum nexthop
Do not use the `default` case when switching over an enumerated type. This allows the code to fail to compile when we add a new enumeration. Thus allowing us developers to know all the places in the code we'll need to touch. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_mpls.c')
-rw-r--r--zebra/zebra_mpls.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 66d2d6b4ba..f1a7c3e8c1 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -752,7 +752,7 @@ static int nhlfe_nexthop_active(zebra_nhlfe_t *nhlfe)
}
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
break;
}
@@ -1183,7 +1183,7 @@ static char *nhlfe2str(const zebra_nhlfe_t *nhlfe, char *buf, int size)
break;
case NEXTHOP_TYPE_IFINDEX:
snprintf(buf, size, "Ifindex: %u", nexthop->ifindex);
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
break;
}
@@ -1224,7 +1224,7 @@ static int nhlfe_nhop_match(zebra_nhlfe_t *nhlfe, enum nexthop_types_t gtype,
case NEXTHOP_TYPE_IFINDEX:
cmp = !(nhop->ifindex == ifindex);
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
break;
}
@@ -1294,7 +1294,7 @@ static zebra_nhlfe_t *nhlfe_alloc(zebra_lsp_t *lsp, enum lsp_types_t lsp_type,
case NEXTHOP_TYPE_IFINDEX:
nexthop->ifindex = ifindex;
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
nexthop_free(nexthop);
XFREE(MTYPE_NHLFE, nhlfe);
return NULL;
@@ -1527,7 +1527,8 @@ static json_object *nhlfe_json(zebra_nhlfe_t *nhlfe)
ifindex2ifname(nexthop->ifindex,
nexthop->vrf_id));
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
+ case NEXTHOP_TYPE_IFINDEX:
break;
}
@@ -1588,7 +1589,8 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty,
ifindex2ifname(nexthop->ifindex,
nexthop->vrf_id));
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
+ case NEXTHOP_TYPE_IFINDEX:
break;
}
vty_out(vty, "%s",
@@ -2830,7 +2832,8 @@ static bool ftn_update_znh(bool add_p, enum lsp_types_t type,
break;
success = true;
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
+ case NEXTHOP_TYPE_IFINDEX:
break;
}
@@ -3752,7 +3755,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
inet_ntop(AF_INET6, &nexthop->gate.ipv6,
nh_buf, sizeof(nh_buf));
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
break;
}
@@ -3795,7 +3798,11 @@ static char *nhlfe_config_str(const zebra_nhlfe_t *nhlfe, char *buf, int size)
buf[0] = '\0';
switch (nh->type) {
case NEXTHOP_TYPE_IPV4:
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
inet_ntop(AF_INET, &nh->gate.ipv4, buf, size);
+ if (nh->ifindex)
+ strlcat(buf, ifindex2ifname(nh->ifindex, VRF_DEFAULT),
+ size);
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
@@ -3805,7 +3812,8 @@ static char *nhlfe_config_str(const zebra_nhlfe_t *nhlfe, char *buf, int size)
ifindex2ifname(nh->ifindex, VRF_DEFAULT),
size);
break;
- default:
+ case NEXTHOP_TYPE_BLACKHOLE:
+ case NEXTHOP_TYPE_IFINDEX:
break;
}