]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Add 'test pim keepalive-reset A.B.C.D A.B.C.D' command
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 Feb 2019 22:21:39 +0000 (17:21 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 21 Feb 2019 00:26:05 +0000 (19:26 -0500)
Add a test command to pim that allows you to reset the keepalive timer
for an upstream to it's max value.  This is to allow purposeful testing
of cleanup code in pim, by forcing the keeaplive timer to expire later.

robot# show ip pim upstream
Iif       Source          Group           State       Uptime   JoinTimer RSTimer   KATimer   RefCnt
enp3s0    192.168.201.136 225.1.0.0       NotJ,RegP   00:00:10 00:00:52  00:00:25  00:02:54       1
robot# show ip pim upstream
Iif       Source          Group           State       Uptime   JoinTimer RSTimer   KATimer   RefCnt
enp3s0    192.168.201.136 225.1.0.0       NotJ,RegP   00:00:11 00:00:51  00:00:24  00:02:53       1
robot# test pim keep 192.168.201.136 225.1.0.0
Setting (192.168.201.136,225.1.0.0) to current keep alive time: 210
robot# show ip pim upstream
Iif       Source          Group           State       Uptime   JoinTimer RSTimer   KATimer   RefCnt
enp3s0    192.168.201.136 225.1.0.0       NotJ,RegP   00:00:27 00:00:35  00:00:08  00:03:27       1
robot#

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

index d2d2445a1553539faa26e48fd11025a8fab248d7..193eddf68a72849be314fed02db13f229306e4df 100644 (file)
@@ -6404,6 +6404,56 @@ static int pim_cmd_interface_add(struct interface *ifp)
        return 1;
 }
 
+DEFPY_HIDDEN (pim_test_sg_keepalive,
+             pim_test_sg_keepalive_cmd,
+             "test pim [vrf NAME$name] keepalive-reset A.B.C.D$source A.B.C.D$group",
+             "Test code\n"
+             PIM_STR
+             VRF_CMD_HELP_STR
+             "Reset the Keepalive Timer\n"
+             "The Source we are resetting\n"
+             "The Group we are resetting\n")
+{
+       struct pim_upstream *up;
+       struct pim_instance *pim;
+       struct prefix_sg sg;
+
+       sg.src = source;
+       sg.grp = group;
+
+       if (!name)
+               pim = pim_get_pim_instance(VRF_DEFAULT);
+       else {
+               struct vrf *vrf = vrf_lookup_by_name(name);
+
+               if (!vrf) {
+                       vty_out(vty, "%% Vrf specified: %s does not exist\n",
+                               name);
+                       return CMD_WARNING;
+               }
+
+               pim = pim_get_pim_instance(vrf->vrf_id);
+       }
+
+       if (!pim) {
+               vty_out(vty, "%% Unable to find pim instance\n");
+               return CMD_WARNING;
+       }
+
+       up = pim_upstream_find(pim, &sg);
+       if (!up) {
+               vty_out(vty, "%% Unable to find %s specified\n",
+                       pim_str_sg_dump(&sg));
+               return CMD_WARNING;
+       }
+
+       vty_out(vty, "Setting %s to current keep alive time: %d\n",
+               pim_str_sg_dump(&sg), pim->keep_alive_time);
+       pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time);
+
+       return CMD_SUCCESS;
+}
+
 DEFPY_HIDDEN (interface_ip_pim_activeactive,
              interface_ip_pim_activeactive_cmd,
              "[no$no] ip pim active-active",
@@ -8667,7 +8717,6 @@ DEFUN (show_ip_msdp_sa_sg_vrf_all,
        return CMD_SUCCESS;
 }
 
-
 void pim_cmd_init(void)
 {
        install_node(&interface_node,
@@ -8676,6 +8725,8 @@ void pim_cmd_init(void)
 
        install_node(&debug_node, pim_debug_config_write);
 
+       install_element(ENABLE_NODE, &pim_test_sg_keepalive_cmd);
+
        install_element(CONFIG_NODE, &ip_pim_rp_cmd);
        install_element(VRF_NODE, &ip_pim_rp_cmd);
        install_element(CONFIG_NODE, &no_ip_pim_rp_cmd);