]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: Convert all usage of zclient_send_message to new enum
authorDonald Sharp <sharpd@nvidia.com>
Wed, 11 Nov 2020 19:14:37 +0000 (14:14 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Sun, 15 Nov 2020 20:04:52 +0000 (15:04 -0500)
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>
16 files changed:
bgpd/bgp_labelpool.c
bgpd/bgp_nht.c
bgpd/bgp_zebra.c
isisd/isis_zebra.c
ldpd/lde.c
ldpd/ldp_zebra.c
lib/zclient.c
lib/zclient.h
ospfd/ospf_zebra.c
pbrd/pbr_zebra.c
pimd/pim_nht.c
pimd/pim_zlookup.c
sharpd/sharp_zebra.c
staticd/static_zebra.c
vrrpd/vrrp_zebra.c
vrrpd/vrrp_zebra.h

index feda0328bd5af13228421d60914f716df65f9d71..e8d8167c35f1f7477d42708b2023b3f068a8767c 100644 (file)
@@ -392,8 +392,9 @@ void bgp_lp_get(
        if (lp_fifo_count(&lp->requests) > lp->pending_count) {
                if (!zclient || zclient->sock < 0)
                        return;
-               if (!zclient_send_get_label_chunk(zclient, 0, LP_CHUNK_SIZE,
-                                                 MPLS_LABEL_BASE_ANY))
+               if (zclient_send_get_label_chunk(zclient, 0, LP_CHUNK_SIZE,
+                                                MPLS_LABEL_BASE_ANY)
+                   == ZCLIENT_SEND_FAILURE)
                        lp->pending_count += LP_CHUNK_SIZE;
        }
 }
index 64b10c025219e69464fb610b4385633e1fb00835..63a7d3d57bde79cc99e896de0b0445c00f07fe51 100644 (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,
                               bnc->bgp->vrf_id);
        /* TBD: handle the failure */
-       if (ret < 0)
+       if (ret == ZCLIENT_SEND_FAILURE)
                flog_warn(EC_BGP_ZEBRA_SEND,
                          "sendmsg_nexthop: zclient_send_message() failed");
 
index 780780fd1ffdac44ead12e9fc21d8a42be38455c..c29b3222ddf1cfa09aab4d73f3fc9f0d894d2300 100644 (file)
@@ -3319,7 +3319,7 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
        }
 
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
-           < 0) {
+           == ZCLIENT_SEND_FAILURE) {
                zlog_err("error sending capability");
                ret = BGP_GR_FAILURE;
        } 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;
 
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
-           < 0) {
+           == ZCLIENT_SEND_FAILURE) {
                if (BGP_DEBUG(zebra, ZEBRA))
                        zlog_debug("error sending capability");
                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.vrf_id = bgp->vrf_id;
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
-           < 0) {
+           == ZCLIENT_SEND_FAILURE) {
                if (BGP_DEBUG(zebra, ZEBRA))
                        zlog_debug("error sending capability");
                return BGP_GR_FAILURE;
index 8bc56339977bb795495735d4baa903c96fa37520..b9958a669635bb7ce802de33aca82faccaafa46b 100644 (file)
@@ -618,7 +618,7 @@ int isis_zebra_label_manager_connect(void)
        set_nonblocking(zclient_sync->sock);
 
        /* 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!",
                          __func__);
                close(zclient_sync->sock);
index 67b695150e4fe72769f8dff09865ec02b1cd5093..c2e11a0aeed580df8128b63cbef135609bbeefe5 100644 (file)
@@ -2092,7 +2092,7 @@ static void zclient_sync_init(void)
        sock_set_nonblock(zclient_sync->sock);
 
        /* 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!");
                goto retry;
        }
index 3852d8d23b3072d52c0147908f584281d07599f5..df9832a28100bbb761420f38db9b6f566fbc6da1 100644 (file)
@@ -127,8 +127,12 @@ ldp_zebra_opaque_unregister(void)
 int
 ldp_sync_zebra_send_state_update(struct ldp_igp_sync_if_state *state)
 {
-        return zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE,
-               (const uint8_t *) state, sizeof(*state));
+       if (zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE,
+                               (const uint8_t *)state, sizeof(*state))
+           == ZCLIENT_SEND_FAILURE)
+               return -1;
+       else
+               return 0;
 }
 
 static int
@@ -137,8 +141,12 @@ ldp_sync_zebra_send_announce(void)
        struct ldp_igp_sync_announce announce;
        announce.proto = ZEBRA_ROUTE_LDP;
 
-        return zclient_send_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE,
-               (const uint8_t *) &announce, sizeof(announce));
+       if (zclient_send_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE,
+                               (const uint8_t *)&announce, sizeof(announce))
+           == ZCLIENT_SEND_FAILURE)
+               return -1;
+       else
+               return 0;
 }
 
 static int
@@ -272,7 +280,10 @@ ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr)
        znh->label_num = 1;
        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
@@ -293,7 +304,8 @@ kmpw_add(struct zapi_pw *zpw)
        debug_zebra_out("pseudowire %s nexthop %s (add)",
            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
@@ -302,7 +314,8 @@ kmpw_del(struct zapi_pw *zpw)
        debug_zebra_out("pseudowire %s nexthop %s (del)",
            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
@@ -312,7 +325,8 @@ kmpw_set(struct zapi_pw *zpw)
            zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop),
            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
@@ -321,7 +335,8 @@ kmpw_unset(struct zapi_pw *zpw)
        debug_zebra_out("pseudowire %s nexthop %s (unset)",
            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
index 56c131f7e3a60c68bcead6a1061d6dbad517ed87..053014f86dab12b26995fa34f799c3a8221fed49 100644 (file)
@@ -372,8 +372,8 @@ stream_failure:
 }
 
 /* Send simple Zebra message. */
-static int zebra_message_send(struct zclient *zclient, int command,
-                             vrf_id_t vrf_id)
+static enum zclient_send_status zebra_message_send(struct zclient *zclient,
+                                                  int command, vrf_id_t vrf_id)
 {
        struct stream *s;
 
@@ -387,7 +387,7 @@ static int zebra_message_send(struct zclient *zclient, int command,
        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;
 
@@ -413,11 +413,13 @@ int zclient_send_hello(struct zclient *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,
-                          mpls_label_t label, enum lsp_types_t ltype)
+enum zclient_send_status zclient_send_vrf_label(struct zclient *zclient,
+                                               vrf_id_t vrf_id, afi_t afi,
+                                               mpls_label_t label,
+                                               enum lsp_types_t ltype)
 {
        struct stream *s;
 
@@ -567,9 +569,10 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)
        }
 }
 
-int zclient_send_router_id_update(struct zclient *zclient,
-                                 zebra_message_types_t type, afi_t afi,
-                                 vrf_id_t vrf_id)
+enum zclient_send_status
+zclient_send_router_id_update(struct zclient *zclient,
+                             zebra_message_types_t type, afi_t afi,
+                             vrf_id_t vrf_id)
 {
        struct stream *s = zclient->obuf;
        stream_reset(s);
@@ -580,15 +583,16 @@ int zclient_send_router_id_update(struct zclient *zclient,
 }
 
 /* Send request to zebra daemon to start or stop RA. */
-int zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
-                                   struct interface *ifp, int enable,
-                                   int ra_interval)
+enum zclient_send_status
+zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
+                               struct interface *ifp, int enable,
+                               int ra_interval)
 {
        struct stream *s;
 
        /* If not connected to the zebra yet. */
        if (zclient->sock < 0)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        /* Form and send message. */
        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);
 }
 
-int zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
-                                    struct interface *ifp, bool down)
+enum zclient_send_status
+zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
+                                struct interface *ifp, bool down)
 {
        struct stream *s;
 
        if (zclient->sock < 0)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        s = zclient->obuf;
        stream_reset(s);
@@ -720,9 +725,9 @@ static int zclient_connect(struct thread *t)
        return zclient_start(zclient);
 }
 
-int zclient_send_rnh(struct zclient *zclient, int command,
-                    const struct prefix *p, bool exact_match,
-                    vrf_id_t vrf_id)
+enum zclient_send_status zclient_send_rnh(struct zclient *zclient, int command,
+                                         const struct prefix *p,
+                                         bool exact_match, vrf_id_t vrf_id)
 {
        struct stream *s;
 
@@ -1031,7 +1036,8 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
        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;
 
@@ -1764,8 +1770,9 @@ stream_failure:
  * then set/unset redist[type] in the client handle (a struct zserv) for the
  * sending client
  */
-int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi,
-                           int type, unsigned short instance, vrf_id_t vrf_id)
+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)
 {
        struct stream *s;
 
@@ -1782,8 +1789,9 @@ int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi,
        return zclient_send_message(zclient);
 }
 
-int zebra_redistribute_default_send(int command, struct zclient *zclient,
-                                   afi_t afi, vrf_id_t vrf_id)
+enum zclient_send_status
+zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
+                               vrf_id_t vrf_id)
 {
        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
  * @result 0 on success, -1 otherwise
  */
-int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
-                                uint32_t chunk_size, uint32_t base)
+enum zclient_send_status zclient_send_get_label_chunk(struct zclient *zclient,
+                                                     uint8_t keep,
+                                                     uint32_t chunk_size,
+                                                     uint32_t base)
 {
        struct stream *s;
 
@@ -2583,7 +2593,7 @@ int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
                zlog_debug("Getting Label Chunk");
 
        if (zclient->sock < 0)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        s = zclient->obuf;
        stream_reset(s);
@@ -2799,7 +2809,7 @@ int tm_table_manager_connect(struct zclient *zclient)
                zlog_debug("Connecting to Table Manager");
 
        if (zclient->sock < 0)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        /* send request */
        s = zclient->obuf;
@@ -2815,7 +2825,7 @@ int tm_table_manager_connect(struct zclient *zclient)
        stream_putw_at(s, 0, stream_get_endp(s));
 
        ret = zclient_send_message(zclient);
-       if (ret < 0)
+       if (ret == ZCLIENT_SEND_FAILURE)
                return -1;
 
        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. */
        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,
-                        struct zapi_sr_policy *zp)
+enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient, int cmd,
+                                             struct zapi_sr_policy *zp)
 {
        if (zapi_sr_policy_encode(zclient->obuf, cmd, zp) < 0)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
        return zclient_send_message(zclient);
 }
 
@@ -3029,11 +3042,11 @@ stream_failure:
        return -1;
 }
 
-int zebra_send_mpls_labels(struct zclient *zclient, int cmd,
-                          struct zapi_labels *zl)
+enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
+                                               int cmd, struct zapi_labels *zl)
 {
        if (zapi_labels_encode(zclient->obuf, cmd, zl) < 0)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
        return zclient_send_message(zclient);
 }
 
@@ -3194,7 +3207,8 @@ stream_failure:
        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;
 
@@ -3220,7 +3234,7 @@ int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw)
                break;
        default:
                flog_err(EC_LIB_ZAPI_ENCODE, "%s: unknown af", __func__);
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
        }
 
        /* Put labels */
@@ -3289,7 +3303,8 @@ stream_failure:
        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;
 
@@ -3303,12 +3318,13 @@ int zclient_send_mlag_register(struct zclient *client, uint32_t bit_map)
        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);
 }
 
-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;
 
@@ -3344,8 +3360,9 @@ static void zclient_mlag_handle_msg(ZAPI_CALLBACK_ARGS)
  * Send an OPAQUE message, contents opaque to zebra. The message header
  * is a message subtype.
  */
-int zclient_send_opaque(struct zclient *zclient, uint32_t type,
-                       const uint8_t *data, size_t datasize)
+enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
+                                            uint32_t type, const uint8_t *data,
+                                            size_t datasize)
 {
        struct stream *s;
        uint16_t flags = 0;
@@ -3353,7 +3370,7 @@ int zclient_send_opaque(struct zclient *zclient, uint32_t type,
        /* Check buffer size */
        if (STREAM_SIZE(zclient->obuf) <
            (ZEBRA_HEADER_SIZE + sizeof(type) + datasize))
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        s = zclient->obuf;
        stream_reset(s);
@@ -3377,10 +3394,11 @@ int zclient_send_opaque(struct zclient *zclient, uint32_t type,
  * Send an OPAQUE message to a specific zclient. The contents are opaque
  * to zebra.
  */
-int zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
-                               uint8_t proto, uint16_t instance,
-                               uint32_t session_id, const uint8_t *data,
-                               size_t datasize)
+enum zclient_send_status
+zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
+                           uint8_t proto, uint16_t instance,
+                           uint32_t session_id, const uint8_t *data,
+                           size_t datasize)
 {
        struct stream *s;
        uint16_t flags = 0;
@@ -3388,7 +3406,7 @@ int zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
        /* Check buffer size */
        if (STREAM_SIZE(zclient->obuf) <
            (ZEBRA_HEADER_SIZE + sizeof(struct zapi_opaque_msg) + datasize))
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        s = zclient->obuf;
        stream_reset(s);
@@ -3444,7 +3462,8 @@ stream_failure:
 /*
  * 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;
 
@@ -3470,7 +3489,8 @@ int zclient_register_opaque(struct zclient *zclient, uint32_t type)
 /*
  * 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;
 
@@ -3945,9 +3965,9 @@ static void zclient_event(enum event event, struct zclient *zclient)
        }
 }
 
-int zclient_interface_set_master(struct zclient *client,
-                                struct interface *master,
-                                struct interface *slave)
+enum zclient_send_status zclient_interface_set_master(struct zclient *client,
+                                                     struct interface *master,
+                                                     struct interface *slave)
 {
        struct stream *s;
 
@@ -3968,14 +3988,15 @@ int zclient_interface_set_master(struct zclient *client,
 /*
  * Send capabilities message to zebra
  */
-int32_t zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
-                                 struct zapi_cap *api)
+enum zclient_send_status zclient_capabilities_send(uint32_t cmd,
+                                                  struct zclient *zclient,
+                                                  struct zapi_cap *api)
 {
 
        struct stream *s;
 
        if (zclient == NULL)
-               return -1;
+               return ZCLIENT_SEND_FAILURE;
 
        s = zclient->obuf;
        stream_reset(s);
@@ -4034,9 +4055,10 @@ stream_failure:
        return 0;
 }
 
-int zclient_send_neigh_discovery_req(struct zclient *zclient,
-                                    const struct interface *ifp,
-                                    const struct prefix *p)
+enum zclient_send_status
+zclient_send_neigh_discovery_req(struct zclient *zclient,
+                                const struct interface *ifp,
+                                const struct prefix *p)
 {
        struct stream *s;
 
index 52fdfe202cf8a648751aa7b116a67d7709e35163..d4ec0b4d7b9bc9926b40ca718dd9f42126fdcd47 100644 (file)
@@ -772,31 +772,33 @@ extern void redist_del_all_instances(struct redist_proto *red);
  * we have installed and play some special games
  * to get them both installed.
  */
-extern int zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id,
-                                 afi_t afi, mpls_label_t label,
-                                 enum lsp_types_t ltype);
+extern enum zclient_send_status
+zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi,
+                      mpls_label_t label, enum lsp_types_t ltype);
 
 extern void zclient_send_reg_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,
-                                        zebra_message_types_t type, afi_t afi,
-                                        vrf_id_t vrf_id);
-
-extern int zclient_send_interface_radv_req(struct zclient *zclient,
-                                          vrf_id_t vrf_id,
-                                          struct interface *ifp, int enable,
-                                          int ra_interval);
-extern int zclient_send_interface_protodown(struct zclient *zclient,
-                                           vrf_id_t vrf_id,
-                                           struct interface *ifp, bool down);
+extern enum zclient_send_status
+zclient_send_router_id_update(struct zclient *zclient,
+                             zebra_message_types_t type, afi_t afi,
+                             vrf_id_t vrf_id);
+
+extern enum zclient_send_status
+zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
+                               struct interface *ifp, int enable,
+                               int ra_interval);
+extern enum zclient_send_status
+zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
+                                struct interface *ifp, bool down);
 
 /* Send redistribute command to zebra daemon. Do not update zclient state. */
-extern int zebra_redistribute_send(int command, struct zclient *, afi_t,
-                                  int type, unsigned short instance,
-                                  vrf_id_t vrf_id);
+extern enum zclient_send_status
+zebra_redistribute_send(int command, struct zclient *, afi_t, int type,
+                       unsigned short instance, vrf_id_t vrf_id);
 
-extern int zebra_redistribute_default_send(int command, struct zclient *zclient,
-                                          afi_t afi, vrf_id_t vrf_id);
+extern enum zclient_send_status
+zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
+                               vrf_id_t vrf_id);
 
 /* Send route notify request to zebra */
 extern int zebra_route_notify_send(int command, struct zclient *zclient,
@@ -874,9 +876,9 @@ 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 int zclient_interface_set_master(struct zclient *client,
-                                       struct interface *master,
-                                       struct interface *slave);
+extern enum zclient_send_status
+zclient_interface_set_master(struct zclient *client, struct interface *master,
+                            struct interface *slave);
 extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
 extern struct connected *zebra_interface_address_read(int, struct stream *,
                                                      vrf_id_t);
@@ -891,8 +893,9 @@ extern struct interface *zebra_interface_link_params_read(struct stream *s,
                                                          vrf_id_t vrf_id);
 extern size_t zebra_interface_link_params_write(struct stream *,
                                                struct interface *);
-extern int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
-                                       uint32_t chunk_size, uint32_t base);
+extern enum zclient_send_status
+zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
+                            uint32_t chunk_size, uint32_t base);
 
 extern int lm_label_manager_connect(struct zclient *zclient, int async);
 extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
@@ -906,30 +909,32 @@ 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,
                                  uint32_t end);
 
-extern int zebra_send_sr_policy(struct zclient *zclient, int cmd,
-                               struct zapi_sr_policy *zp);
+extern enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient,
+                                                    int cmd,
+                                                    struct zapi_sr_policy *zp);
 extern int zapi_sr_policy_encode(struct stream *s, int cmd,
                                 struct zapi_sr_policy *zp);
 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,
                                               struct zapi_sr_policy *zp);
 
-extern int zebra_send_mpls_labels(struct zclient *zclient, int cmd,
-                                 struct zapi_labels *zl);
+extern enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
+                                                      int cmd,
+                                                      struct zapi_labels *zl);
 extern int zapi_labels_encode(struct stream *s, int cmd,
                              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,
-                        struct zapi_pw *pw);
+extern enum zclient_send_status zebra_send_pw(struct zclient *zclient,
+                                             int command, struct zapi_pw *pw);
 extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS,
                                       struct zapi_pw_status *pw);
 
 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);
+extern enum zclient_send_status
+zclient_send_rnh(struct zclient *zclient, int command, const struct prefix *p,
+                bool exact_match, vrf_id_t vrf_id);
 int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
                        uint32_t api_flags, uint32_t api_message);
 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_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
-extern int zclient_nhg_send(struct zclient *zclient, int cmd,
-                           struct zapi_nhg *api_nhg);
+extern enum zclient_send_status
+zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg);
 
 #define ZEBRA_IPSET_NAME_SIZE   32
 
@@ -980,8 +985,9 @@ const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
 extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
 
 /* Encode and decode restart capabilities */
-extern int32_t zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
-                                        struct zapi_cap *api);
+extern enum zclient_send_status
+zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
+                         struct zapi_cap *api);
 extern int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api);
 
 static inline void zapi_route_set_blackhole(struct zapi_route *api,
@@ -994,12 +1000,13 @@ static inline void zapi_route_set_blackhole(struct zapi_route *api,
        SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
 };
 
-extern int 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_register(struct zclient *client, uint32_t bit_map);
+extern enum zclient_send_status
+zclient_send_mlag_deregister(struct zclient *client);
 
-extern int zclient_send_mlag_data(struct zclient *client,
-                                 struct stream *client_s);
+extern enum zclient_send_status zclient_send_mlag_data(struct zclient *client,
+                                                      struct stream *client_s);
 
 /*
  * Send an OPAQUE message, contents opaque to zebra - but note that
@@ -1009,13 +1016,15 @@ extern int zclient_send_mlag_data(struct zclient *client,
  * below to avoid sub-type collisions. Clients use the registration
  * apis to manage the specific opaque subtypes they want to receive.
  */
-int zclient_send_opaque(struct zclient *zclient, uint32_t type,
-                       const uint8_t *data, size_t datasize);
+enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
+                                            uint32_t type, const uint8_t *data,
+                                            size_t datasize);
 
-int zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
-                               uint8_t proto, uint16_t instance,
-                               uint32_t session_id, const uint8_t *data,
-                               size_t datasize);
+enum zclient_send_status
+zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
+                           uint8_t proto, uint16_t instance,
+                           uint32_t session_id, const uint8_t *data,
+                           size_t datasize);
 
 /* Struct representing the decoded opaque header info */
 struct zapi_opaque_msg {
@@ -1045,8 +1054,10 @@ struct zapi_opaque_reg_info {
 /* Decode incoming opaque */
 int zclient_opaque_decode(struct stream *msg, struct zapi_opaque_msg *info);
 
-int zclient_register_opaque(struct zclient *zclient, uint32_t type);
-int zclient_unregister_opaque(struct zclient *zclient, uint32_t type);
+enum zclient_send_status zclient_register_opaque(struct zclient *zclient,
+                                                uint32_t type);
+enum zclient_send_status zclient_unregister_opaque(struct zclient *zclient,
+                                                  uint32_t type);
 int zapi_opaque_reg_decode(struct stream *msg,
                           struct zapi_opaque_reg_info *info);
 
@@ -1072,11 +1083,12 @@ enum zapi_opaque_registry {
 /* Send the hello message.
  * 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,
-                                           const struct interface *ifp,
-                                           const struct prefix *p);
+extern enum zclient_send_status
+zclient_send_neigh_discovery_req(struct zclient *zclient,
+                                const struct interface *ifp,
+                                const struct prefix *p);
 
 #ifdef __cplusplus
 }
index fd965e8f214c8a8557e8c971b46faba3b6c50dda..64bfbf7e483f75acb80131c81d2e11d49878c121 100644 (file)
@@ -1917,7 +1917,7 @@ int ospf_zebra_label_manager_connect(void)
        set_nonblocking(zclient_sync->sock);
 
        /* 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!",
                          __func__);
                close(zclient_sync->sock);
index 82a2d2feb51f7ae739358bd168ea83a14b2d8add..222a10e7510582600d152ca8213f648f79453a3b 100644 (file)
@@ -476,8 +476,8 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg)
                break;
        }
 
-       if (zclient_send_rnh(zclient, command, &p,
-                            false, nhop->vrf_id) < 0) {
+       if (zclient_send_rnh(zclient, command, &p, false, nhop->vrf_id)
+           == ZCLIENT_SEND_FAILURE) {
                zlog_warn("%s: Failure to send nexthop to zebra", __func__);
        }
 }
index f691e8b75592d541316cfc65673dcfca718b0c0a..68e0a45690e82c7d8cbaaa973b40a43aa3759d46 100644 (file)
@@ -55,7 +55,7 @@ void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient,
 
        p = &(pnc->rpf.rpf_addr);
        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");
 
        if (PIM_DEBUG_PIM_NHT)
index dc4c621e9c452bbd27b6dbc9588763e67dfa3f8c..05c9af8734b73071c46f773909916d8aad7466c6 100644 (file)
@@ -61,7 +61,7 @@ static int zclient_lookup_connect(struct thread *t)
                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)) {
                        zlog_warn("%s: closing fd=%d: errno=%d %s", __func__,
                                  zlookup->sock, errno, safe_strerror(errno));
index e88904097aec622e88d30fca65636f89aef5984c..627caea37d35ebfc6b53a0b6b3ff539f39d2ef8c 100644 (file)
@@ -211,9 +211,10 @@ int sharp_install_lsps_helper(bool install_p, bool update_p,
                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 {
@@ -590,7 +591,8 @@ void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,
                        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__);
 }
 
@@ -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,
                                                          instance, session_id,
                                                          buf, sizeof(buf));
-               if (ret < 0) {
+               if (ret == ZCLIENT_SEND_FAILURE) {
                        zlog_debug("%s: send_opaque() failed => %d",
                                   __func__, ret);
                        break;
index 0bccbfbeadadcb84993ab95c27895b7a5c376677..19c578c60e2edcf37ad75a6d614643a0c298a367 100644 (file)
@@ -331,7 +331,8 @@ void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh,
                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__);
 }
 /*
index 37a1e4a624bcdf98206dd83e4063e8af21740576..385d4435712728f281aadb0aed3ce578aec283b0 100644 (file)
@@ -179,14 +179,13 @@ void vrrp_zebra_radv_set(struct vrrp_router *r, bool enable)
                                        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,
               VRRP_LOGPFX "Requesting Zebra to set %s protodown %s", ifp->name,
               down ? "on" : "off");
 
-       return zclient_send_interface_protodown(zclient, ifp->vrf_id, ifp,
-                                               down);
+       zclient_send_interface_protodown(zclient, ifp->vrf_id, ifp, down);
 }
 
 void vrrp_zebra_init(void)
index 02d7055b8600ed8e13c091bf6c34872bcee2ab6b..c09943dcef9d32cc277a75eb8fe03a5a62203c85 100644 (file)
@@ -26,8 +26,8 @@
 
 extern void vrrp_zebra_init(void);
 extern void vrrp_zebra_radv_set(struct vrrp_router *r, bool enable);
-extern int vrrp_zclient_send_interface_protodown(struct interface *ifp,
-                                                bool down);
+extern void vrrp_zclient_send_interface_protodown(struct interface *ifp,
+                                                 bool down);
 
 extern int vrrp_ifp_create(struct interface *ifp);
 extern int vrrp_ifp_up(struct interface *ifp);