void babelz_zebra_init(void)
{
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_BABEL, 0, &babeld_privs);
zclient->zebra_connected = babel_zebra_connected;
zclient_num_connects = 0;
/* Set default values. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_BGP, 0, &bgpd_privs);
zclient->zebra_connected = bgp_zebra_connected;
zclient->router_id_update = bgp_router_id_update;
void vnc_zebra_init(struct thread_master *master)
{
/* Set default values. */
- zclient_vnc = zclient_new(master);
+ zclient_vnc = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient_vnc, ZEBRA_ROUTE_VNC, 0, &bgpd_privs);
zclient_vnc->redistribute_route_add = vnc_zebra_read_route;
void eigrp_zebra_init(void)
{
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_EIGRP, 0, &eigrpd_privs);
zclient->zebra_connected = eigrp_zebra_connected;
void isis_zebra_init(struct thread_master *master)
{
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_ISIS, 0, &isisd_privs);
zclient->zebra_connected = isis_zebra_connected;
zclient->router_id_update = isis_router_id_update_zebra;
zclient_sync_init(u_short instance)
{
/* Initialize special zclient for synchronous message exchanges. */
- zclient_sync = zclient_new(master);
+ zclient_sync = zclient_new_notify(master, &zclient_options_default);
zclient_sync->sock = -1;
zclient_sync->redist_default = ZEBRA_ROUTE_LDP;
zclient_sync->instance = instance;
ldp_zebra_init(struct thread_master *master)
{
/* Set default values. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_LDP, 0, &ldpd_privs);
/* set callbacks */
/* This file local debug flag. */
int zclient_debug = 0;
+struct zclient_options zclient_options_default = { .receive_notify = false };
+
/* Allocate zclient structure. */
-struct zclient *zclient_new(struct thread_master *master)
+struct zclient *zclient_new_notify(struct thread_master *master,
+ struct zclient_options *opt)
{
struct zclient *zclient;
zclient = XCALLOC(MTYPE_ZCLIENT, sizeof(struct zclient));
zclient->wb = buffer_new(0);
zclient->master = master;
+ zclient->receive_notify = opt->receive_notify;
+
return zclient;
}
* @param zclient a pointer to zclient structure
* @return socket fd just to make sure that connection established
* @see zclient_init
- * @see zclient_new
+ * @see zclient_new_notify
*/
int zclient_socket_connect(struct zclient *zclient)
{
zclient_create_header(s, ZEBRA_HELLO, VRF_DEFAULT);
stream_putc(s, zclient->redist_default);
stream_putw(s, zclient->instance);
+ if (zclient->receive_notify)
+ stream_putc(s, 1);
+ else
+ stream_putc(s, 0);
+
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
}
/* Priviledges to change socket values */
struct zebra_privs_t *privs;
+ /* Do we care about failure events for route install? */
+ bool receive_notify;
+
/* Socket to zebra daemon. */
int sock;
#define ZEBRA_MAC_TYPE_STICKY 0x01 /* Sticky MAC*/
#define ZEBRA_MAC_TYPE_GW 0x02 /* gateway (SVI) mac*/
+struct zclient_options {
+ bool receive_notify;
+};
+
/* Prototypes of zebra client service functions. */
extern struct zclient *zclient_new(struct thread_master *);
+
+#if CONFDATE > 20181101
+CPP_NOTICE("zclient_new_notify can take over or zclient_new now");
+#endif
+
+extern struct zclient_options zclient_options_default;
+
+extern struct zclient *zclient_new_notify(struct thread_master *m,
+ struct zclient_options *opt);
+
+#define zclient_new(A) zclient_new_notify((A), &zclient_options_default); \
+ CPP_WARN("Please transition to using zclient_new_notify");
+
extern void zclient_init(struct zclient *, int, u_short, struct zebra_privs_t *privs);
extern int zclient_start(struct zclient *);
extern void zclient_stop(struct zclient *);
zebra_rib[AFI_IP] = route_table_init();
zebra_rib[AFI_IP6] = route_table_init();
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient->zebra_connected = nhrp_zebra_connected;
zclient->interface_add = nhrp_interface_add;
zclient->interface_delete = nhrp_interface_delete;
void ospf6_zebra_init(struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
zclient->zebra_connected = ospf6_zebra_connected;
zclient->router_id_update = ospf6_router_id_update_zebra;
void ospf_zebra_init(struct thread_master *master, u_short instance)
{
/* Allocate zebra structure. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs);
zclient->zebra_connected = ospf_zebra_connected;
zclient->router_id_update = ospf_router_id_update_zebra;
int i;
/* Socket for receiving updates from Zebra daemon */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient->zebra_connected = pim_zebra_connected;
zclient->router_id_update = pim_router_id_update_zebra;
void zclient_lookup_new(void)
{
- zlookup = zclient_new(master);
+ zlookup = zclient_new_notify(master, &zclient_options_default);
if (!zlookup) {
zlog_err("%s: zclient_new() failure", __PRETTY_FUNCTION__);
return;
void rip_zclient_init(struct thread_master *master)
{
/* Set default value to the zebra client structure. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs);
zclient->zebra_connected = rip_zebra_connected;
zclient->interface_add = rip_interface_add;
void zebra_init(struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_RIPNG, 0, &ripngd_privs);
zclient->zebra_connected = ripng_zebra_connected;
{
qobj_init();
master = thread_master_create(NULL);
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
bgp_master_init(master);
vrf_init(NULL, NULL, NULL, NULL);
bgp_option_set(BGP_OPT_NO_LISTEN);
{
frr_zclient_addr(&zclient_addr, &zclient_addr_len, lm_zserv_path);
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
/* zclient_init(zclient, ZEBRA_LABEL_MANAGER, 0); */
zclient->sock = -1;
zclient->redist_default = ZEBRA_ROUTE_LDP;
master = thread_master_create(NULL);
/* Establish connection to zebra. */
- zclient = zclient_new(master);
+ zclient = zclient_new_notify(master, &zclient_options_default);
zclient->enable = 1;
zclient_socket_connect(zclient);
lm_zserv_path);
/* Set default values. */
- zclient = zclient_new(zebrad.master);
+ zclient = zclient_new_notify(zebrad.master, &zclient_options_default);
zclient->sock = -1;
zclient->t_connect = NULL;
lm_zclient_connect(NULL);
uint8_t blen;
client = zebra_find_client(proto);
- if (!client) {
- if (IS_ZEBRA_DEBUG_PACKET)
- zlog_debug("Attempting to notify a client for proto: %u but did not find one",
- proto);
- return -1;
+ if (!client || !client->notify_owner) {
+ if (IS_ZEBRA_DEBUG_PACKET) {
+ char buff[PREFIX_STRLEN];
+
+ zlog_debug("Not Notifying Owner: %u about prefix %s",
+ proto, prefix2str(p, buff, sizeof(buff)));
+ }
+ return 0;
}
s = client->obuf;
/* type of protocol (lib/zebra.h) */
u_char proto;
u_short instance;
+ u_char notify;
STREAM_GETC(client->ibuf, proto);
STREAM_GETW(client->ibuf, instance);
+ STREAM_GETC(client->ibuf, notify);
+ if (notify)
+ client->notify_owner = true;
/* accept only dynamic routing protocols */
if ((proto < ZEBRA_ROUTE_MAX) && (proto > ZEBRA_ROUTE_STATIC)) {
/* Router-id information. */
vrf_bitmap_t ridinfo;
+ bool notify_owner;
+
/* client's protocol */
u_char proto;
u_short instance;