*: Convert all usage of zclient_send_message to new enum

The `enum zclient_send_status` enum needs to be extended
throughout the code base to use the new states and
to fix up places where we tested against the return
value being non zero.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2020-11-11 14:14:37 -05:00
parent 8a3f8f2e4a
commit 7cfdb48554
16 changed files with 197 additions and 145 deletions

View File

@ -392,8 +392,9 @@ void bgp_lp_get(
if (lp_fifo_count(&lp->requests) > lp->pending_count) { if (lp_fifo_count(&lp->requests) > lp->pending_count) {
if (!zclient || zclient->sock < 0) if (!zclient || zclient->sock < 0)
return; return;
if (!zclient_send_get_label_chunk(zclient, 0, LP_CHUNK_SIZE, if (zclient_send_get_label_chunk(zclient, 0, LP_CHUNK_SIZE,
MPLS_LABEL_BASE_ANY)) MPLS_LABEL_BASE_ANY)
== ZCLIENT_SEND_FAILURE)
lp->pending_count += LP_CHUNK_SIZE; lp->pending_count += LP_CHUNK_SIZE;
} }
} }

View File

@ -624,7 +624,7 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
ret = zclient_send_rnh(zclient, command, &bnc->prefix, exact_match, ret = zclient_send_rnh(zclient, command, &bnc->prefix, exact_match,
bnc->bgp->vrf_id); bnc->bgp->vrf_id);
/* TBD: handle the failure */ /* TBD: handle the failure */
if (ret < 0) if (ret == ZCLIENT_SEND_FAILURE)
flog_warn(EC_BGP_ZEBRA_SEND, flog_warn(EC_BGP_ZEBRA_SEND,
"sendmsg_nexthop: zclient_send_message() failed"); "sendmsg_nexthop: zclient_send_message() failed");

View File

@ -3319,7 +3319,7 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
} }
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api) if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
< 0) { == ZCLIENT_SEND_FAILURE) {
zlog_err("error sending capability"); zlog_err("error sending capability");
ret = BGP_GR_FAILURE; ret = BGP_GR_FAILURE;
} else { } else {
@ -3361,7 +3361,7 @@ int bgp_zebra_update(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type)
api.cap = type; api.cap = type;
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api) if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
< 0) { == ZCLIENT_SEND_FAILURE) {
if (BGP_DEBUG(zebra, ZEBRA)) if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("error sending capability"); zlog_debug("error sending capability");
return BGP_GR_FAILURE; return BGP_GR_FAILURE;
@ -3393,7 +3393,7 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
api.stale_removal_time = bgp->rib_stale_time; api.stale_removal_time = bgp->rib_stale_time;
api.vrf_id = bgp->vrf_id; api.vrf_id = bgp->vrf_id;
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api) if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
< 0) { == ZCLIENT_SEND_FAILURE) {
if (BGP_DEBUG(zebra, ZEBRA)) if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("error sending capability"); zlog_debug("error sending capability");
return BGP_GR_FAILURE; return BGP_GR_FAILURE;

View File

@ -618,7 +618,7 @@ int isis_zebra_label_manager_connect(void)
set_nonblocking(zclient_sync->sock); set_nonblocking(zclient_sync->sock);
/* Send hello to notify zebra this is a synchronous client */ /* Send hello to notify zebra this is a synchronous client */
if (zclient_send_hello(zclient_sync) < 0) { if (zclient_send_hello(zclient_sync) == ZCLIENT_SEND_FAILURE) {
zlog_warn("%s: failed sending hello for synchronous zclient!", zlog_warn("%s: failed sending hello for synchronous zclient!",
__func__); __func__);
close(zclient_sync->sock); close(zclient_sync->sock);

View File

@ -2092,7 +2092,7 @@ static void zclient_sync_init(void)
sock_set_nonblock(zclient_sync->sock); sock_set_nonblock(zclient_sync->sock);
/* Send hello to notify zebra this is a synchronous client */ /* Send hello to notify zebra this is a synchronous client */
if (zclient_send_hello(zclient_sync) < 0) { if (zclient_send_hello(zclient_sync) == ZCLIENT_SEND_FAILURE) {
log_warnx("Error sending hello for synchronous zclient!"); log_warnx("Error sending hello for synchronous zclient!");
goto retry; goto retry;
} }

View File

@ -127,8 +127,12 @@ ldp_zebra_opaque_unregister(void)
int int
ldp_sync_zebra_send_state_update(struct ldp_igp_sync_if_state *state) ldp_sync_zebra_send_state_update(struct ldp_igp_sync_if_state *state)
{ {
return zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE, if (zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE,
(const uint8_t *) state, sizeof(*state)); (const uint8_t *)state, sizeof(*state))
== ZCLIENT_SEND_FAILURE)
return -1;
else
return 0;
} }
static int static int
@ -137,8 +141,12 @@ ldp_sync_zebra_send_announce(void)
struct ldp_igp_sync_announce announce; struct ldp_igp_sync_announce announce;
announce.proto = ZEBRA_ROUTE_LDP; announce.proto = ZEBRA_ROUTE_LDP;
return zclient_send_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE, if (zclient_send_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE,
(const uint8_t *) &announce, sizeof(announce)); (const uint8_t *)&announce, sizeof(announce))
== ZCLIENT_SEND_FAILURE)
return -1;
else
return 0;
} }
static int static int
@ -272,7 +280,10 @@ ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr)
znh->label_num = 1; znh->label_num = 1;
znh->labels[0] = kr->remote_label; znh->labels[0] = kr->remote_label;
return zebra_send_mpls_labels(zclient, cmd, &zl); if (zebra_send_mpls_labels(zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE)
return -1;
return 0;
} }
int int
@ -293,7 +304,8 @@ kmpw_add(struct zapi_pw *zpw)
debug_zebra_out("pseudowire %s nexthop %s (add)", debug_zebra_out("pseudowire %s nexthop %s (add)",
zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop)); zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop));
return (zebra_send_pw(zclient, ZEBRA_PW_ADD, zpw)); return zebra_send_pw(zclient, ZEBRA_PW_ADD, zpw)
== ZCLIENT_SEND_FAILURE;
} }
int int
@ -302,7 +314,8 @@ kmpw_del(struct zapi_pw *zpw)
debug_zebra_out("pseudowire %s nexthop %s (del)", debug_zebra_out("pseudowire %s nexthop %s (del)",
zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop)); zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop));
return (zebra_send_pw(zclient, ZEBRA_PW_DELETE, zpw)); return zebra_send_pw(zclient, ZEBRA_PW_DELETE, zpw)
== ZCLIENT_SEND_FAILURE;
} }
int int
@ -312,7 +325,8 @@ kmpw_set(struct zapi_pw *zpw)
zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop), zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop),
zpw->local_label, zpw->remote_label); zpw->local_label, zpw->remote_label);
return (zebra_send_pw(zclient, ZEBRA_PW_SET, zpw)); return zebra_send_pw(zclient, ZEBRA_PW_SET, zpw)
== ZCLIENT_SEND_FAILURE;
} }
int int
@ -321,7 +335,8 @@ kmpw_unset(struct zapi_pw *zpw)
debug_zebra_out("pseudowire %s nexthop %s (unset)", debug_zebra_out("pseudowire %s nexthop %s (unset)",
zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop)); zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop));
return (zebra_send_pw(zclient, ZEBRA_PW_UNSET, zpw)); return zebra_send_pw(zclient, ZEBRA_PW_UNSET, zpw)
== ZCLIENT_SEND_FAILURE;
} }
void void

View File

@ -372,8 +372,8 @@ stream_failure:
} }
/* Send simple Zebra message. */ /* Send simple Zebra message. */
static int zebra_message_send(struct zclient *zclient, int command, static enum zclient_send_status zebra_message_send(struct zclient *zclient,
vrf_id_t vrf_id) int command, vrf_id_t vrf_id)
{ {
struct stream *s; struct stream *s;
@ -387,7 +387,7 @@ static int zebra_message_send(struct zclient *zclient, int command,
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
int zclient_send_hello(struct zclient *zclient) enum zclient_send_status zclient_send_hello(struct zclient *zclient)
{ {
struct stream *s; struct stream *s;
@ -413,11 +413,13 @@ int zclient_send_hello(struct zclient *zclient)
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
return 0; return ZCLIENT_SEND_SUCCESS;
} }
int zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi, enum zclient_send_status zclient_send_vrf_label(struct zclient *zclient,
mpls_label_t label, enum lsp_types_t ltype) vrf_id_t vrf_id, afi_t afi,
mpls_label_t label,
enum lsp_types_t ltype)
{ {
struct stream *s; struct stream *s;
@ -567,7 +569,8 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)
} }
} }
int zclient_send_router_id_update(struct zclient *zclient, enum zclient_send_status
zclient_send_router_id_update(struct zclient *zclient,
zebra_message_types_t type, afi_t afi, zebra_message_types_t type, afi_t afi,
vrf_id_t vrf_id) vrf_id_t vrf_id)
{ {
@ -580,7 +583,8 @@ int zclient_send_router_id_update(struct zclient *zclient,
} }
/* Send request to zebra daemon to start or stop RA. */ /* Send request to zebra daemon to start or stop RA. */
int zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id, enum zclient_send_status
zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
struct interface *ifp, int enable, struct interface *ifp, int enable,
int ra_interval) int ra_interval)
{ {
@ -588,7 +592,7 @@ int zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
/* If not connected to the zebra yet. */ /* If not connected to the zebra yet. */
if (zclient->sock < 0) if (zclient->sock < 0)
return -1; return ZCLIENT_SEND_FAILURE;
/* Form and send message. */ /* Form and send message. */
s = zclient->obuf; s = zclient->obuf;
@ -607,13 +611,14 @@ int zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
int zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id, enum zclient_send_status
zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
struct interface *ifp, bool down) struct interface *ifp, bool down)
{ {
struct stream *s; struct stream *s;
if (zclient->sock < 0) if (zclient->sock < 0)
return -1; return ZCLIENT_SEND_FAILURE;
s = zclient->obuf; s = zclient->obuf;
stream_reset(s); stream_reset(s);
@ -720,9 +725,9 @@ static int zclient_connect(struct thread *t)
return zclient_start(zclient); return zclient_start(zclient);
} }
int zclient_send_rnh(struct zclient *zclient, int command, enum zclient_send_status zclient_send_rnh(struct zclient *zclient, int command,
const struct prefix *p, bool exact_match, const struct prefix *p,
vrf_id_t vrf_id) bool exact_match, vrf_id_t vrf_id)
{ {
struct stream *s; struct stream *s;
@ -1031,7 +1036,8 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
return 0; return 0;
} }
int zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg) enum zclient_send_status zclient_nhg_send(struct zclient *zclient, int cmd,
struct zapi_nhg *api_nhg)
{ {
api_nhg->proto = zclient->redist_default; api_nhg->proto = zclient->redist_default;
@ -1764,7 +1770,8 @@ stream_failure:
* then set/unset redist[type] in the client handle (a struct zserv) for the * then set/unset redist[type] in the client handle (a struct zserv) for the
* sending client * sending client
*/ */
int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi, enum zclient_send_status
zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi,
int type, unsigned short instance, vrf_id_t vrf_id) int type, unsigned short instance, vrf_id_t vrf_id)
{ {
struct stream *s; struct stream *s;
@ -1782,8 +1789,9 @@ int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi,
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
int zebra_redistribute_default_send(int command, struct zclient *zclient, enum zclient_send_status
afi_t afi, vrf_id_t vrf_id) zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
vrf_id_t vrf_id)
{ {
struct stream *s; struct stream *s;
@ -2574,8 +2582,10 @@ stream_failure:
* @param base Base for the label chunk. if MPLS_LABEL_BASE_ANY we do not care * @param base Base for the label chunk. if MPLS_LABEL_BASE_ANY we do not care
* @result 0 on success, -1 otherwise * @result 0 on success, -1 otherwise
*/ */
int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep, enum zclient_send_status zclient_send_get_label_chunk(struct zclient *zclient,
uint32_t chunk_size, uint32_t base) uint8_t keep,
uint32_t chunk_size,
uint32_t base)
{ {
struct stream *s; struct stream *s;
@ -2583,7 +2593,7 @@ int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
zlog_debug("Getting Label Chunk"); zlog_debug("Getting Label Chunk");
if (zclient->sock < 0) if (zclient->sock < 0)
return -1; return ZCLIENT_SEND_FAILURE;
s = zclient->obuf; s = zclient->obuf;
stream_reset(s); stream_reset(s);
@ -2799,7 +2809,7 @@ int tm_table_manager_connect(struct zclient *zclient)
zlog_debug("Connecting to Table Manager"); zlog_debug("Connecting to Table Manager");
if (zclient->sock < 0) if (zclient->sock < 0)
return -1; return ZCLIENT_SEND_FAILURE;
/* send request */ /* send request */
s = zclient->obuf; s = zclient->obuf;
@ -2815,7 +2825,7 @@ int tm_table_manager_connect(struct zclient *zclient)
stream_putw_at(s, 0, stream_get_endp(s)); stream_putw_at(s, 0, stream_get_endp(s));
ret = zclient_send_message(zclient); ret = zclient_send_message(zclient);
if (ret < 0) if (ret == ZCLIENT_SEND_FAILURE)
return -1; return -1;
if (zclient_debug) if (zclient_debug)
@ -2940,14 +2950,17 @@ int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
/* Put length at the first point of the stream. */ /* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s)); stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient); if (zclient_send_message(zclient) == ZCLIENT_SEND_FAILURE)
return -1;
return 0;
} }
int zebra_send_sr_policy(struct zclient *zclient, int cmd, enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient, int cmd,
struct zapi_sr_policy *zp) struct zapi_sr_policy *zp)
{ {
if (zapi_sr_policy_encode(zclient->obuf, cmd, zp) < 0) if (zapi_sr_policy_encode(zclient->obuf, cmd, zp) < 0)
return -1; return ZCLIENT_SEND_FAILURE;
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
@ -3029,11 +3042,11 @@ stream_failure:
return -1; return -1;
} }
int zebra_send_mpls_labels(struct zclient *zclient, int cmd, enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
struct zapi_labels *zl) int cmd, struct zapi_labels *zl)
{ {
if (zapi_labels_encode(zclient->obuf, cmd, zl) < 0) if (zapi_labels_encode(zclient->obuf, cmd, zl) < 0)
return -1; return ZCLIENT_SEND_FAILURE;
return zclient_send_message(zclient); return zclient_send_message(zclient);
} }
@ -3194,7 +3207,8 @@ stream_failure:
return -1; return -1;
} }
int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw) enum zclient_send_status zebra_send_pw(struct zclient *zclient, int command,
struct zapi_pw *pw)
{ {
struct stream *s; struct stream *s;
@ -3220,7 +3234,7 @@ int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw)
break; break;
default: default:
flog_err(EC_LIB_ZAPI_ENCODE, "%s: unknown af", __func__); flog_err(EC_LIB_ZAPI_ENCODE, "%s: unknown af", __func__);
return -1; return ZCLIENT_SEND_FAILURE;
} }
/* Put labels */ /* Put labels */
@ -3289,7 +3303,8 @@ stream_failure:
return; return;
} }
int zclient_send_mlag_register(struct zclient *client, uint32_t bit_map) enum zclient_send_status zclient_send_mlag_register(struct zclient *client,
uint32_t bit_map)
{ {
struct stream *s; struct stream *s;
@ -3303,12 +3318,13 @@ int zclient_send_mlag_register(struct zclient *client, uint32_t bit_map)
return zclient_send_message(client); return zclient_send_message(client);
} }
int zclient_send_mlag_deregister(struct zclient *client) enum zclient_send_status zclient_send_mlag_deregister(struct zclient *client)
{ {
return zebra_message_send(client, ZEBRA_MLAG_CLIENT_UNREGISTER, VRF_DEFAULT); return zebra_message_send(client, ZEBRA_MLAG_CLIENT_UNREGISTER, VRF_DEFAULT);
} }
int zclient_send_mlag_data(struct zclient *client, struct stream *client_s) enum zclient_send_status zclient_send_mlag_data(struct zclient *client,
struct stream *client_s)
{ {
struct stream *s; struct stream *s;
@ -3344,8 +3360,9 @@ static void zclient_mlag_handle_msg(ZAPI_CALLBACK_ARGS)
* Send an OPAQUE message, contents opaque to zebra. The message header * Send an OPAQUE message, contents opaque to zebra. The message header
* is a message subtype. * is a message subtype.
*/ */
int zclient_send_opaque(struct zclient *zclient, uint32_t type, enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
const uint8_t *data, size_t datasize) uint32_t type, const uint8_t *data,
size_t datasize)
{ {
struct stream *s; struct stream *s;
uint16_t flags = 0; uint16_t flags = 0;
@ -3353,7 +3370,7 @@ int zclient_send_opaque(struct zclient *zclient, uint32_t type,
/* Check buffer size */ /* Check buffer size */
if (STREAM_SIZE(zclient->obuf) < if (STREAM_SIZE(zclient->obuf) <
(ZEBRA_HEADER_SIZE + sizeof(type) + datasize)) (ZEBRA_HEADER_SIZE + sizeof(type) + datasize))
return -1; return ZCLIENT_SEND_FAILURE;
s = zclient->obuf; s = zclient->obuf;
stream_reset(s); stream_reset(s);
@ -3377,7 +3394,8 @@ int zclient_send_opaque(struct zclient *zclient, uint32_t type,
* Send an OPAQUE message to a specific zclient. The contents are opaque * Send an OPAQUE message to a specific zclient. The contents are opaque
* to zebra. * to zebra.
*/ */
int zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type, enum zclient_send_status
zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
uint8_t proto, uint16_t instance, uint8_t proto, uint16_t instance,
uint32_t session_id, const uint8_t *data, uint32_t session_id, const uint8_t *data,
size_t datasize) size_t datasize)
@ -3388,7 +3406,7 @@ int zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
/* Check buffer size */ /* Check buffer size */
if (STREAM_SIZE(zclient->obuf) < if (STREAM_SIZE(zclient->obuf) <
(ZEBRA_HEADER_SIZE + sizeof(struct zapi_opaque_msg) + datasize)) (ZEBRA_HEADER_SIZE + sizeof(struct zapi_opaque_msg) + datasize))
return -1; return ZCLIENT_SEND_FAILURE;
s = zclient->obuf; s = zclient->obuf;
stream_reset(s); stream_reset(s);
@ -3444,7 +3462,8 @@ stream_failure:
/* /*
* Send a registration request for opaque messages with a specified subtype. * Send a registration request for opaque messages with a specified subtype.
*/ */
int zclient_register_opaque(struct zclient *zclient, uint32_t type) enum zclient_send_status zclient_register_opaque(struct zclient *zclient,
uint32_t type)
{ {
struct stream *s; struct stream *s;
@ -3470,7 +3489,8 @@ int zclient_register_opaque(struct zclient *zclient, uint32_t type)
/* /*
* Send an un-registration request for a specified opaque subtype. * Send an un-registration request for a specified opaque subtype.
*/ */
int zclient_unregister_opaque(struct zclient *zclient, uint32_t type) enum zclient_send_status zclient_unregister_opaque(struct zclient *zclient,
uint32_t type)
{ {
struct stream *s; struct stream *s;
@ -3945,7 +3965,7 @@ static void zclient_event(enum event event, struct zclient *zclient)
} }
} }
int zclient_interface_set_master(struct zclient *client, enum zclient_send_status zclient_interface_set_master(struct zclient *client,
struct interface *master, struct interface *master,
struct interface *slave) struct interface *slave)
{ {
@ -3968,14 +3988,15 @@ int zclient_interface_set_master(struct zclient *client,
/* /*
* Send capabilities message to zebra * Send capabilities message to zebra
*/ */
int32_t zclient_capabilities_send(uint32_t cmd, struct zclient *zclient, enum zclient_send_status zclient_capabilities_send(uint32_t cmd,
struct zclient *zclient,
struct zapi_cap *api) struct zapi_cap *api)
{ {
struct stream *s; struct stream *s;
if (zclient == NULL) if (zclient == NULL)
return -1; return ZCLIENT_SEND_FAILURE;
s = zclient->obuf; s = zclient->obuf;
stream_reset(s); stream_reset(s);
@ -4034,7 +4055,8 @@ stream_failure:
return 0; return 0;
} }
int zclient_send_neigh_discovery_req(struct zclient *zclient, enum zclient_send_status
zclient_send_neigh_discovery_req(struct zclient *zclient,
const struct interface *ifp, const struct interface *ifp,
const struct prefix *p) const struct prefix *p)
{ {

View File

@ -772,31 +772,33 @@ extern void redist_del_all_instances(struct redist_proto *red);
* we have installed and play some special games * we have installed and play some special games
* to get them both installed. * to get them both installed.
*/ */
extern int zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, extern enum zclient_send_status
afi_t afi, mpls_label_t label, zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi,
enum lsp_types_t ltype); mpls_label_t label, enum lsp_types_t ltype);
extern void zclient_send_reg_requests(struct zclient *, vrf_id_t); extern void zclient_send_reg_requests(struct zclient *, vrf_id_t);
extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t); extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t);
extern int zclient_send_router_id_update(struct zclient *zclient, extern enum zclient_send_status
zclient_send_router_id_update(struct zclient *zclient,
zebra_message_types_t type, afi_t afi, zebra_message_types_t type, afi_t afi,
vrf_id_t vrf_id); vrf_id_t vrf_id);
extern int zclient_send_interface_radv_req(struct zclient *zclient, extern enum zclient_send_status
vrf_id_t vrf_id, zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
struct interface *ifp, int enable, struct interface *ifp, int enable,
int ra_interval); int ra_interval);
extern int zclient_send_interface_protodown(struct zclient *zclient, extern enum zclient_send_status
vrf_id_t vrf_id, zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
struct interface *ifp, bool down); struct interface *ifp, bool down);
/* Send redistribute command to zebra daemon. Do not update zclient state. */ /* Send redistribute command to zebra daemon. Do not update zclient state. */
extern int zebra_redistribute_send(int command, struct zclient *, afi_t, extern enum zclient_send_status
int type, unsigned short instance, zebra_redistribute_send(int command, struct zclient *, afi_t, int type,
vrf_id_t vrf_id); unsigned short instance, vrf_id_t vrf_id);
extern int zebra_redistribute_default_send(int command, struct zclient *zclient, extern enum zclient_send_status
afi_t afi, vrf_id_t vrf_id); zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
vrf_id_t vrf_id);
/* Send route notify request to zebra */ /* Send route notify request to zebra */
extern int zebra_route_notify_send(int command, struct zclient *zclient, extern int zebra_route_notify_send(int command, struct zclient *zclient,
@ -874,8 +876,8 @@ extern int zclient_read_header(struct stream *s, int sock, uint16_t *size,
*/ */
extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr); extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr);
extern int zclient_interface_set_master(struct zclient *client, extern enum zclient_send_status
struct interface *master, zclient_interface_set_master(struct zclient *client, struct interface *master,
struct interface *slave); struct interface *slave);
extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t); extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
extern struct connected *zebra_interface_address_read(int, struct stream *, extern struct connected *zebra_interface_address_read(int, struct stream *,
@ -891,7 +893,8 @@ extern struct interface *zebra_interface_link_params_read(struct stream *s,
vrf_id_t vrf_id); vrf_id_t vrf_id);
extern size_t zebra_interface_link_params_write(struct stream *, extern size_t zebra_interface_link_params_write(struct stream *,
struct interface *); struct interface *);
extern int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep, extern enum zclient_send_status
zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
uint32_t chunk_size, uint32_t base); uint32_t chunk_size, uint32_t base);
extern int lm_label_manager_connect(struct zclient *zclient, int async); extern int lm_label_manager_connect(struct zclient *zclient, int async);
@ -906,7 +909,8 @@ extern int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start, extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
uint32_t end); uint32_t end);
extern int zebra_send_sr_policy(struct zclient *zclient, int cmd, extern enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient,
int cmd,
struct zapi_sr_policy *zp); struct zapi_sr_policy *zp);
extern int zapi_sr_policy_encode(struct stream *s, int cmd, extern int zapi_sr_policy_encode(struct stream *s, int cmd,
struct zapi_sr_policy *zp); struct zapi_sr_policy *zp);
@ -914,22 +918,23 @@ extern int zapi_sr_policy_decode(struct stream *s, struct zapi_sr_policy *zp);
extern int zapi_sr_policy_notify_status_decode(struct stream *s, extern int zapi_sr_policy_notify_status_decode(struct stream *s,
struct zapi_sr_policy *zp); struct zapi_sr_policy *zp);
extern int zebra_send_mpls_labels(struct zclient *zclient, int cmd, extern enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
int cmd,
struct zapi_labels *zl); struct zapi_labels *zl);
extern int zapi_labels_encode(struct stream *s, int cmd, extern int zapi_labels_encode(struct stream *s, int cmd,
struct zapi_labels *zl); struct zapi_labels *zl);
extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl); extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl);
extern int zebra_send_pw(struct zclient *zclient, int command, extern enum zclient_send_status zebra_send_pw(struct zclient *zclient,
struct zapi_pw *pw); int command, struct zapi_pw *pw);
extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS, extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS,
struct zapi_pw_status *pw); struct zapi_pw_status *pw);
extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *, extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *,
struct zapi_route *); struct zapi_route *);
extern int zclient_send_rnh(struct zclient *zclient, int command, extern enum zclient_send_status
const struct prefix *p, bool exact_match, zclient_send_rnh(struct zclient *zclient, int command, const struct prefix *p,
vrf_id_t vrf_id); bool exact_match, vrf_id_t vrf_id);
int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh, int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
uint32_t api_flags, uint32_t api_message); uint32_t api_flags, uint32_t api_message);
extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *); extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);
@ -952,8 +957,8 @@ bool zapi_ipset_notify_decode(struct stream *s,
extern int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg); extern int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
extern int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg); extern int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
extern int zclient_nhg_send(struct zclient *zclient, int cmd, extern enum zclient_send_status
struct zapi_nhg *api_nhg); zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg);
#define ZEBRA_IPSET_NAME_SIZE 32 #define ZEBRA_IPSET_NAME_SIZE 32
@ -980,7 +985,8 @@ const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error); extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
/* Encode and decode restart capabilities */ /* Encode and decode restart capabilities */
extern int32_t zclient_capabilities_send(uint32_t cmd, struct zclient *zclient, extern enum zclient_send_status
zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
struct zapi_cap *api); struct zapi_cap *api);
extern int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api); extern int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api);
@ -994,11 +1000,12 @@ static inline void zapi_route_set_blackhole(struct zapi_route *api,
SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP); SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
}; };
extern int zclient_send_mlag_register(struct zclient *client, extern enum zclient_send_status
uint32_t bit_map); zclient_send_mlag_register(struct zclient *client, uint32_t bit_map);
extern int zclient_send_mlag_deregister(struct zclient *client); extern enum zclient_send_status
zclient_send_mlag_deregister(struct zclient *client);
extern int zclient_send_mlag_data(struct zclient *client, extern enum zclient_send_status zclient_send_mlag_data(struct zclient *client,
struct stream *client_s); struct stream *client_s);
/* /*
@ -1009,10 +1016,12 @@ extern int zclient_send_mlag_data(struct zclient *client,
* below to avoid sub-type collisions. Clients use the registration * below to avoid sub-type collisions. Clients use the registration
* apis to manage the specific opaque subtypes they want to receive. * apis to manage the specific opaque subtypes they want to receive.
*/ */
int zclient_send_opaque(struct zclient *zclient, uint32_t type, enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
const uint8_t *data, size_t datasize); uint32_t type, const uint8_t *data,
size_t datasize);
int zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type, enum zclient_send_status
zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
uint8_t proto, uint16_t instance, uint8_t proto, uint16_t instance,
uint32_t session_id, const uint8_t *data, uint32_t session_id, const uint8_t *data,
size_t datasize); size_t datasize);
@ -1045,8 +1054,10 @@ struct zapi_opaque_reg_info {
/* Decode incoming opaque */ /* Decode incoming opaque */
int zclient_opaque_decode(struct stream *msg, struct zapi_opaque_msg *info); int zclient_opaque_decode(struct stream *msg, struct zapi_opaque_msg *info);
int zclient_register_opaque(struct zclient *zclient, uint32_t type); enum zclient_send_status zclient_register_opaque(struct zclient *zclient,
int zclient_unregister_opaque(struct zclient *zclient, uint32_t type); uint32_t type);
enum zclient_send_status zclient_unregister_opaque(struct zclient *zclient,
uint32_t type);
int zapi_opaque_reg_decode(struct stream *msg, int zapi_opaque_reg_decode(struct stream *msg,
struct zapi_opaque_reg_info *info); struct zapi_opaque_reg_info *info);
@ -1072,9 +1083,10 @@ enum zapi_opaque_registry {
/* Send the hello message. /* Send the hello message.
* Returns 0 for success or -1 on an I/O error. * Returns 0 for success or -1 on an I/O error.
*/ */
extern int zclient_send_hello(struct zclient *client); extern enum zclient_send_status zclient_send_hello(struct zclient *client);
extern int zclient_send_neigh_discovery_req(struct zclient *zclient, extern enum zclient_send_status
zclient_send_neigh_discovery_req(struct zclient *zclient,
const struct interface *ifp, const struct interface *ifp,
const struct prefix *p); const struct prefix *p);

View File

@ -1917,7 +1917,7 @@ int ospf_zebra_label_manager_connect(void)
set_nonblocking(zclient_sync->sock); set_nonblocking(zclient_sync->sock);
/* Send hello to notify zebra this is a synchronous client */ /* Send hello to notify zebra this is a synchronous client */
if (zclient_send_hello(zclient_sync) < 0) { if (zclient_send_hello(zclient_sync) == ZCLIENT_SEND_FAILURE) {
zlog_warn("%s: failed sending hello for synchronous zclient!", zlog_warn("%s: failed sending hello for synchronous zclient!",
__func__); __func__);
close(zclient_sync->sock); close(zclient_sync->sock);

View File

@ -476,8 +476,8 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg)
break; break;
} }
if (zclient_send_rnh(zclient, command, &p, if (zclient_send_rnh(zclient, command, &p, false, nhop->vrf_id)
false, nhop->vrf_id) < 0) { == ZCLIENT_SEND_FAILURE) {
zlog_warn("%s: Failure to send nexthop to zebra", __func__); zlog_warn("%s: Failure to send nexthop to zebra", __func__);
} }
} }

View File

@ -55,7 +55,7 @@ void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient,
p = &(pnc->rpf.rpf_addr); p = &(pnc->rpf.rpf_addr);
ret = zclient_send_rnh(zclient, command, p, false, pim->vrf_id); ret = zclient_send_rnh(zclient, command, p, false, pim->vrf_id);
if (ret < 0) if (ret == ZCLIENT_SEND_FAILURE)
zlog_warn("sendmsg_nexthop: zclient_send_message() failed"); zlog_warn("sendmsg_nexthop: zclient_send_message() failed");
if (PIM_DEBUG_PIM_NHT) if (PIM_DEBUG_PIM_NHT)

View File

@ -61,7 +61,7 @@ static int zclient_lookup_connect(struct thread *t)
zlookup->fail = 0; /* reset counter on connection */ zlookup->fail = 0; /* reset counter on connection */
} }
if (zclient_send_hello(zlookup) < 0) { if (zclient_send_hello(zlookup) == ZCLIENT_SEND_FAILURE) {
if (close(zlookup->sock)) { if (close(zlookup->sock)) {
zlog_warn("%s: closing fd=%d: errno=%d %s", __func__, zlog_warn("%s: closing fd=%d: errno=%d %s", __func__,
zlookup->sock, errno, safe_strerror(errno)); zlookup->sock, errno, safe_strerror(errno));

View File

@ -211,9 +211,10 @@ int sharp_install_lsps_helper(bool install_p, bool update_p,
cmd = ZEBRA_MPLS_LABELS_DELETE; cmd = ZEBRA_MPLS_LABELS_DELETE;
} }
ret = zebra_send_mpls_labels(zclient, cmd, &zl); if (zebra_send_mpls_labels(zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE)
return -1;
return ret; return 0;
} }
enum where_to_restart { enum where_to_restart {
@ -590,7 +591,8 @@ void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,
command = ZEBRA_IMPORT_ROUTE_UNREGISTER; command = ZEBRA_IMPORT_ROUTE_UNREGISTER;
} }
if (zclient_send_rnh(zclient, command, p, connected, vrf_id) < 0) if (zclient_send_rnh(zclient, command, p, connected, vrf_id)
== ZCLIENT_SEND_FAILURE)
zlog_warn("%s: Failure to send nexthop to zebra", __func__); zlog_warn("%s: Failure to send nexthop to zebra", __func__);
} }
@ -776,7 +778,7 @@ void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance,
ret = zclient_send_opaque_unicast(zclient, type, proto, ret = zclient_send_opaque_unicast(zclient, type, proto,
instance, session_id, instance, session_id,
buf, sizeof(buf)); buf, sizeof(buf));
if (ret < 0) { if (ret == ZCLIENT_SEND_FAILURE) {
zlog_debug("%s: send_opaque() failed => %d", zlog_debug("%s: send_opaque() failed => %d",
__func__, ret); __func__, ret);
break; break;

View File

@ -331,7 +331,8 @@ void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh,
static_nht_hash_free(nhtd); static_nht_hash_free(nhtd);
} }
if (zclient_send_rnh(zclient, cmd, &p, false, nh->nh_vrf_id) < 0) if (zclient_send_rnh(zclient, cmd, &p, false, nh->nh_vrf_id)
== ZCLIENT_SEND_FAILURE)
zlog_warn("%s: Failure to send nexthop to zebra", __func__); zlog_warn("%s: Failure to send nexthop to zebra", __func__);
} }
/* /*

View File

@ -179,14 +179,13 @@ void vrrp_zebra_radv_set(struct vrrp_router *r, bool enable)
enable, VRRP_RADV_INT); enable, VRRP_RADV_INT);
} }
int vrrp_zclient_send_interface_protodown(struct interface *ifp, bool down) void vrrp_zclient_send_interface_protodown(struct interface *ifp, bool down)
{ {
DEBUGD(&vrrp_dbg_zebra, DEBUGD(&vrrp_dbg_zebra,
VRRP_LOGPFX "Requesting Zebra to set %s protodown %s", ifp->name, VRRP_LOGPFX "Requesting Zebra to set %s protodown %s", ifp->name,
down ? "on" : "off"); down ? "on" : "off");
return zclient_send_interface_protodown(zclient, ifp->vrf_id, ifp, zclient_send_interface_protodown(zclient, ifp->vrf_id, ifp, down);
down);
} }
void vrrp_zebra_init(void) void vrrp_zebra_init(void)

View File

@ -26,7 +26,7 @@
extern void vrrp_zebra_init(void); extern void vrrp_zebra_init(void);
extern void vrrp_zebra_radv_set(struct vrrp_router *r, bool enable); extern void vrrp_zebra_radv_set(struct vrrp_router *r, bool enable);
extern int vrrp_zclient_send_interface_protodown(struct interface *ifp, extern void vrrp_zclient_send_interface_protodown(struct interface *ifp,
bool down); bool down);
extern int vrrp_ifp_create(struct interface *ifp); extern int vrrp_ifp_create(struct interface *ifp);