]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Add ability to debug pim Register packets
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 3 Aug 2016 01:44:29 +0000 (21:44 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:04 +0000 (20:26 -0500)
Allow the user to specify the ability to debug
pim register packets.

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

index 9d1602ac40842546377d9ca2e5bcf5a4916890f5..f3d1244e9a3cfeb8b8ea8407148aa5b02fdc6fe4 100644 (file)
@@ -3752,23 +3752,29 @@ DEFUN (debug_pim_packets,
 
 DEFUN (debug_pim_packets_filter,
        debug_pim_packets_filter_cmd,
-       "debug pim packets <hello|joins>",
+       "debug pim packets <hello|joins|register>",
        DEBUG_STR
        DEBUG_PIM_STR
        DEBUG_PIM_PACKETS_STR
        DEBUG_PIM_HELLO_PACKETS_STR
-       DEBUG_PIM_J_P_PACKETS_STR)
+       DEBUG_PIM_J_P_PACKETS_STR
+       DEBUG_PIM_PIM_REG_PACKETS_STR)
 {
   int idx_hello_join = 3;
-    if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) 
+  if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) 
     {
       PIM_DO_DEBUG_PIM_HELLO;
-      vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE);
+      vty_out (vty, "PIM Hello debugging is on%s", VTY_NEWLINE);
     }
-    else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
+  else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
     {
       PIM_DO_DEBUG_PIM_J_P;
-      vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE);
+      vty_out (vty, "PIM Join/Prune debugging is on%s", VTY_NEWLINE);
+    }
+  else if (strncmp(argv[idx_hello_join]->arg,"r",1) == 0)
+    {
+      PIM_DO_DEBUG_PIM_REG;
+      vty_out (vty, "PIM Register debugging is on%s", VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
@@ -3790,7 +3796,7 @@ DEFUN (no_debug_pim_packets,
 
 DEFUN (no_debug_pim_packets_filter,
        no_debug_pim_packets_filter_cmd,
-       "no debug pim packets <hello|joins>",
+       "no debug pim packets <hello|joins|register>",
        NO_STR
        DEBUG_STR
        DEBUG_PIM_STR
@@ -3799,17 +3805,22 @@ DEFUN (no_debug_pim_packets_filter,
        DEBUG_PIM_J_P_PACKETS_STR)
 {
   int idx_hello_join = 4;
-    if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) 
+  if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) 
     {
       PIM_DONT_DEBUG_PIM_HELLO;
       vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE);
     }
-    else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
+  else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
     {
       PIM_DONT_DEBUG_PIM_J_P;
       vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE);
     }
-    return CMD_SUCCESS;
+  else if (strncmp (argv[idx_hello_join]->arg, "r", 1) == 0)
+    {
+      PIM_DONT_DEBUG_PIM_REG;
+      vty_out (vty, "PIM Register debugging is off%s", VTY_NEWLINE);
+    }
+  return CMD_SUCCESS;
 }
 
 
index 6e6e80d4f2c54e21a5960c5af2f595f48149e8de..d5e5c6a30444e826f7e5e7ec1a9a689ada5c0f05 100644 (file)
@@ -48,6 +48,7 @@
 #define DEBUG_PIM_PACKETS_STR                       "PIM protocol packets\n"
 #define DEBUG_PIM_HELLO_PACKETS_STR                 "PIM Hello protocol packets\n"
 #define DEBUG_PIM_J_P_PACKETS_STR                   "PIM Join/Prune protocol packets\n"
+#define DEBUG_PIM_PIM_REG_PACKETS_STR               "PIM Register/Reg-Stop protocol packets\n"
 #define DEBUG_PIM_PACKETDUMP_STR                    "PIM packet dump\n"
 #define DEBUG_PIM_PACKETDUMP_SEND_STR               "Dump sent packets\n"
 #define DEBUG_PIM_PACKETDUMP_RECV_STR               "Dump received packets\n"
index aaf05bbb199bc36512d5a831c6df9e5d365befab..5da8a677ef334897db588ecd9a2d94aceb210f23 100644 (file)
@@ -77,6 +77,12 @@ pim_register_stop_send (struct interface *ifp, struct prefix *sg,
   uint8_t *b1;
   struct prefix p;
 
+  if (PIM_DEBUG_PIM_REG)
+    {
+      zlog_debug ("Sending Register stop for %s to %s on %s",
+                 pim_str_sg_dump (sg), inet_ntoa(originator), ifp->name);
+    }
+
   memset (buffer, 0, 3000);
   b1 = (uint8_t *)buffer + PIM_MSG_REGISTER_STOP_LEN;
 
@@ -120,9 +126,6 @@ pim_register_stop_recv (uint8_t *buf, int buf_size)
   struct prefix sg;
   int l;
 
-  if (PIM_DEBUG_PIM_PACKETDUMP_RECV)
-    pim_pkt_dump ("Received Register Stop", buf, buf_size);
-
   l = pim_parse_addr_group (&group, buf, buf_size);
   buf += l;
   buf_size -= l;
@@ -130,6 +133,13 @@ pim_register_stop_recv (uint8_t *buf, int buf_size)
   memset (&sg, 0, sizeof (struct prefix));
   sg.u.sg.src = source.u.prefix4;
   sg.u.sg.grp = group.u.prefix4;
+
+  if (PIM_DEBUG_PIM_REG)
+    {
+      zlog_debug ("Received Register stop for %s",
+                 pim_str_sg_dump (&sg));
+    }
+
   upstream = pim_upstream_find (&sg);
   if (!upstream)
     {
@@ -162,6 +172,13 @@ pim_register_send (const uint8_t *buf, int buf_size, struct pim_rpf *rpg, int nu
   struct pim_interface *pinfo;
   struct interface *ifp;
 
+  if (PIM_DEBUG_PIM_REG)
+    {
+       char rp_str[100];
+       strcpy (rp_str, inet_ntoa (rpg->rpf_addr));
+       zlog_debug ("Sending %sRegister Packet to %s", null_register ? "NULL " : "", rp_str);
+    }
+
   ifp = rpg->source_nexthop.interface;
   pinfo = (struct pim_interface *)ifp->info;
   if (!pinfo) {
@@ -257,6 +274,14 @@ pim_register_recv (struct interface *ifp,
     return 0;
   }
 
+  if (PIM_DEBUG_PIM_REG)
+    {
+      char src_str[100];
+
+      pim_inet4_dump ("<src?>", src_addr, src_str, sizeof (src_str));
+      zlog_debug ("Received Register message from %s on %s", src_str, ifp->name);
+    }
+
   /*
    * Please note this is not drawn to get the correct bit/data size
    *
index c6fb3464b10a8aa2dddb391b08755765590655fb..9c3df6bbdc58efa02506b2014e63114c40b34f04 100644 (file)
@@ -108,6 +108,11 @@ pim_debug_config_write (struct vty *vty)
     ++writes;
   }
 
+  if (PIM_DEBUG_PIM_REG) {
+    vty_out (vty, "debug pim packets register%s", VTY_NEWLINE);
+    ++writes;
+  }
+
   if (PIM_DEBUG_STATIC) {
     vty_out (vty, "debug pim static%s", VTY_NEWLINE);
     ++writes;
index 6ff36a2a51409194f34e8a0f7b38a44fd9d10292..e91959948ab5adba09c8e542ac36f0b1f69b59e8 100644 (file)
@@ -69,6 +69,7 @@
 #define PIM_MASK_PIM_HELLO           (1 << 14)
 #define PIM_MASK_PIM_J_P             (1 << 15)
 #define PIM_MASK_STATIC              (1 << 16)
+#define PIM_MASK_PIM_REG             (1 << 17)
 
 const char *const PIM_ALL_SYSTEMS;
 const char *const PIM_ALL_ROUTERS;
@@ -135,6 +136,7 @@ extern int32_t qpim_register_probe_time;
 #define PIM_DEBUG_MROUTE              (qpim_debugs & PIM_MASK_MROUTE)
 #define PIM_DEBUG_PIM_HELLO           (qpim_debugs & PIM_MASK_PIM_HELLO)
 #define PIM_DEBUG_PIM_J_P             (qpim_debugs & PIM_MASK_PIM_J_P)
+#define PIM_DEBUG_PIM_REG             (qpim_debugs & PIM_MASK_PIM_REG)
 #define PIM_DEBUG_STATIC              (qpim_debugs & PIM_MASK_STATIC)
 
 #define PIM_DEBUG_EVENTS       (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS))
@@ -155,6 +157,7 @@ extern int32_t qpim_register_probe_time;
 #define PIM_DO_DEBUG_MROUTE              (qpim_debugs |= PIM_MASK_MROUTE)
 #define PIM_DO_DEBUG_PIM_HELLO           (qpim_debugs |= PIM_MASK_PIM_HELLO)
 #define PIM_DO_DEBUG_PIM_J_P             (qpim_debugs |= PIM_MASK_PIM_J_P)
+#define PIM_DO_DEBUG_PIM_REG             (qpim_debugs |= PIM_MASK_PIM_REG)
 #define PIM_DO_DEBUG_STATIC              (qpim_debugs |= PIM_MASK_STATIC)
 
 #define PIM_DONT_DEBUG_PIM_EVENTS          (qpim_debugs &= ~PIM_MASK_PIM_EVENTS)
@@ -171,6 +174,7 @@ extern int32_t qpim_register_probe_time;
 #define PIM_DONT_DEBUG_MROUTE              (qpim_debugs &= ~PIM_MASK_MROUTE)
 #define PIM_DONT_DEBUG_PIM_HELLO           (qpim_debugs &= ~PIM_MASK_PIM_HELLO)
 #define PIM_DONT_DEBUG_PIM_J_P             (qpim_debugs &= ~PIM_MASK_PIM_J_P)
+#define PIM_DONT_DEBUG_PIM_REG             (qpim_debugs &= ~PIM_MASK_PIM_REG)
 #define PIM_DONT_DEBUG_STATIC              (qpim_debugs &= ~PIM_MASK_STATIC)
 
 void pim_init(void);