From: Donald Sharp Date: Tue, 9 Aug 2016 19:04:23 +0000 (+0000) Subject: pimd: Properly isolate zlookup X-Git-Tag: frr-3.0-branchpoint~64^2~10^2~298 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=05b0d0d0ecadcf030ae8fdffc2e78ab6392fc500;p=mirror%2Ffrr.git pimd: Properly isolate zlookup The qpim_zclient_lookup was a global variable. This is not needed. Isolate appropriately Signed-off-by: Donald Sharp --- diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 008e708349..b51fe39a7b 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -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, "%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, "%s", VTY_NEWLINE); - } + + pim_zlookup_show_ip_multicast (vty); vty_out(vty, "%s", VTY_NEWLINE); vty_out(vty, "Current highest VifIndex: %d%s", diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index b610d91073..15b00d8d06 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -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) { diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 5472fe3d3a..8a32b24e8c 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -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) { diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index f38475b12c..ceac1eff7a 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -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, "%s", VTY_NEWLINE); + } +} diff --git a/pimd/pim_zlookup.h b/pimd/pim_zlookup.h index b32dfe2b7c..d92eb089b1 100644 --- a/pimd/pim_zlookup.h +++ b/pimd/pim_zlookup.h @@ -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 */ diff --git a/pimd/pimd.c b/pimd/pimd.c index fa80aec5a2..2e21349a48 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -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; diff --git a/pimd/pimd.h b/pimd/pimd.h index b4b8d4886d..a1bd225343 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -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;