bgp_encode_pbr_rule_action(s, pbra, pbr);
stream_putw_at(s, 0, stream_get_endp(s));
- if ((zclient_send_message(zclient) != -1) && install) {
+ if ((zclient_send_message(zclient) != ZCLIENT_SEND_FAILURE)
+ && install) {
if (!pbr)
pbra->install_in_progress = true;
else
bgp_encode_pbr_ipset_match(s, pbrim);
stream_putw_at(s, 0, stream_get_endp(s));
- if ((zclient_send_message(zclient) != -1) && install)
+ if ((zclient_send_message(zclient) != ZCLIENT_SEND_FAILURE) && install)
pbrim->install_in_progress = true;
}
bgp_encode_pbr_ipset_entry_match(s, pbrime);
stream_putw_at(s, 0, stream_get_endp(s));
- if ((zclient_send_message(zclient) != -1) && install)
+ if ((zclient_send_message(zclient) != ZCLIENT_SEND_FAILURE) && install)
pbrime->install_in_progress = true;
}
stream_putw_at(s, 0, stream_get_endp(s));
ret = zclient_send_message(zclient);
if (install) {
- if (ret != -1)
+ if (ret != ZCLIENT_SEND_FAILURE)
pba->refcnt++;
else
pbm->install_iptable_in_progress = true;
vrf_id_t vrf_id)
{
struct stream *s;
- int ret;
+ enum zclient_send_status ret;
/* Check socket. */
if (!zclient || zclient->sock < 0) {
ret = zclient_send_message(zclient);
- if (ret < 0) {
+ if (ret == ZCLIENT_SEND_FAILURE) {
if (bfd_debug)
zlog_debug(
"bfd_client_sendmsg %ld: zclient_send_message() failed",
stream_putw_at(s, 0, stream_get_endp(s));
/* Send message to zebra. */
- if (zclient_send_message(zc) == -1) {
+ if (zclient_send_message(zc) == ZCLIENT_SEND_FAILURE) {
if (bfd_debug)
zlog_debug("%s: zclient_send_message failed", __func__);
return -1;
return sock;
}
-static int zclient_failed(struct zclient *zclient)
+static enum zclient_send_status zclient_failed(struct zclient *zclient)
{
zclient->fail++;
zclient_stop(zclient);
zclient_event(ZCLIENT_CONNECT, zclient);
- return -1;
+ return ZCLIENT_SEND_FAILURE;
}
static int zclient_flush_data(struct thread *thread)
}
/*
- * -1 is a failure
- * 0 means we sent
- * 1 means we are buffering
+ * Returns:
+ * ZCLIENT_SEND_FAILED - is a failure
+ * ZCLIENT_SEND_SUCCESS - means we sent data to zebra
+ * ZCLIENT_SEND_BUFFERED - means we are buffering
*/
-int zclient_send_message(struct zclient *zclient)
+enum zclient_send_status zclient_send_message(struct zclient *zclient)
{
if (zclient->sock < 0)
- return -1;
+ return ZCLIENT_SEND_FAILURE;
switch (buffer_write(zclient->wb, zclient->sock,
STREAM_DATA(zclient->obuf),
stream_get_endp(zclient->obuf))) {
return zclient_failed(zclient);
case BUFFER_EMPTY:
THREAD_OFF(zclient->t_write);
- return 0;
- break;
+ return ZCLIENT_SEND_SUCCESS;
case BUFFER_PENDING:
thread_add_write(zclient->master, zclient_flush_data, zclient,
zclient->sock, &zclient->t_write);
- return 1;
- break;
+ return ZCLIENT_SEND_BUFFERED;
}
/* should not get here */
- return 0;
+ return ZCLIENT_SEND_SUCCESS;
}
/*
*
* XXX: No attention paid to alignment.
*/
-int zclient_route_send(uint8_t cmd, struct zclient *zclient,
- struct zapi_route *api)
+enum zclient_send_status
+zclient_route_send(uint8_t cmd, struct zclient *zclient, struct zapi_route *api)
{
if (zapi_route_encode(cmd, zclient->obuf, api) < 0)
- return -1;
+ return ZCLIENT_SEND_FAILURE;
return zclient_send_message(zclient);
}
ZAPI_IPTABLE_FAIL_REMOVE,
};
+enum zclient_send_status {
+ ZCLIENT_SEND_FAILURE = -1,
+ ZCLIENT_SEND_SUCCESS = 0,
+ ZCLIENT_SEND_BUFFERED = 1
+};
+
static inline const char *
zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note)
{
* 0 data was successfully sent
* 1 data was buffered for future usage
*/
-extern int zclient_send_message(struct zclient *);
+extern enum zclient_send_status zclient_send_message(struct zclient *);
/* create header for command, length to be filled in by user later */
extern void zclient_create_header(struct stream *, uint16_t, vrf_id_t);
extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS,
struct zapi_pw_status *pw);
-extern int zclient_route_send(uint8_t, struct zclient *, struct zapi_route *);
+extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *,
+ struct zapi_route *);
extern int zclient_send_rnh(struct zclient *zclient, int command,
const struct prefix *p, bool exact_match,
vrf_id_t vrf_id);
else
ret = zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
- if (ret < 0)
+ if (ret == ZCLIENT_SEND_FAILURE)
flog_err(EC_LIB_ZAPI_SOCKET,
"zclient_route_send() %s failed: %s",
(type == REM ? "delete" : "add"),
api.backup_nexthop_num = i;
}
- if (zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api) == 1)
+ if (zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api)
+ == ZCLIENT_SEND_BUFFERED)
return true;
else
return false;
api.instance = instance;
memcpy(&api.prefix, p, sizeof(*p));
- if (zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api) == 1)
+ if (zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api)
+ == ZCLIENT_SEND_BUFFERED)
return true;
else
return false;
return;
}
}
-
- return;
}
void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
return;
}
}
-
- return;
}
void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id,
wb.instance, wb.nhgid, wb.nhg,
wb.backup_nhg, wb.routes);
return;
- break;
case SHARP_DELETE_ROUTES_RESTART:
sharp_remove_routes_restart(&wb.p, wb.count, wb.vrf_id,
wb.instance, wb.routes);
return;
- break;
}
}