Browse Source

pimd: clear zclient-update: Reset zclient update connection to zebra daemon

Everton Marques 5 years ago
parent
commit
3456a80f5f
5 changed files with 34 additions and 19 deletions
  1. 1 0
      pimd/COMMANDS
  2. 13 0
      pimd/pim_cmd.c
  3. 18 19
      pimd/pim_zebra.c
  4. 1 0
      pimd/pimd.c
  5. 1 0
      pimd/pimd.h

+ 1 - 0
pimd/COMMANDS

@@ -60,6 +60,7 @@ debug commands:
        clear ip mroute                  Reset multicast routes
        clear ip pim interfaces		Reset PIM interfaces
        clear ip pim oil			Rescan PIM OIL (output interface list)
+       clear zclient-update		Reset zclient update connection to zebra daemon
        debug igmp			IGMP protocol activity
        debug mroute			PIM interaction with kernel MFC cache
        debug pim			PIM protocol activity

+ 13 - 0
pimd/pim_cmd.c

@@ -27,6 +27,7 @@
 #include "command.h"
 #include "if.h"
 #include "prefix.h"
+#include "zclient.h"
 
 #include "pimd.h"
 #include "pim_cmd.h"
@@ -1562,6 +1563,17 @@ DEFUN (pim_interface,
   return CMD_SUCCESS;
 }
 
+DEFUN (clear_zclient_update,
+       clear_zclient_update_cmd,
+       "clear zclient-update",
+       CLEAR_STR
+       "Reset zclient update connection to zebra daemon\n")
+{
+  zclient_reset(qpim_zclient_update);
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (clear_ip_interfaces,
        clear_ip_interfaces_cmd,
        "clear ip interfaces",
@@ -4312,6 +4324,7 @@ void pim_cmd_init()
   install_element (ENABLE_NODE, &clear_ip_mroute_cmd);
   install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
   install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd);
+  install_element (ENABLE_NODE, &clear_zclient_update_cmd);
 
   install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
   install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);

+ 18 - 19
pimd/pim_zebra.c

@@ -644,7 +644,6 @@ static int redist_read_ipv4_route(int command, struct zclient *zclient,
 
 void pim_zebra_init()
 {
-  struct zclient *zclient;
   int i;
 
 #ifdef HAVE_TCP_ZEBRA
@@ -654,35 +653,35 @@ void pim_zebra_init()
 #endif
 
   /* Socket for receiving updates from Zebra daemon */
-  zclient = zclient_new();
-
-  zclient->router_id_update         = pim_router_id_update;
-  zclient->router_id_update         = pim_router_id_update_zebra;
-  zclient->interface_add            = pim_zebra_if_add;
-  zclient->interface_delete         = pim_zebra_if_del;
-  zclient->interface_up             = pim_zebra_if_state_up;
-  zclient->interface_down           = pim_zebra_if_state_down;
-  zclient->interface_address_add    = pim_zebra_if_address_add;
-  zclient->interface_address_delete = pim_zebra_if_address_del;
-  zclient->ipv4_route_add           = redist_read_ipv4_route;
-  zclient->ipv4_route_delete        = redist_read_ipv4_route;
-
-  zclient_init(zclient, ZEBRA_ROUTE_PIM);
+  qpim_zclient_update = zclient_new();
+
+  qpim_zclient_update->zclient_broken           = zclient_broken;
+  qpim_zclient_update->router_id_update         = pim_router_id_update_zebra;
+  qpim_zclient_update->interface_add            = pim_zebra_if_add;
+  qpim_zclient_update->interface_delete         = pim_zebra_if_del;
+  qpim_zclient_update->interface_up             = pim_zebra_if_state_up;
+  qpim_zclient_update->interface_down           = pim_zebra_if_state_down;
+  qpim_zclient_update->interface_address_add    = pim_zebra_if_address_add;
+  qpim_zclient_update->interface_address_delete = pim_zebra_if_address_del;
+  qpim_zclient_update->ipv4_route_add           = redist_read_ipv4_route;
+  qpim_zclient_update->ipv4_route_delete        = redist_read_ipv4_route;
+
+  zclient_init(qpim_zclient_update, ZEBRA_ROUTE_PIM);
   zlog_info("zclient_init cleared redistribution request");
 
-  zassert(zclient->redist_default == ZEBRA_ROUTE_PIM);
+  zassert(qpim_zclient_update->redist_default == ZEBRA_ROUTE_PIM);
 
   /* Request all redistribution */
   for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
-    if (i == zclient->redist_default)
+    if (i == qpim_zclient_update->redist_default)
       continue;
-    zclient->redist[i] = 1;
+    qpim_zclient_update->redist[i] = 1;
     zlog_info("%s: requesting redistribution for %s (%i)", 
 	      __PRETTY_FUNCTION__, zebra_route_string(i), i);
   }
 
   /* Request default information */
-  zclient->default_information = 1;
+  qpim_zclient_update->default_information = 1;
   zlog_info("%s: requesting default information redistribution",
 	    __PRETTY_FUNCTION__);
 

+ 1 - 0
pimd/pimd.c

@@ -51,6 +51,7 @@ int                       qpim_mroute_oif_highest_vif_index = -1;
 struct list              *qpim_channel_oil_list = 0;
 int                       qpim_t_periodic = PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
 struct list              *qpim_upstream_list = 0;
+struct zclient           *qpim_zclient_update = 0;
 struct zclient           *qpim_zclient_lookup = 0;
 struct pim_assert_metric  qpim_infinite_assert_metric;
 long                      qpim_rpf_cache_refresh_delay_msec = 10000;

+ 1 - 0
pimd/pimd.h

@@ -80,6 +80,7 @@ struct list              *qpim_channel_oil_list; /* list of struct channel_oil *
 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;