]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Properly isolate zlookup
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 9 Aug 2016 19:04:23 +0000 (19:04 +0000)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:06 +0000 (20:26 -0500)
The qpim_zclient_lookup was a global variable.
This is not needed.  Isolate appropriately

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_rpf.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
pimd/pim_zlookup.h
pimd/pimd.c
pimd/pimd.h

index 008e7083494322cfefd36e528c4b446d5383fb5d..b51fe39a7bbd77ec36bff6f36752060ad9a1f0fc 100644 (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",
index b610d910735796a572aed1c02e958764f0f4b10d..15b00d8d060a11715aa088a91e87a56f9f731455 100644 (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) {
index 5472fe3d3aeecf1b12fd8dc57a68d6b5f9301f6a..8a32b24e8c5581d8f9f9ff268d87dc94766a9227 100644 (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) {
index f38475b12c65e283b8dcb9ed58b06b7f9be17150..ceac1eff7a077121a16d6e024beb31a7b4bbe79e 100644 (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);
+  }
+}
index b32dfe2b7c6099087bd3d65a0b25288ff131af90..d92eb089b15c13ffc69ede8e3beb6fc38ad49910 100644 (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 */
index fa80aec5a24f07f7d2bfa600773eac94eebda432..2e21349a4849a4635eca39b51501523a0fd19824 100644 (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;
index b4b8d4886da06002bb24aea99668dcdd650d18ab..a1bd225343e402817d5a7a1d32c143ccbbf574aa 100644 (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;