diff options
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index ab2dd09896..f6c5a8af08 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -47,10 +47,10 @@ DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient"); DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs"); /* Zebra client events. */ -enum event { ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT }; +enum zclient_event { ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT }; /* Prototype for event manager. */ -static void zclient_event(enum event, struct zclient *); +static void zclient_event(enum zclient_event, struct zclient *); static void zebra_interface_if_set_value(struct stream *s, struct interface *ifp); @@ -263,20 +263,21 @@ static enum zclient_send_status zclient_failed(struct zclient *zclient) return ZCLIENT_SEND_FAILURE; } -static int zclient_flush_data(struct thread *thread) +static void zclient_flush_data(struct thread *thread) { struct zclient *zclient = THREAD_ARG(thread); zclient->t_write = NULL; if (zclient->sock < 0) - return -1; + return; switch (buffer_flush_available(zclient->wb, zclient->sock)) { case BUFFER_ERROR: flog_err( EC_LIB_ZAPI_SOCKET, "%s: buffer_flush_available failed on zclient fd %d, closing", __func__, zclient->sock); - return zclient_failed(zclient); + zclient_failed(zclient); + return; case BUFFER_PENDING: zclient->t_write = NULL; thread_add_write(zclient->master, zclient_flush_data, zclient, @@ -287,7 +288,6 @@ static int zclient_flush_data(struct thread *thread) (*zclient->zebra_buffer_write_ready)(); break; } - return 0; } /* @@ -754,7 +754,7 @@ void zclient_init(struct zclient *zclient, int redist_default, /* This function is a wrapper function for calling zclient_start from timer or event thread. */ -static int zclient_connect(struct thread *t) +static void zclient_connect(struct thread *t) { struct zclient *zclient; @@ -764,7 +764,7 @@ static int zclient_connect(struct thread *t) if (zclient_debug) zlog_debug("zclient_connect is called"); - return zclient_start(zclient); + zclient_start(zclient); } enum zclient_send_status zclient_send_rnh(struct zclient *zclient, int command, @@ -1924,7 +1924,8 @@ const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf, /* * Decode the nexthop-tracking update message */ -bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr) +bool zapi_nexthop_update_decode(struct stream *s, struct prefix *match, + struct zapi_route *nhr) { uint32_t i; @@ -1932,6 +1933,22 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr) STREAM_GETL(s, nhr->message); STREAM_GETW(s, nhr->safi); + STREAM_GETW(s, match->family); + STREAM_GETC(s, match->prefixlen); + /* + * What we got told to match against + */ + switch (match->family) { + case AF_INET: + STREAM_GET(&match->u.prefix4.s_addr, s, IPV4_MAX_BYTELEN); + break; + case AF_INET6: + STREAM_GET(&match->u.prefix6, s, IPV6_MAX_BYTELEN); + break; + } + /* + * What we matched against + */ STREAM_GETW(s, nhr->prefix.family); STREAM_GETC(s, nhr->prefix.prefixlen); switch (nhr->prefix.family) { @@ -3864,7 +3881,7 @@ static zclient_handler *const lib_handlers[] = { }; /* Zebra client message read function. */ -static int zclient_read(struct thread *thread) +static void zclient_read(struct thread *thread) { size_t already; uint16_t length, command; @@ -3888,11 +3905,12 @@ static int zclient_read(struct thread *thread) zlog_debug( "zclient connection closed socket [%d].", zclient->sock); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } if (nbyte != (ssize_t)(ZEBRA_HEADER_SIZE - already)) { zclient_event(ZCLIENT_READ, zclient); - return 0; + return; } already = ZEBRA_HEADER_SIZE; } @@ -3912,14 +3930,16 @@ static int zclient_read(struct thread *thread) EC_LIB_ZAPI_MISSMATCH, "%s: socket %d version mismatch, marker %d, version %d", __func__, zclient->sock, marker, version); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } if (length < ZEBRA_HEADER_SIZE) { flog_err(EC_LIB_ZAPI_MISSMATCH, "%s: socket %d message length %u is less than %d ", __func__, zclient->sock, length, ZEBRA_HEADER_SIZE); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } /* Length check. */ @@ -3947,12 +3967,13 @@ static int zclient_read(struct thread *thread) zlog_debug( "zclient connection closed socket [%d].", zclient->sock); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } if (nbyte != (ssize_t)(length - already)) { /* Try again later. */ zclient_event(ZCLIENT_READ, zclient); - return 0; + return; } } @@ -3969,13 +3990,11 @@ static int zclient_read(struct thread *thread) if (zclient->sock < 0) /* Connection was closed during packet processing. */ - return -1; + return; /* Register read thread. */ stream_reset(zclient->ibuf); zclient_event(ZCLIENT_READ, zclient); - - return 0; } void zclient_redistribute(int command, struct zclient *zclient, afi_t afi, @@ -4036,7 +4055,7 @@ void zclient_redistribute_default(int command, struct zclient *zclient, zebra_redistribute_default_send(command, zclient, afi, vrf_id); } -static void zclient_event(enum event event, struct zclient *zclient) +static void zclient_event(enum zclient_event event, struct zclient *zclient) { switch (event) { case ZCLIENT_SCHEDULE: |
