summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/zclient.c27
-rw-r--r--lib/zclient.h21
2 files changed, 33 insertions, 15 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 9f261e2f29..1b2ff02f61 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -41,8 +41,20 @@ static void zclient_event(enum zclient_event, struct zclient *);
static void zebra_interface_if_set_value(struct stream *s,
struct interface *ifp);
-struct zclient_options zclient_options_default = {.receive_notify = false,
- .synchronous = false};
+const struct zclient_options zclient_options_default = {
+ .synchronous = false,
+ .auxiliary = false,
+};
+
+const struct zclient_options zclient_options_sync = {
+ .synchronous = true,
+ .auxiliary = true,
+};
+
+const struct zclient_options zclient_options_auxiliary = {
+ .synchronous = false,
+ .auxiliary = true,
+};
struct sockaddr_storage zclient_addr;
socklen_t zclient_addr_len;
@@ -52,7 +64,7 @@ static int zclient_debug;
/* Allocate zclient structure. */
struct zclient *zclient_new(struct event_loop *master,
- struct zclient_options *opt,
+ const struct zclient_options *opt,
zclient_handler *const *handlers, size_t n_handlers)
{
struct zclient *zclient;
@@ -69,8 +81,8 @@ struct zclient *zclient_new(struct event_loop *master,
zclient->handlers = handlers;
zclient->n_handlers = n_handlers;
- zclient->receive_notify = opt->receive_notify;
zclient->synchronous = opt->synchronous;
+ zclient->auxiliary = opt->auxiliary;
return zclient;
}
@@ -392,10 +404,6 @@ enum zclient_send_status zclient_send_hello(struct zclient *zclient)
stream_putc(s, zclient->redist_default);
stream_putw(s, zclient->instance);
stream_putl(s, zclient->session_id);
- if (zclient->receive_notify)
- stream_putc(s, 1);
- else
- stream_putc(s, 0);
if (zclient->synchronous)
stream_putc(s, 1);
else
@@ -4444,7 +4452,8 @@ static void zclient_read(struct event *thread)
zlog_debug("zclient %p command %s VRF %u", zclient,
zserv_command_string(command), vrf_id);
- if (command < array_size(lib_handlers) && lib_handlers[command])
+ if (!zclient->auxiliary && command < array_size(lib_handlers) &&
+ lib_handlers[command])
lib_handlers[command](command, zclient, length, vrf_id);
if (command < zclient->n_handlers && zclient->handlers[command])
zclient->handlers[command](command, zclient, length, vrf_id);
diff --git a/lib/zclient.h b/lib/zclient.h
index 9b709ea64b..05eb6b20ee 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -303,12 +303,14 @@ struct zclient {
/* Privileges to change socket values */
struct zebra_privs_t *privs;
- /* Do we care about failure events for route install? */
- bool receive_notify;
-
/* Is this a synchronous client? */
bool synchronous;
+ /* Auxiliary clients don't execute standard library handlers
+ * (which otherwise would duplicate VRF/interface add/delete/etc.
+ */
+ bool auxiliary;
+
/* BFD enabled with bfd_protocol_integration_init() */
bool bfd_integration;
@@ -834,11 +836,18 @@ extern char *zclient_evpn_dump_macip_flags(uint8_t flags, char *buf,
enum zebra_neigh_state { ZEBRA_NEIGH_INACTIVE = 0, ZEBRA_NEIGH_ACTIVE = 1 };
struct zclient_options {
- bool receive_notify;
bool synchronous;
+
+ /* auxiliary = don't call common lib/ handlers that manage bits.
+ * Those should only run once, on the "main" zclient, which this is
+ * not. (This is also set for synchronous clients.)
+ */
+ bool auxiliary;
};
-extern struct zclient_options zclient_options_default;
+extern const struct zclient_options zclient_options_default;
+extern const struct zclient_options zclient_options_sync;
+extern const struct zclient_options zclient_options_auxiliary;
/* link layer representation for GRE like interfaces
* ip_in is the underlay IP, ip_out is the tunnel dest
@@ -885,7 +894,7 @@ int zclient_neigh_ip_encode(struct stream *s, uint16_t cmd, union sockunion *in,
extern uint32_t zclient_get_nhg_start(uint32_t proto);
extern struct zclient *zclient_new(struct event_loop *m,
- struct zclient_options *opt,
+ const struct zclient_options *opt,
zclient_handler *const *handlers,
size_t n_handlers);