Browse Source

[pim] show ip igmp join

Everton Marques 9 years ago
parent
commit
567f927c39
5 changed files with 87 additions and 4 deletions
  1. 1 0
      pimd/COMMANDS
  2. 69 0
      pimd/pim_cmd.c
  3. 15 3
      pimd/pim_iface.c
  4. 1 0
      pimd/pim_igmp.h
  5. 1 1
      pimd/pim_version.h

+ 1 - 0
pimd/COMMANDS

@@ -14,6 +14,7 @@ interface configuration commands:
 
 verification commands:
        show ip igmp interface			IGMP interface information
+       show ip igmp join			IGMP static join information
        show ip igmp parameters			IGMP parameters information
        show ip igmp groups			IGMP groups information
        show ip igmp groups retransmissions	IGMP group retransmission

+ 69 - 0
pimd/pim_cmd.c

@@ -34,6 +34,7 @@
 #include "pim_vty.h"
 #include "pim_mroute.h"
 #include "pim_str.h"
+#include "pim_igmp.h"
 #include "pim_igmpv3.h"
 #include "pim_sock.h"
 #include "pim_time.h"
@@ -455,6 +456,59 @@ static void igmp_show_interfaces(struct vty *vty)
   }
 }
 
+static void igmp_show_interface_join(struct vty *vty)
+{
+  struct listnode  *node;
+  struct interface *ifp;
+  time_t            now;
+  
+  now = pim_time_monotonic_sec();
+
+  vty_out(vty,
+	  "Interface Address         Source          Group           Socket Uptime  %s",
+	  VTY_NEWLINE);
+
+  for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
+    struct pim_interface *pim_ifp;
+    struct listnode *join_node;
+    struct igmp_join *ij;
+    struct in_addr pri_addr;
+    char pri_addr_str[100];
+
+    pim_ifp = ifp->info;
+    
+    if (!pim_ifp)
+      continue;
+
+    if (!pim_ifp->igmp_join_list)
+      continue;
+
+    pri_addr = pim_find_primary_addr(ifp);
+    pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
+
+    for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, join_node, ij)) {
+      char group_str[100];
+      char source_str[100];
+      char uptime[10];
+
+      pim_time_uptime(uptime, sizeof(uptime), now - ij->sock_creation);
+      pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
+      pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
+      
+      vty_out(vty, "%-9s %-15s %-15s %-15s %6d %8s%s",
+	      ifp->name,
+	      pri_addr_str,
+	      source_str,
+	      group_str,
+	      ij->sock_fd,
+	      uptime,
+	      VTY_NEWLINE);
+    } /* for (pim_ifp->igmp_join_list) */
+
+  } /* for (iflist) */
+
+}
+
 static void show_interface_address(struct vty *vty)
 {
   struct listnode  *ifpnode;
@@ -1547,6 +1601,19 @@ DEFUN (show_ip_igmp_interface,
   return CMD_SUCCESS;
 }
 
+DEFUN (show_ip_igmp_join,
+       show_ip_igmp_join_cmd,
+       "show ip igmp join",
+       SHOW_STR
+       IP_STR
+       IGMP_STR
+       "IGMP static join information\n")
+{
+  igmp_show_interface_join(vty);
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (show_ip_igmp_groups,
        show_ip_igmp_groups_cmd,
        "show ip igmp groups",
@@ -4140,6 +4207,7 @@ void pim_cmd_init()
   install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd); 
 
   install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
   install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
   install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
   install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
@@ -4175,6 +4243,7 @@ void pim_cmd_init()
   install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
 
   install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);
   install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
   install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
   install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);

+ 15 - 3
pimd/pim_iface.c

@@ -38,6 +38,7 @@
 #include "pim_ifchannel.h"
 #include "pim_rand.h"
 #include "pim_sock.h"
+#include "pim_time.h"
 #include "pim_ssmpingd.h"
 
 static void pim_if_igmp_join_del_all(struct interface *ifp);
@@ -917,9 +918,10 @@ static struct igmp_join *igmp_join_new(struct interface *ifp,
     return 0;
   }
 
-  ij->sock_fd     = join_fd;
-  ij->group_addr  = group_addr;
-  ij->source_addr = source_addr;
+  ij->sock_fd       = join_fd;
+  ij->group_addr    = group_addr;
+  ij->source_addr   = source_addr;
+  ij->sock_creation = pim_time_monotonic_sec();
 
   listnode_add(pim_ifp->igmp_join_list, ij);
 
@@ -975,6 +977,16 @@ int pim_if_igmp_join_add(struct interface *ifp,
     return -4;
   }
 
+  {
+    char group_str[100];
+    char source_str[100];
+    pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
+    pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
+    zlog_info("%s: issued static igmp join for channel (S,G)=(%s,%s) on interface %s",
+	      __PRETTY_FUNCTION__,
+	      source_str, group_str, ifp->name);
+  }
+
   return 0;
 }
 

+ 1 - 0
pimd/pim_igmp.h

@@ -70,6 +70,7 @@ struct igmp_join {
   struct in_addr group_addr;
   struct in_addr source_addr;
   int            sock_fd;
+  time_t         sock_creation;
 };
 
 struct igmp_sock {

+ 1 - 1
pimd/pim_version.h

@@ -23,7 +23,7 @@
 #ifndef PIM_VERSION_H
 #define PIM_VERSION_H
 
-#define PIMD_VERSION_STR "0.159"
+#define PIMD_VERSION_STR "0.160"
 
 const char * const PIMD_VERSION;