Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: clean up zclient options #14867

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bgpd/rfapi/vnc_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ static zclient_handler *const vnc_handlers[] = {
void vnc_zebra_init(struct event_loop *master)
{
/* Set default values. */
zclient_vnc = zclient_new(master, &zclient_options_default,
zclient_vnc = zclient_new(master, &zclient_options_auxiliary,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the zapi communication of this change into zebra and it respecting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this have any effect on zebra? The goal is to not invoke the common lib/ callbacks on the receiving end in the daemon. There can still be other code that wants to process the same notifications (e.g. running multithreaded), just without duplicating/going into lib/ structures.

vnc_handlers, array_size(vnc_handlers));
zclient_init(zclient_vnc, ZEBRA_ROUTE_VNC, 0, &bgpd_privs);
}
Expand Down
11 changes: 10 additions & 1 deletion lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ static void zebra_interface_if_set_value(struct stream *s,

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;
Expand Down Expand Up @@ -75,6 +82,7 @@ struct zclient *zclient_new(struct event_loop *master,
zclient->n_handlers = n_handlers;

zclient->synchronous = opt->synchronous;
zclient->auxiliary = opt->auxiliary;

return zclient;
}
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions lib/zclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ struct zclient {
/* 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;

Expand Down Expand Up @@ -832,10 +837,17 @@ enum zebra_neigh_state { ZEBRA_NEIGH_INACTIVE = 0, ZEBRA_NEIGH_ACTIVE = 1 };

struct zclient_options {
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 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
Expand Down
Loading