pimd: Properly isolate zlookup

The qpim_zclient_lookup was a global variable.
This is not needed.  Isolate appropriately

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-08-09 19:04:23 +00:00
parent f0ce50d470
commit 05b0d0d0ec
7 changed files with 39 additions and 33 deletions

View File

@ -51,6 +51,7 @@
#include "pim_zebra.h"
#include "pim_static.h"
#include "pim_rp.h"
#include "pim_zlookup.h"
static struct cmd_node pim_global_node = {
PIM_NODE,
@ -2099,14 +2100,8 @@ DEFUN (show_ip_multicast,
else {
vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
}
vty_out(vty, "Zclient lookup socket: ");
if (qpim_zclient_lookup) {
vty_out(vty, "%d failures=%d%s", qpim_zclient_lookup->sock,
qpim_zclient_lookup->fail, VTY_NEWLINE);
}
else {
vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
}
pim_zlookup_show_ip_multicast (vty);
vty_out(vty, "%s", VTY_NEWLINE);
vty_out(vty, "Current highest VifIndex: %d%s",

View File

@ -49,7 +49,7 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop,
if (!incoming)
{
num_ifindex = zclient_lookup_nexthop(qpim_zclient_lookup, nexthop_tab,
num_ifindex = zclient_lookup_nexthop(nexthop_tab,
PIM_NEXTHOP_IFINDEX_TAB_SIZE,
addr, PIM_NEXTHOP_LOOKUP_MAX);
if (num_ifindex < 1) {

View File

@ -718,9 +718,7 @@ void pim_zebra_init(char *zebra_sock_path)
__PRETTY_FUNCTION__);
}
zassert(!qpim_zclient_lookup);
qpim_zclient_lookup = zclient_lookup_new();
zassert(qpim_zclient_lookup);
zclient_lookup_new();
}
void igmp_anysource_forward_start(struct igmp_group *group)
@ -758,7 +756,7 @@ static int fib_lookup_if_vif_index(struct in_addr addr)
int vif_index;
ifindex_t first_ifindex;
num_ifindex = zclient_lookup_nexthop(qpim_zclient_lookup, nexthop_tab,
num_ifindex = zclient_lookup_nexthop(nexthop_tab,
PIM_NEXTHOP_IFINDEX_TAB_SIZE, addr,
PIM_NEXTHOP_LOOKUP_MAX);
if (num_ifindex < 1) {

View File

@ -28,6 +28,7 @@
#include "stream.h"
#include "network.h"
#include "thread.h"
#include "vty.h"
#include "pimd.h"
#include "pim_pim.h"
@ -36,6 +37,8 @@
extern int zclient_debug;
static struct zclient *zlookup = NULL;
static void zclient_lookup_sched(struct zclient *zlookup, int delay);
/* Connect to zebra for nexthop lookup. */
@ -117,15 +120,14 @@ static void zclient_lookup_failed(struct zclient *zlookup)
zclient_lookup_reconnect(zlookup);
}
struct zclient *zclient_lookup_new()
void
zclient_lookup_new (void)
{
struct zclient *zlookup;
zlookup = zclient_new (master);
if (!zlookup) {
zlog_err("%s: zclient_new() failure",
__PRETTY_FUNCTION__);
return 0;
return;
}
zlookup->sock = -1;
@ -138,7 +140,6 @@ struct zclient *zclient_lookup_new()
zlog_notice("%s: zclient lookup socket initialized",
__PRETTY_FUNCTION__);
return zlookup;
}
static int zclient_read_nexthop(struct zclient *zlookup,
@ -296,10 +297,10 @@ static int zclient_read_nexthop(struct zclient *zlookup,
return num_ifindex;
}
static int zclient_lookup_nexthop_once(struct zclient *zlookup,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size,
struct in_addr addr)
static int
zclient_lookup_nexthop_once (struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size,
struct in_addr addr)
{
struct stream *s;
int ret;
@ -344,11 +345,11 @@ static int zclient_lookup_nexthop_once(struct zclient *zlookup,
tab_size, addr);
}
int zclient_lookup_nexthop(struct zclient *zlookup,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size,
struct in_addr addr,
int max_lookup)
int
zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size,
struct in_addr addr,
int max_lookup)
{
int lookup;
uint32_t route_metric = 0xFFFFFFFF;
@ -359,7 +360,7 @@ int zclient_lookup_nexthop(struct zclient *zlookup,
int first_ifindex;
struct in_addr nexthop_addr;
num_ifindex = zclient_lookup_nexthop_once(qpim_zclient_lookup, nexthop_tab,
num_ifindex = zclient_lookup_nexthop_once(nexthop_tab,
PIM_NEXTHOP_IFINDEX_TAB_SIZE, addr);
if (num_ifindex < 1) {
if (PIM_DEBUG_ZEBRA) {
@ -437,3 +438,16 @@ int zclient_lookup_nexthop(struct zclient *zlookup,
return -2;
}
void
pim_zlookup_show_ip_multicast (struct vty *vty)
{
vty_out(vty, "Zclient lookup socket: ");
if (zlookup) {
vty_out(vty, "%d failures=%d%s", zlookup->sock,
zlookup->fail, VTY_NEWLINE);
}
else {
vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
}
}

View File

@ -35,12 +35,13 @@ struct pim_zlookup_nexthop {
uint8_t protocol_distance;
};
struct zclient *zclient_lookup_new(void);
void zclient_lookup_new (void);
int zclient_lookup_nexthop(struct zclient *zlookup,
struct pim_zlookup_nexthop nexthop_tab[],
int zclient_lookup_nexthop(struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size,
struct in_addr addr,
int max_lookup);
void pim_zlookup_show_ip_multicast (struct vty *vty);
#endif /* PIM_ZLOOKUP_H */

View File

@ -53,7 +53,6 @@ struct list *qpim_channel_oil_list = NULL;
int qpim_t_periodic = PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
struct list *qpim_upstream_list = NULL;
struct zclient *qpim_zclient_update = NULL;
struct zclient *qpim_zclient_lookup = NULL;
struct pim_assert_metric qpim_infinite_assert_metric;
long qpim_rpf_cache_refresh_delay_msec = 10000;
struct thread *qpim_rpf_cache_refresher = NULL;

View File

@ -87,7 +87,6 @@ struct in_addr qpim_all_pim_routers_addr;
int qpim_t_periodic; /* Period between Join/Prune Messages */
struct list *qpim_upstream_list; /* list of struct pim_upstream */
struct zclient *qpim_zclient_update;
struct zclient *qpim_zclient_lookup;
struct pim_assert_metric qpim_infinite_assert_metric;
long qpim_rpf_cache_refresh_delay_msec;
struct thread *qpim_rpf_cache_refresher;