From 8068a649a79409737dfa5235a84915b544d4fff7 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 6 Mar 2018 17:01:42 -0500 Subject: [PATCH] zebra: dont return a status code in zapi handlers All of the ZAPI message handlers return an integer that means different things to each of them, but nobody ever reads these integers, so this is technical debt that we can just eliminate outright. Signed-off-by: Quentin Young --- zebra/zebra_mroute.c | 5 +- zebra/zebra_mroute.h | 4 +- zebra/zebra_ptm.c | 28 +++--- zebra/zebra_ptm.h | 10 +- zebra/zebra_vxlan.c | 88 +++++++++--------- zebra/zebra_vxlan.h | 30 +++--- zebra/zebra_vxlan_null.c | 20 ++-- zebra/zserv.c | 194 +++++++++++++++++++-------------------- 8 files changed, 188 insertions(+), 191 deletions(-) diff --git a/zebra/zebra_mroute.c b/zebra/zebra_mroute.c index e9cd19ebe0..1143451d62 100644 --- a/zebra/zebra_mroute.c +++ b/zebra/zebra_mroute.c @@ -32,8 +32,8 @@ #include "zebra/rt.h" #include "zebra/debug.h" -int zebra_ipmr_route_stats(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_ipmr_route_stats(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct mcast_route_data mroute; struct stream *s; @@ -69,5 +69,4 @@ stream_failure: stream_putw_at(s, 0, stream_get_endp(s)); zebra_server_send_message(client); - return 0; } diff --git a/zebra/zebra_mroute.h b/zebra/zebra_mroute.h index 616c3a83ab..5bee7b03d6 100644 --- a/zebra/zebra_mroute.h +++ b/zebra/zebra_mroute.h @@ -28,7 +28,7 @@ struct mcast_route_data { unsigned long long lastused; }; -int zebra_ipmr_route_stats(struct zserv *client, u_short length, - struct zebra_vrf *zvf); +void zebra_ipmr_route_stats(struct zserv *client, u_short length, + struct zebra_vrf *zvf); #endif diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index f6775fa0b1..b0295d127e 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -661,8 +661,8 @@ int zebra_ptm_sock_read(struct thread *thread) } /* BFD peer/dst register/update */ -int zebra_ptm_bfd_dst_register(struct zserv *client, u_short length, - int command, struct zebra_vrf *zvrf) +void zebra_ptm_bfd_dst_register(struct zserv *client, u_short length, + int command, struct zebra_vrf *zvrf) { struct stream *s; struct prefix src_p; @@ -693,7 +693,7 @@ int zebra_ptm_bfd_dst_register(struct zserv *client, u_short length, ptm_cb.t_timer = NULL; thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, &ptm_cb.t_timer); - return -1; + return; } ptm_lib_init_msg(ptm_hdl, 0, PTMLIB_MSG_TYPE_CMD, NULL, &out_ctxt); @@ -816,16 +816,16 @@ int zebra_ptm_bfd_dst_register(struct zserv *client, u_short length, ptm_cb.out_data); zebra_ptm_send_message(ptm_cb.out_data, data_len); - return 0; + return; stream_failure: ptm_lib_cleanup_msg(ptm_hdl, out_ctxt); - return 0; + return; } /* BFD peer/dst deregister */ -int zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; struct prefix src_p; @@ -849,7 +849,7 @@ int zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length, ptm_cb.t_timer = NULL; thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, &ptm_cb.t_timer); - return -1; + return; } ptm_lib_init_msg(ptm_hdl, 0, PTMLIB_MSG_TYPE_CMD, NULL, &out_ctxt); @@ -948,15 +948,15 @@ int zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length, zebra_ptm_send_message(ptm_cb.out_data, data_len); - return 0; + return; stream_failure: ptm_lib_cleanup_msg(ptm_hdl, out_ctxt); - return 0; + return; } /* BFD client register */ -int zebra_ptm_bfd_client_register(struct zserv *client, u_short length) +void zebra_ptm_bfd_client_register(struct zserv *client, u_short length) { struct stream *s; unsigned int pid; @@ -977,7 +977,7 @@ int zebra_ptm_bfd_client_register(struct zserv *client, u_short length) ptm_cb.t_timer = NULL; thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, &ptm_cb.t_timer); - return -1; + return; } ptm_lib_init_msg(ptm_hdl, 0, PTMLIB_MSG_TYPE_CMD, NULL, &out_ctxt); @@ -1003,7 +1003,7 @@ int zebra_ptm_bfd_client_register(struct zserv *client, u_short length) SET_FLAG(ptm_cb.client_flags[client->proto], ZEBRA_PTM_BFD_CLIENT_FLAG_REG); - return 0; + return; stream_failure: /* @@ -1013,7 +1013,7 @@ stream_failure: * if (out_ctxt) * ptm_lib_cleanup_msg(ptm_hdl, out_ctxt); */ - return 0; + return; } /* BFD client deregister */ diff --git a/zebra/zebra_ptm.h b/zebra/zebra_ptm.h index 392853b599..2397d53845 100644 --- a/zebra/zebra_ptm.h +++ b/zebra/zebra_ptm.h @@ -62,12 +62,12 @@ int zebra_ptm_connect(struct thread *t); void zebra_ptm_write(struct vty *vty); int zebra_ptm_get_enable_state(void); -int zebra_ptm_bfd_dst_register(struct zserv *client, u_short length, - int command, struct zebra_vrf *zvrf); -int zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); +void zebra_ptm_bfd_dst_register(struct zserv *client, u_short length, + int command, struct zebra_vrf *zvrf); +void zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); void zebra_ptm_show_status(struct vty *vty, struct interface *ifp); -int zebra_ptm_bfd_client_register(struct zserv *client, u_short length); +void zebra_ptm_bfd_client_register(struct zserv *client, u_short length); void zebra_ptm_if_init(struct zebra_if *zebra_ifp); void zebra_ptm_if_set_ptm_state(struct interface *ifp, struct zebra_if *zebra_ifp); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index d3ede66fb0..bac589a841 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -4863,8 +4863,8 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp, /* * Handle message from client to delete a remote MACIP for a VNI. */ -int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_macip_del(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; vni_t vni; @@ -5008,7 +5008,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length, } stream_failure: - return 0; + return; } /* @@ -5016,8 +5016,8 @@ stream_failure: * could be just the add of a MAC address or the add of a neighbor * (IP+MAC). */ -int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; vni_t vni; @@ -5045,7 +5045,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, zlog_warn( "%s: EVPN Not turned on yet we have received a remote_macip add zapi callback", __PRETTY_FUNCTION__); - return -1; + return; } s = client->ibuf; @@ -5159,7 +5159,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, prefix_mac2str(&macaddr, buf, sizeof(buf)), vni, inet_ntoa(vtep_ip)); - return -1; + return; } /* Is this MAC created for a MACIP? */ @@ -5212,7 +5212,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, prefix_mac2str(&macaddr, buf, sizeof(buf)), vni, inet_ntoa(vtep_ip)); - return -1; + return; } } else if (memcmp(&n->emac, &macaddr, sizeof(macaddr)) @@ -5240,7 +5240,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, } stream_failure: - return 0; + return; } /* @@ -5543,8 +5543,8 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp, /* * Handle message from client to delete a remote VTEP for a VNI. */ -int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; u_short l = 0; @@ -5559,13 +5559,13 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, zlog_warn( "%s: EVPN is not enabled yet we have received a vtep del command", __PRETTY_FUNCTION__); - return -1; + return; } if (zvrf_id(zvrf) != VRF_DEFAULT) { zlog_err("Recv MACIP DEL for non-default VRF %u", zvrf_id(zvrf)); - return -1; + return; } s = client->ibuf; @@ -5623,14 +5623,14 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, } stream_failure: - return 0; + return; } /* * Handle message from client to add a remote VTEP for a VNI. */ -int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; u_short l = 0; @@ -5644,13 +5644,13 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, zlog_warn( "%s: EVPN not enabled yet we received a vtep_add zapi call", __PRETTY_FUNCTION__); - return -1; + return; } if (zvrf_id(zvrf) != VRF_DEFAULT) { zlog_err("Recv MACIP ADD for non-default VRF %u", zvrf_id(zvrf)); - return -1; + return; } s = client->ibuf; @@ -5705,7 +5705,7 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, } stream_failure: - return 0; + return; } /* @@ -6512,8 +6512,8 @@ int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf) * Handle message from client to enable/disable advertisement of g/w macip * routes */ -int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; int advertise; @@ -6527,7 +6527,7 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, if (zvrf_id(zvrf) != VRF_DEFAULT) { zlog_err("EVPN GW-MACIP Adv for non-default VRF %u", zvrf_id(zvrf)); - return -1; + return; } s = client->ibuf; @@ -6536,10 +6536,10 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, zvni = zvni_lookup(vni); if (!zvni) - return 0; + return; if (zvni->advertise_subnet == advertise) - return 0; + return; if (IS_ZEBRA_DEBUG_VXLAN) zlog_debug("EVPN subnet Adv %s on VNI %d , currently %s", @@ -6551,35 +6551,35 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, ifp = zvni->vxlan_if; if (!ifp) - return 0; + return; zif = ifp->info; /* If down or not mapped to a bridge, we're done. */ if (!if_is_operative(ifp) || !zif->brslave_info.br_if) - return 0; + return; zl2_info = zif->l2info.vxl; vlan_if = zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if); if (!vlan_if) - return 0; + return; if (zvni->advertise_subnet) zvni_advertise_subnet(zvni, vlan_if, 1); else zvni_advertise_subnet(zvni, vlan_if, 0); - return 0; + return; } /* * Handle message from client to enable/disable advertisement of g/w macip * routes */ -int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; int advertise; @@ -6590,7 +6590,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, if (zvrf_id(zvrf) != VRF_DEFAULT) { zlog_err("EVPN GW-MACIP Adv for non-default VRF %u", zvrf_id(zvrf)); - return -1; + return; } s = client->ibuf; @@ -6606,7 +6606,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, : "disabled"); if (zvrf->advertise_gw_macip == advertise) - return 0; + return; zvrf->advertise_gw_macip = advertise; @@ -6625,7 +6625,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, zvni = zvni_lookup(vni); if (!zvni) - return 0; + return; if (IS_ZEBRA_DEBUG_VXLAN) zlog_debug( @@ -6635,26 +6635,26 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, : "disabled"); if (zvni->advertise_gw_macip == advertise) - return 0; + return; zvni->advertise_gw_macip = advertise; ifp = zvni->vxlan_if; if (!ifp) - return 0; + return; zif = ifp->info; /* If down or not mapped to a bridge, we're done. */ if (!if_is_operative(ifp) || !zif->brslave_info.br_if) - return 0; + return; zl2_info = zif->l2info.vxl; vlan_if = zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if); if (!vlan_if) - return 0; + return; if (advertise_gw_macip_enabled(zvni)) { /* Add primary SVI MAC-IP */ @@ -6676,7 +6676,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, } stream_failure: - return 0; + return; } @@ -6686,8 +6686,8 @@ stream_failure: * when disabled, the entries should be deleted and remote VTEPs and MACs * uninstalled from the kernel. */ -int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s = NULL; int advertise = 0; @@ -6695,7 +6695,7 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, if (zvrf_id(zvrf) != VRF_DEFAULT) { zlog_err("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf)); - return -1; + return; } s = client->ibuf; @@ -6707,7 +6707,7 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, is_evpn_enabled() ? "enabled" : "disabled"); if (zvrf->advertise_all_vni == advertise) - return 0; + return; zvrf->advertise_all_vni = advertise; if (is_evpn_enabled()) { @@ -6732,13 +6732,13 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, /* cleanup all l3vnis */ zns = zebra_ns_lookup(NS_DEFAULT); if (!zns) - return -1; + return; hash_iterate(zns->l3vni_table, zl3vni_cleanup_all, NULL); } stream_failure: - return 0; + return; } /* diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 7abf0050fc..af76a41d80 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -51,6 +51,22 @@ static inline int is_evpn_enabled() #define VNI_STR_LEN 32 +/* zserv handlers */ +extern void zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_remote_macip_del(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); +extern void zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, + struct zebra_vrf *zvrf); + extern int is_l3vni_for_prefix_routes_only(vni_t vni); extern ifindex_t get_l3vni_svi_ifindex(vrf_id_t vrf_id); extern int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf); @@ -117,10 +133,6 @@ extern int zebra_vxlan_local_neigh_add_update( extern int zebra_vxlan_local_neigh_del(struct interface *ifp, struct interface *link_if, struct ipaddr *ip); -extern int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); -extern int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); extern int zebra_vxlan_local_mac_add_update(struct interface *ifp, struct interface *br_if, struct ethaddr *mac, vlanid_t vid, @@ -140,16 +152,6 @@ extern int zebra_vxlan_if_down(struct interface *ifp); extern int zebra_vxlan_if_add(struct interface *ifp); extern int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags); extern int zebra_vxlan_if_del(struct interface *ifp); -extern int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); -extern int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); -extern int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); -extern int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); -extern int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, - struct zebra_vrf *zvrf); extern int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, char *err, int err_str_sz, int filter, int add); diff --git a/zebra/zebra_vxlan_null.c b/zebra/zebra_vxlan_null.c index 1bac2cafb6..e6a3dd674e 100644 --- a/zebra/zebra_vxlan_null.c +++ b/zebra/zebra_vxlan_null.c @@ -117,14 +117,14 @@ int zebra_vxlan_svi_down(struct interface *ifp, struct interface *link_if) return 0; } -int zebra_vxlan_remote_macip_add(struct zserv *client, int sock, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_macip_add(struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) { return 0; } -int zebra_vxlan_remote_macip_del(struct zserv *client, int sock, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_macip_del(struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) { return 0; } @@ -182,20 +182,20 @@ int zebra_vxlan_if_del(struct interface *ifp) return 0; } -int zebra_vxlan_remote_vtep_add(struct zserv *client, int sock, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_vtep_add(struct zserv *client, int sock, u_short length, + struct zebra_vrf *zvrf) { return 0; } -int zebra_vxlan_remote_vtep_del(struct zserv *client, int sock, u_short length, - struct zebra_vrf *zvrf) +void zebra_vxlan_remote_vtep_del(struct zserv *client, int sock, u_short length, + struct zebra_vrf *zvrf) { return 0; } -int zebra_vxlan_advertise_all_vni(struct zserv *client, int sock, - u_short length, struct zebra_vrf *zvrf) +void zebra_vxlan_advertise_all_vni(struct zserv *client, int sock, + u_short length, struct zebra_vrf *zvrf) { return 0; } diff --git a/zebra/zserv.c b/zebra/zserv.c index 1a2ad7f8b4..f3ee38fef1 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -693,8 +693,8 @@ static int zsend_write_nexthop(struct stream *s, struct nexthop *nexthop) } /* Nexthop register */ -static int zserv_rnh_register(struct zserv *client, u_short length, - rnh_type_t type, struct zebra_vrf *zvrf) +static void zserv_rnh_register(struct zserv *client, u_short length, + rnh_type_t type, struct zebra_vrf *zvrf) { struct rnh *rnh; struct stream *s; @@ -722,7 +722,7 @@ static int zserv_rnh_register(struct zserv *client, u_short length, zlog_warn( "%s: Specified prefix length %d is too large for a v4 address", __PRETTY_FUNCTION__, p.prefixlen); - return -1; + return; } STREAM_GET(&p.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN); l += IPV4_MAX_BYTELEN; @@ -731,7 +731,7 @@ static int zserv_rnh_register(struct zserv *client, u_short length, zlog_warn( "%s: Specified prefix length %d is to large for a v6 address", __PRETTY_FUNCTION__, p.prefixlen); - return -1; + return; } STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); l += IPV6_MAX_BYTELEN; @@ -739,7 +739,7 @@ static int zserv_rnh_register(struct zserv *client, u_short length, zlog_err( "rnh_register: Received unknown family type %d\n", p.family); - return -1; + return; } rnh = zebra_add_rnh(&p, zvrf_id(zvrf), type); if (type == RNH_NEXTHOP_TYPE) { @@ -764,12 +764,12 @@ static int zserv_rnh_register(struct zserv *client, u_short length, } stream_failure: - return 0; + return; } /* Nexthop register */ -static int zserv_rnh_unregister(struct zserv *client, u_short length, - rnh_type_t type, struct zebra_vrf *zvrf) +static void zserv_rnh_unregister(struct zserv *client, u_short length, + rnh_type_t type, struct zebra_vrf *zvrf) { struct rnh *rnh; struct stream *s; @@ -797,7 +797,7 @@ static int zserv_rnh_unregister(struct zserv *client, u_short length, zlog_warn( "%s: Specified prefix length %d is to large for a v4 address", __PRETTY_FUNCTION__, p.prefixlen); - return -1; + return; } STREAM_GET(&p.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN); l += IPV4_MAX_BYTELEN; @@ -806,7 +806,7 @@ static int zserv_rnh_unregister(struct zserv *client, u_short length, zlog_warn( "%s: Specified prefix length %d is to large for a v6 address", __PRETTY_FUNCTION__, p.prefixlen); - return -1; + return; } STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); l += IPV6_MAX_BYTELEN; @@ -814,7 +814,7 @@ static int zserv_rnh_unregister(struct zserv *client, u_short length, zlog_err( "rnh_register: Received unknown family type %d\n", p.family); - return -1; + return; } rnh = zebra_lookup_rnh(&p, zvrf_id(zvrf), type); if (rnh) { @@ -823,13 +823,13 @@ static int zserv_rnh_unregister(struct zserv *client, u_short length, } } stream_failure: - return 0; + return; } #define ZEBRA_MIN_FEC_LENGTH 5 /* FEC register */ -static int zserv_fec_register(struct zserv *client, u_short length) +static void zserv_fec_register(struct zserv *client, u_short length) { struct stream *s; struct zebra_vrf *zvrf; @@ -841,7 +841,7 @@ static int zserv_fec_register(struct zserv *client, u_short length) s = client->ibuf; zvrf = vrf_info_lookup(VRF_DEFAULT); if (!zvrf) - return 0; // unexpected + return; /* * The minimum amount of data that can be sent for one fec @@ -851,7 +851,7 @@ static int zserv_fec_register(struct zserv *client, u_short length) zlog_err( "fec_register: Received a fec register of length %d, it is of insufficient size to properly decode", length); - return -1; + return; } while (l < length) { @@ -862,7 +862,7 @@ static int zserv_fec_register(struct zserv *client, u_short length) zlog_err( "fec_register: Received unknown family type %d\n", p.family); - return -1; + return; } STREAM_GETC(s, p.prefixlen); if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN) @@ -871,7 +871,7 @@ static int zserv_fec_register(struct zserv *client, u_short length) zlog_warn( "%s: Specified prefix length: %d is to long for %d", __PRETTY_FUNCTION__, p.prefixlen, p.family); - return -1; + return; } l += 5; STREAM_GET(&p.u.prefix, s, PSIZE(p.prefixlen)); @@ -885,11 +885,11 @@ static int zserv_fec_register(struct zserv *client, u_short length) } stream_failure: - return 0; + return; } /* FEC unregister */ -static int zserv_fec_unregister(struct zserv *client, u_short length) +static void zserv_fec_unregister(struct zserv *client, u_short length) { struct stream *s; struct zebra_vrf *zvrf; @@ -900,7 +900,7 @@ static int zserv_fec_unregister(struct zserv *client, u_short length) s = client->ibuf; zvrf = vrf_info_lookup(VRF_DEFAULT); if (!zvrf) - return 0; // unexpected + return; /* * The minimum amount of data that can be sent for one @@ -910,7 +910,7 @@ static int zserv_fec_unregister(struct zserv *client, u_short length) zlog_err( "fec_unregister: Received a fec unregister of length %d, it is of insufficient size to properly decode", length); - return -1; + return; } while (l < length) { @@ -924,7 +924,7 @@ static int zserv_fec_unregister(struct zserv *client, u_short length) zlog_err( "fec_unregister: Received unknown family type %d\n", p.family); - return -1; + return; } STREAM_GETC(s, p.prefixlen); if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN) @@ -933,7 +933,7 @@ static int zserv_fec_unregister(struct zserv *client, u_short length) zlog_warn( "%s: Received prefix length %d which is greater than %d can support", __PRETTY_FUNCTION__, p.prefixlen, p.family); - return -1; + return; } l += 5; STREAM_GET(&p.u.prefix, s, PSIZE(p.prefixlen)); @@ -942,7 +942,7 @@ static int zserv_fec_unregister(struct zserv *client, u_short length) } stream_failure: - return 0; + return; } /* @@ -1133,8 +1133,8 @@ int zsend_pw_update(struct zserv *client, struct zebra_pw *pw) /* Register zebra server interface information. Send current all interface and address information. */ -static int zread_interface_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_interface_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct vrf *vrf; struct interface *ifp; @@ -1149,21 +1149,20 @@ static int zread_interface_add(struct zserv *client, u_short length, continue; if (zsend_interface_add(client, ifp) < 0) - return -1; + return; if (zsend_interface_addresses(client, ifp) < 0) - return -1; + return; } } - return 0; + return; } /* Unregister zebra server interface information. */ -static int zread_interface_delete(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_interface_delete(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { vrf_bitmap_unset(client->ifinfo, zvrf_id(zvrf)); - return 0; } void zserv_nexthop_num_warn(const char *caller, const struct prefix *p, @@ -1178,8 +1177,8 @@ void zserv_nexthop_num_warn(const char *caller, const struct prefix *p, } } -static int zread_route_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_route_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; struct zapi_route api; @@ -1193,7 +1192,7 @@ static int zread_route_add(struct zserv *client, u_short length, s = client->ibuf; if (zapi_route_decode(s, &api) < 0) - return -1; + return; /* Allocate new route. */ vrf_id = zvrf_id(zvrf); @@ -1277,7 +1276,7 @@ static int zread_route_add(struct zserv *client, u_short length, __PRETTY_FUNCTION__, api.nexthop_num); nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } /* MPLS labels for BGP-LU or Segment Routing */ if (CHECK_FLAG(api.message, ZAPI_MESSAGE_LABEL) @@ -1309,7 +1308,7 @@ static int zread_route_add(struct zserv *client, u_short length, __PRETTY_FUNCTION__); nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) src_p = &api.src_prefix; @@ -1331,12 +1330,10 @@ static int zread_route_add(struct zserv *client, u_short length, client->v6_route_upd8_cnt++; break; } - - return 0; } -static int zread_route_del(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_route_del(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; struct zapi_route api; @@ -1345,13 +1342,13 @@ static int zread_route_del(struct zserv *client, u_short length, s = client->ibuf; if (zapi_route_decode(s, &api) < 0) - return -1; + return; afi = family2afi(api.prefix.family); if (afi != AFI_IP6 && CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) { zlog_warn("%s: Received a src prefix while afi is not v6", __PRETTY_FUNCTION__); - return -1; + return; } if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) src_p = &api.src_prefix; @@ -1370,7 +1367,7 @@ static int zread_route_del(struct zserv *client, u_short length, break; } - return 0; + return; } /* This function support multiple nexthop. */ @@ -1378,8 +1375,8 @@ static int zread_route_del(struct zserv *client, u_short length, * Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update re and * add kernel route. */ -static int zread_ipv4_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_ipv4_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { int i; struct route_entry *re; @@ -1409,7 +1406,7 @@ static int zread_ipv4_add(struct zserv *client, u_short length, zlog_warn("%s: Specified route type %d is not a legal value\n", __PRETTY_FUNCTION__, re->type); XFREE(MTYPE_RE, re); - return -1; + return; } STREAM_GETW(s, re->instance); STREAM_GETL(s, re->flags); @@ -1426,7 +1423,7 @@ static int zread_ipv4_add(struct zserv *client, u_short length, "%s: Specified prefix length %d is greater than what v4 can be", __PRETTY_FUNCTION__, p.prefixlen); XFREE(MTYPE_RE, re); - return -1; + return; } STREAM_GET(&p.u.prefix4, s, PSIZE(p.prefixlen)); @@ -1478,7 +1475,7 @@ static int zread_ipv4_add(struct zserv *client, u_short length, __PRETTY_FUNCTION__); nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; break; case NEXTHOP_TYPE_BLACKHOLE: route_entry_nexthop_blackhole_add(re, bh_type); @@ -1489,7 +1486,7 @@ static int zread_ipv4_add(struct zserv *client, u_short length, __PRETTY_FUNCTION__, nexthop_type); nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } } } @@ -1524,17 +1521,17 @@ static int zread_ipv4_add(struct zserv *client, u_short length, else if (ret < 0) client->v4_route_upd8_cnt++; - return 0; + return; stream_failure: nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } /* Zebra server IPv4 prefix delete function. */ -static int zread_ipv4_delete(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_ipv4_delete(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; struct zapi_ipv4 api; @@ -1557,7 +1554,7 @@ static int zread_ipv4_delete(struct zserv *client, u_short length, if (p.prefixlen > IPV4_MAX_BITLEN) { zlog_warn("%s: Passed in prefixlen %d is impossible", __PRETTY_FUNCTION__, p.prefixlen); - return -1; + return; } STREAM_GET(&p.u.prefix4, s, PSIZE(p.prefixlen)); @@ -1568,28 +1565,29 @@ static int zread_ipv4_delete(struct zserv *client, u_short length, client->v4_route_del_cnt++; stream_failure: - return 0; + return; } /* MRIB Nexthop lookup for IPv4. */ -static int zread_ipv4_nexthop_lookup_mrib(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_ipv4_nexthop_lookup_mrib(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct in_addr addr; struct route_entry *re; STREAM_GET(&addr.s_addr, client->ibuf, IPV4_MAX_BYTELEN); re = rib_match_ipv4_multicast(zvrf_id(zvrf), addr, NULL); - return zsend_ipv4_nexthop_lookup_mrib(client, addr, re, zvrf); + zsend_ipv4_nexthop_lookup_mrib(client, addr, re, zvrf); + return; stream_failure: - return -1; + return; } /* Zebra server IPv6 prefix add function. */ -static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client, - u_short length, - struct zebra_vrf *zvrf) +static void zread_ipv4_route_ipv6_nexthop_add(struct zserv *client, + u_short length, + struct zebra_vrf *zvrf) { unsigned int i; struct stream *s; @@ -1623,7 +1621,8 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client, zlog_warn("%s: Specified route type: %d is not a legal value\n", __PRETTY_FUNCTION__, re->type); XFREE(MTYPE_RE, re); - return -1; + + return; } STREAM_GETW(s, re->instance); STREAM_GETL(s, re->flags); @@ -1640,7 +1639,7 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client, "%s: Prefix Length %d is greater than what a v4 address can use", __PRETTY_FUNCTION__, p.prefixlen); XFREE(MTYPE_RE, re); - return -1; + return; } STREAM_GET(&p.u.prefix4, s, PSIZE(p.prefixlen)); @@ -1695,7 +1694,7 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client, __PRETTY_FUNCTION__); nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } } @@ -1753,16 +1752,16 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client, else if (ret < 0) client->v4_route_upd8_cnt++; - return 0; + return; stream_failure: nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } -static int zread_ipv6_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_ipv6_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { unsigned int i; struct stream *s; @@ -1798,7 +1797,7 @@ static int zread_ipv6_add(struct zserv *client, u_short length, zlog_warn("%s: Specified route type: %d is not a legal value\n", __PRETTY_FUNCTION__, re->type); XFREE(MTYPE_RE, re); - return -1; + return; } STREAM_GETW(s, re->instance); STREAM_GETL(s, re->flags); @@ -1815,7 +1814,7 @@ static int zread_ipv6_add(struct zserv *client, u_short length, "%s: Specified prefix length %d is to large for v6 prefix", __PRETTY_FUNCTION__, p.prefixlen); XFREE(MTYPE_RE, re); - return -1; + return; } STREAM_GET(&p.u.prefix6, s, PSIZE(p.prefixlen)); @@ -1828,7 +1827,7 @@ static int zread_ipv6_add(struct zserv *client, u_short length, "%s: Specified src prefix length %d is to large for v6 prefix", __PRETTY_FUNCTION__, src_p.prefixlen); XFREE(MTYPE_RE, re); - return -1; + return; } STREAM_GET(&src_p.prefix, s, PSIZE(src_p.prefixlen)); src_pp = &src_p; @@ -1891,7 +1890,7 @@ static int zread_ipv6_add(struct zserv *client, u_short length, __PRETTY_FUNCTION__); nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } } @@ -1947,18 +1946,18 @@ static int zread_ipv6_add(struct zserv *client, u_short length, else if (ret < 0) client->v6_route_upd8_cnt++; - return 0; + return; stream_failure: nexthops_free(re->ng.nexthop); XFREE(MTYPE_RE, re); - return -1; + return; } /* Zebra server IPv6 prefix delete function. */ -static int zread_ipv6_delete(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_ipv6_delete(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; struct zapi_ipv6 api; @@ -1996,12 +1995,12 @@ static int zread_ipv6_delete(struct zserv *client, u_short length, client->v6_route_del_cnt++; stream_failure: - return 0; + return; } /* Register zebra server router-id information. Send current router-id */ -static int zread_router_id_add(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_router_id_add(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct prefix p; @@ -2010,15 +2009,14 @@ static int zread_router_id_add(struct zserv *client, u_short length, router_id_get(&p, zvrf_id(zvrf)); - return zsend_router_id_update(client, &p, zvrf_id(zvrf)); + zsend_router_id_update(client, &p, zvrf_id(zvrf)); } /* Unregister zebra server router-id information. */ -static int zread_router_id_delete(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_router_id_delete(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { vrf_bitmap_unset(client->ridinfo, zvrf_id(zvrf)); - return 0; } /* Tie up route-type and client->sock */ @@ -2052,8 +2050,8 @@ stream_failure: } /* Unregister all information in a VRF. */ -static int zread_vrf_unregister(struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_vrf_unregister(struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { int i; afi_t afi; @@ -2064,8 +2062,6 @@ static int zread_vrf_unregister(struct zserv *client, u_short length, vrf_bitmap_unset(client->redist_default, zvrf_id(zvrf)); vrf_bitmap_unset(client->ifinfo, zvrf_id(zvrf)); vrf_bitmap_unset(client->ridinfo, zvrf_id(zvrf)); - - return 0; } static void zread_mpls_labels(int command, struct zserv *client, u_short length, @@ -2313,8 +2309,8 @@ static void zread_label_manager_request(int cmd, struct zserv *client, } } -static int zread_pseudowire(int command, struct zserv *client, u_short length, - struct zebra_vrf *zvrf) +static void zread_pseudowire(int command, struct zserv *client, u_short length, + struct zebra_vrf *zvrf) { struct stream *s; char ifname[IF_NAMESIZE]; @@ -2345,7 +2341,7 @@ static int zread_pseudowire(int command, struct zserv *client, u_short length, STREAM_GET(&nexthop.ipv6, s, 16); break; default: - return -1; + return; } STREAM_GETL(s, local_label); STREAM_GETL(s, remote_label); @@ -2360,7 +2356,7 @@ static int zread_pseudowire(int command, struct zserv *client, u_short length, zlog_warn("%s: pseudowire %s already exists [%s]", __func__, ifname, zserv_command_string(command)); - return -1; + return; } zebra_pw_add(zvrf, ifname, protocol, client); @@ -2369,7 +2365,7 @@ static int zread_pseudowire(int command, struct zserv *client, u_short length, if (!pw) { zlog_warn("%s: pseudowire %s not found [%s]", __func__, ifname, zserv_command_string(command)); - return -1; + return; } zebra_pw_del(zvrf, pw); @@ -2379,7 +2375,7 @@ static int zread_pseudowire(int command, struct zserv *client, u_short length, if (!pw) { zlog_warn("%s: pseudowire %s not found [%s]", __func__, ifname, zserv_command_string(command)); - return -1; + return; } switch (command) { @@ -2397,7 +2393,7 @@ static int zread_pseudowire(int command, struct zserv *client, u_short length, } stream_failure: - return 0; + return; } /* Cleanup registered nexthops (across VRFs) upon client disconnect. */ @@ -2532,7 +2528,7 @@ static void zebra_client_create(int sock) zebra_vrf_update_all(client); } -static int zread_interface_set_master(struct zserv *client, u_short length) +static void zread_interface_set_master(struct zserv *client, u_short length) { struct interface *master; struct interface *slave; @@ -2549,12 +2545,12 @@ static int zread_interface_set_master(struct zserv *client, u_short length) slave = if_lookup_by_index(ifindex, vrf_id); if (!master || !slave) - return 0; + return; kernel_interface_set_master(master, slave); stream_failure: - return 1; + return; } -- 2.39.5