summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_fpm_netlink.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-04-21 13:50:27 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2020-04-22 13:29:15 +0200
commit58c3cdb922004056225a46cfde5bd6c36850bebd (patch)
tree645472d808bae08beba38208c3e0d720b58b17f6 /zebra/zebra_fpm_netlink.c
parentMerge pull request #6268 from opensourcerouting/atomlist-cxx-compat (diff)
downloadfrr-58c3cdb922004056225a46cfde5bd6c36850bebd.tar.xz
frr-58c3cdb922004056225a46cfde5bd6c36850bebd.zip
zebra: Cleanup dead code
There are a couple of switch statements in netlink_route_info_encode in zebra_fpm_netlink.c that had logically dead code. We have a switch statement let's take actual advantage of it instead of doing gyrations to what we want. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_fpm_netlink.c')
-rw-r--r--zebra/zebra_fpm_netlink.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index 0d6428026..00909df1d 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -431,23 +431,18 @@ static int netlink_route_info_encode(netlink_route_info_t *ri, char *in_buf,
}
encap = nhi->encap_info.encap_type;
- if (encap > FPM_NH_ENCAP_NONE) {
+ switch (encap) {
+ case FPM_NH_ENCAP_NONE:
+ case FPM_NH_ENCAP_MAX:
+ break;
+ case FPM_NH_ENCAP_VXLAN:
addattr_l(&req->n, in_buf_len, RTA_ENCAP_TYPE, &encap,
sizeof(uint16_t));
- switch (encap) {
- case FPM_NH_ENCAP_NONE:
- break;
- case FPM_NH_ENCAP_VXLAN:
- vxlan = &nhi->encap_info.vxlan_encap;
- nest = addattr_nest(&req->n, in_buf_len,
- RTA_ENCAP);
- addattr32(&req->n, in_buf_len, VXLAN_VNI,
- vxlan->vni);
- addattr_nest_end(&req->n, nest);
- break;
- case FPM_NH_ENCAP_MAX:
- break;
- }
+ vxlan = &nhi->encap_info.vxlan_encap;
+ nest = addattr_nest(&req->n, in_buf_len, RTA_ENCAP);
+ addattr32(&req->n, in_buf_len, VXLAN_VNI, vxlan->vni);
+ addattr_nest_end(&req->n, nest);
+ break;
}
goto done;
@@ -484,25 +479,22 @@ static int netlink_route_info_encode(netlink_route_info_t *ri, char *in_buf,
}
encap = nhi->encap_info.encap_type;
- if (encap > FPM_NH_ENCAP_NONE) {
+ switch (encap) {
+ case FPM_NH_ENCAP_NONE:
+ case FPM_NH_ENCAP_MAX:
+ break;
+ case FPM_NH_ENCAP_VXLAN:
rta_addattr_l(rta, sizeof(buf), RTA_ENCAP_TYPE,
&encap, sizeof(uint16_t));
rtnh->rtnh_len += sizeof(struct rtattr) +
sizeof(uint16_t);
- switch (encap) {
- case FPM_NH_ENCAP_NONE:
- break;
- case FPM_NH_ENCAP_VXLAN:
- vxlan = &nhi->encap_info.vxlan_encap;
- nest = rta_nest(rta, sizeof(buf), RTA_ENCAP);
- rta_addattr_l(rta, sizeof(buf), VXLAN_VNI,
- &vxlan->vni, sizeof(uint32_t));
- nest_len = rta_nest_end(rta, nest);
- rtnh->rtnh_len += nest_len;
- break;
- case FPM_NH_ENCAP_MAX:
- break;
- }
+ vxlan = &nhi->encap_info.vxlan_encap;
+ nest = rta_nest(rta, sizeof(buf), RTA_ENCAP);
+ rta_addattr_l(rta, sizeof(buf), VXLAN_VNI, &vxlan->vni,
+ sizeof(uint32_t));
+ nest_len = rta_nest_end(rta, nest);
+ rtnh->rtnh_len += nest_len;
+ break;
}
rtnh = RTNH_NEXT(rtnh);