summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-09-24 09:25:19 -0400
committerPaul Jakma <paul@quagga.net>2015-10-27 10:53:21 +0000
commit7125293d65d73a451ec203c8c1630c236171f5a3 (patch)
treef9d118c9a8f8374d69fb9c75c87531a2ca478fb2
parentfd1c1a133af47ae5533a5ed41b73ff62e7aa1058 (diff)
downloadquagga-7125293d65d73a451ec203c8c1630c236171f5a3.tar.bz2
quagga-7125293d65d73a451ec203c8c1630c236171f5a3.tar.xz
lib: zclient.c remove extern struct thread_master *
zclient.c depended upon link time inclusion of a extern struct thread_master *master. This is a violation of the namespace of the calling daemon. If a library needs the pointer pass it in and save it for future use. This code change also makes the zclient code consistent with the other lib functions that need to schedule work on your behalf Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_nexthop.c2
-rw-r--r--bgpd/bgp_zebra.c4
-rw-r--r--bgpd/bgp_zebra.h2
-rw-r--r--bgpd/bgpd.c2
-rw-r--r--isisd/isis_main.c2
-rw-r--r--isisd/isis_zebra.c4
-rw-r--r--isisd/isis_zebra.h2
-rw-r--r--lib/zclient.c19
-rw-r--r--lib/zclient.h5
-rw-r--r--ospf6d/ospf6_zebra.c4
-rw-r--r--ospf6d/ospf6_zebra.h2
-rw-r--r--ospf6d/ospf6d.c2
-rw-r--r--ospfd/ospf_main.c2
-rw-r--r--ospfd/ospf_zebra.c4
-rw-r--r--ospfd/ospf_zebra.h2
-rw-r--r--pimd/pim_main.c2
-rw-r--r--pimd/pim_zebra.c4
-rw-r--r--pimd/pim_zebra.h2
-rw-r--r--pimd/pim_zlookup.c2
-rw-r--r--ripd/rip_main.c2
-rw-r--r--ripd/rip_zebra.c4
-rw-r--r--ripd/ripd.h2
-rw-r--r--ripngd/ripng_main.c2
-rw-r--r--ripngd/ripng_zebra.c4
-rw-r--r--ripngd/ripngd.h2
-rw-r--r--tests/bgp_mpath_test.c2
-rw-r--r--zebra/client_main.c4
27 files changed, 47 insertions, 43 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 20302e39..33de365e 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -1402,7 +1402,7 @@ bgp_config_write_scan_time (struct vty *vty)
void
bgp_scan_init (void)
{
- zlookup = zclient_new ();
+ zlookup = zclient_new (master);
zlookup->sock = -1;
zlookup->t_connect = thread_add_event (master, zlookup_connect, zlookup, 0);
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 26163516..e534bee8 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1094,10 +1094,10 @@ bgp_zebra_connected (struct zclient *zclient)
}
void
-bgp_zebra_init (void)
+bgp_zebra_init (struct thread_master *master)
{
/* Set default values. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_BGP);
zclient->zebra_connected = bgp_zebra_connected;
zclient->router_id_update = bgp_router_id_update;
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index 80991930..50f727df 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -25,7 +25,7 @@ Boston, MA 02111-1307, USA. */
extern struct stream *bgp_nexthop_buf;
-extern void bgp_zebra_init (void);
+extern void bgp_zebra_init (struct thread_master *master);
extern int bgp_if_update_all (void);
extern int bgp_config_write_maxpaths (struct vty *, struct bgp *, afi_t,
safi_t, int *);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 00680372..af8bdb45 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -5421,7 +5421,7 @@ bgp_init (void)
bgp_vty_init ();
/* Init zebra. */
- bgp_zebra_init ();
+ bgp_zebra_init (master);
/* BGP inits. */
bgp_attr_init ();
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index e1af71f7..fba7b101 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -339,7 +339,7 @@ main (int argc, char **argv, char **envp)
/* create the global 'isis' instance */
isis_new (1);
- isis_zebra_init ();
+ isis_zebra_init (master);
/* parse config file */
/* this is needed three times! because we have interfaces before the areas */
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 6d0c1571..8a784175 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -602,9 +602,9 @@ isis_zebra_connected (struct zclient *zclient)
}
void
-isis_zebra_init ()
+isis_zebra_init (struct thread_master *master)
{
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_ISIS);
zclient->zebra_connected = isis_zebra_connected;
zclient->router_id_update = isis_router_id_update_zebra;
diff --git a/isisd/isis_zebra.h b/isisd/isis_zebra.h
index 889cd9b6..00114788 100644
--- a/isisd/isis_zebra.h
+++ b/isisd/isis_zebra.h
@@ -24,7 +24,7 @@
extern struct zclient *zclient;
-void isis_zebra_init (void);
+void isis_zebra_init (struct thread_master *);
void isis_zebra_route_update (struct prefix *prefix,
struct isis_route_info *route_info);
int isis_distribute_list_update (int routetype);
diff --git a/lib/zclient.c b/lib/zclient.c
index 0ce46fef..bfff9a36 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -39,8 +39,6 @@ enum event {ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT};
/* Prototype for event manager. */
static void zclient_event (enum event, struct zclient *);
-extern struct thread_master *master;
-
const char *zclient_serv_path = NULL;
/* This file local debug flag. */
@@ -48,7 +46,7 @@ int zclient_debug = 0;
/* Allocate zclient structure. */
struct zclient *
-zclient_new ()
+zclient_new (struct thread_master *master)
{
struct zclient *zclient;
zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
@@ -56,6 +54,7 @@ zclient_new ()
zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
zclient->wb = buffer_new(0);
+ zclient->master = master;
return zclient;
}
@@ -258,8 +257,8 @@ zclient_flush_data(struct thread *thread)
return zclient_failed(zclient);
break;
case BUFFER_PENDING:
- zclient->t_write = thread_add_write(master, zclient_flush_data,
- zclient, zclient->sock);
+ zclient->t_write = thread_add_write (zclient->master, zclient_flush_data,
+ zclient, zclient->sock);
break;
case BUFFER_EMPTY:
break;
@@ -284,8 +283,8 @@ zclient_send_message(struct zclient *zclient)
THREAD_OFF(zclient->t_write);
break;
case BUFFER_PENDING:
- THREAD_WRITE_ON(master, zclient->t_write,
- zclient_flush_data, zclient, zclient->sock);
+ THREAD_WRITE_ON (zclient->master, zclient->t_write,
+ zclient_flush_data, zclient, zclient->sock);
break;
}
return 0;
@@ -1092,7 +1091,7 @@ zclient_event (enum event event, struct zclient *zclient)
case ZCLIENT_SCHEDULE:
if (! zclient->t_connect)
zclient->t_connect =
- thread_add_event (master, zclient_connect, zclient, 0);
+ thread_add_event (zclient->master, zclient_connect, zclient, 0);
break;
case ZCLIENT_CONNECT:
if (zclient->fail >= 10)
@@ -1102,12 +1101,12 @@ zclient_event (enum event event, struct zclient *zclient)
zclient->fail < 3 ? 10 : 60);
if (! zclient->t_connect)
zclient->t_connect =
- thread_add_timer (master, zclient_connect, zclient,
+ thread_add_timer (zclient->master, zclient_connect, zclient,
zclient->fail < 3 ? 10 : 60);
break;
case ZCLIENT_READ:
zclient->t_read =
- thread_add_read (master, zclient_read, zclient, zclient->sock);
+ thread_add_read (zclient->master, zclient_read, zclient, zclient->sock);
break;
}
}
diff --git a/lib/zclient.h b/lib/zclient.h
index 3490b320..aa935c12 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -40,6 +40,9 @@
/* Structure for the zebra client. */
struct zclient
{
+ /* The thread master we schedule ourselves on */
+ struct thread_master *master;
+
/* Socket to zebra daemon. */
int sock;
@@ -132,7 +135,7 @@ struct zapi_ipv4
};
/* Prototypes of zebra client service functions. */
-extern struct zclient *zclient_new (void);
+extern struct zclient *zclient_new (struct thread_master *);
extern void zclient_init (struct zclient *, int);
extern int zclient_start (struct zclient *);
extern void zclient_stop (struct zclient *);
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 951e11d2..d37e5089 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -578,10 +578,10 @@ ospf6_zebra_connected (struct zclient *zclient)
}
void
-ospf6_zebra_init (void)
+ospf6_zebra_init (struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_OSPF6);
zclient->zebra_connected = ospf6_zebra_connected;
zclient->router_id_update = ospf6_router_id_update_zebra;
diff --git a/ospf6d/ospf6_zebra.h b/ospf6d/ospf6_zebra.h
index a219450e..05694d39 100644
--- a/ospf6d/ospf6_zebra.h
+++ b/ospf6d/ospf6_zebra.h
@@ -44,7 +44,7 @@ extern void ospf6_zebra_redistribute (int);
extern void ospf6_zebra_no_redistribute (int);
#define ospf6_zebra_is_redistribute(type) \
vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT)
-extern void ospf6_zebra_init (void);
+extern void ospf6_zebra_init(struct thread_master *);
extern int config_write_ospf6_debug_zebra (struct vty *vty);
extern void install_element_ospf6_debug_zebra (void);
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index 3cdd5c11..c2baa314 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -1764,7 +1764,7 @@ ospf6_init (void)
ospf6_area_init ();
ospf6_interface_init ();
ospf6_neighbor_init ();
- ospf6_zebra_init ();
+ ospf6_zebra_init (master);
ospf6_lsa_init ();
ospf6_spf_init ();
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 826fc983..10565fe6 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -298,7 +298,7 @@ main (int argc, char **argv)
/* OSPFd inits. */
ospf_if_init ();
- ospf_zebra_init ();
+ ospf_zebra_init (master);
/* OSPF vty inits. */
ospf_vty_init ();
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 588f0fb5..cf2ea81f 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -1304,10 +1304,10 @@ ospf_zebra_connected (struct zclient *zclient)
}
void
-ospf_zebra_init ()
+ospf_zebra_init (struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_OSPF);
zclient->zebra_connected = ospf_zebra_connected;
zclient->router_id_update = ospf_router_id_update_zebra;
diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h
index 148f6520..32a02716 100644
--- a/ospfd/ospf_zebra.h
+++ b/ospfd/ospf_zebra.h
@@ -72,7 +72,7 @@ extern int ospf_distance_set (struct vty *, struct ospf *, const char *,
const char *, const char *);
extern int ospf_distance_unset (struct vty *, struct ospf *, const char *,
const char *, const char *);
-extern void ospf_zebra_init (void);
+extern void ospf_zebra_init (struct thread_master *);
#endif /* _ZEBRA_OSPF_ZEBRA_H */
diff --git a/pimd/pim_main.c b/pimd/pim_main.c
index 95c1816f..5f4711e8 100644
--- a/pimd/pim_main.c
+++ b/pimd/pim_main.c
@@ -205,7 +205,7 @@ int main(int argc, char** argv, char** envp) {
/*
* Initialize zclient "update" and "lookup" sockets
*/
- pim_zebra_init(zebra_sock_path);
+ pim_zebra_init (master, zebra_sock_path);
zlog_notice("Loading configuration - begin");
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index dfc871b3..1a392713 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -655,7 +655,7 @@ static void pim_zebra_connected(struct zclient *zclient)
zclient_send_requests(zclient, VRF_DEFAULT);
}
-void pim_zebra_init(char *zebra_sock_path)
+void pim_zebra_init (struct thread_master *master, char *zebra_sock_path)
{
int i;
@@ -669,7 +669,7 @@ void pim_zebra_init(char *zebra_sock_path)
#endif
/* Socket for receiving updates from Zebra daemon */
- qpim_zclient_update = zclient_new();
+ qpim_zclient_update = zclient_new (master);
qpim_zclient_update->zebra_connected = pim_zebra_connected;
qpim_zclient_update->router_id_update = pim_router_id_update_zebra;
diff --git a/pimd/pim_zebra.h b/pimd/pim_zebra.h
index d624c866..af5baef2 100644
--- a/pimd/pim_zebra.h
+++ b/pimd/pim_zebra.h
@@ -26,7 +26,7 @@
#include "pim_igmp.h"
#include "pim_ifchannel.h"
-void pim_zebra_init(char *zebra_sock_path);
+void pim_zebra_init (struct thread_master *master, char *zebra_sock_path);
void pim_scan_oil(void);
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 67896d96..297a2a8a 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -122,7 +122,7 @@ struct zclient *zclient_lookup_new()
{
struct zclient *zlookup;
- zlookup = zclient_new();
+ zlookup = zclient_new (master);
if (!zlookup) {
zlog_err("%s: zclient_new() failure",
__PRETTY_FUNCTION__);
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index 95b1f6d4..4ead9b0e 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -286,7 +286,7 @@ main (int argc, char **argv)
/* RIP related initialization. */
rip_init ();
rip_if_init ();
- rip_zclient_init ();
+ rip_zclient_init (master);
rip_peer_init ();
/* Get configuration file. */
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index de981623..0b6c22a8 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -710,10 +710,10 @@ rip_zebra_connected (struct zclient *zclient)
}
void
-rip_zclient_init ()
+rip_zclient_init (struct thread_master *master)
{
/* Set default value to the zebra client structure. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_RIP);
zclient->zebra_connected = rip_zebra_connected;
zclient->interface_add = rip_interface_add;
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 4f40e79a..a768ccc6 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -389,7 +389,7 @@ extern void rip_if_down_all (void);
extern void rip_route_map_init (void);
extern void rip_route_map_reset (void);
extern void rip_snmp_init (void);
-extern void rip_zclient_init (void);
+extern void rip_zclient_init (struct thread_master *);
extern void rip_zclient_start (void);
extern void rip_zclient_reset (void);
extern void rip_offset_init (void);
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index d8f22411..1c184e2c 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -281,7 +281,7 @@ main (int argc, char **argv)
/* RIPngd inits. */
ripng_init ();
- zebra_init ();
+ zebra_init (master);
ripng_peer_init ();
/* Get configuration file. */
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index 58f88606..13b18533 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -541,10 +541,10 @@ ripng_zebra_connected (struct zclient *zclient)
/* Initialize zebra structure and it's commands. */
void
-zebra_init ()
+zebra_init (struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_RIPNG);
zclient->zebra_connected = ripng_zebra_connected;
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index 28ca41bc..6cbbd84b 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -358,7 +358,7 @@ extern void ripng_route_map_init (void);
extern void ripng_route_map_reset (void);
extern void ripng_terminate (void);
/* zclient_init() is done by ripng_zebra.c:zebra_init() */
-extern void zebra_init (void);
+extern void zebra_init (struct thread_master *);
extern void ripng_zclient_start (void);
extern void ripng_zclient_reset (void);
extern void ripng_offset_init (void);
diff --git a/tests/bgp_mpath_test.c b/tests/bgp_mpath_test.c
index 35947537..ed54d9c1 100644
--- a/tests/bgp_mpath_test.c
+++ b/tests/bgp_mpath_test.c
@@ -376,7 +376,7 @@ static int
global_test_init (void)
{
master = thread_master_create ();
- zclient = zclient_new ();
+ zclient = zclient_new (master);
bgp_master_init ();
bgp_option_set (BGP_OPT_NO_LISTEN);
diff --git a/zebra/client_main.c b/zebra/client_main.c
index 06afc56d..43ab2997 100644
--- a/zebra/client_main.c
+++ b/zebra/client_main.c
@@ -193,13 +193,15 @@ zebra_sim (FILE *fp)
int
main (int argc, char **argv)
{
+ struct thread_master *master;
FILE *fp;
if (argc == 1)
usage_exit ();
+ master = thread_master_create ();
/* Establish connection to zebra. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient->enable = 1;
#ifdef HAVE_TCP_ZEBRA
zclient->sock = zclient_socket ();