]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Clarify pim_mroute_[add|del] function debugging
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 6 Dec 2016 15:08:09 +0000 (10:08 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:18 +0000 (20:26 -0500)
When debugging is turned on for 'debug mroute' we
are unable to tell when a mroute has been added
or deleted from the mrib.  Notice when we
do it and who called it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_mroute.c
pimd/pim_mroute.h
pimd/pim_oil.c
pimd/pim_static.c
pimd/pim_upstream.c
pimd/pim_zebra.c

index 6ab6af7ba8d561f43bb2d28ce89b296ab5e6d713..093497d44e8943e3a3eabb9f5dacc5fd603d1f57 100644 (file)
@@ -2303,7 +2303,7 @@ static void mroute_add_all()
   struct channel_oil *c_oil;
 
   for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
-    if (pim_mroute_add(c_oil)) {
+    if (pim_mroute_add(c_oil, __PRETTY_FUNCTION__)) {
       /* just log warning */
       char source_str[INET_ADDRSTRLEN];
       char group_str[INET_ADDRSTRLEN];
@@ -2322,7 +2322,7 @@ static void mroute_del_all()
   struct channel_oil *c_oil;
 
   for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
-    if (pim_mroute_del(c_oil)) {
+    if (pim_mroute_del(c_oil, __PRETTY_FUNCTION__)) {
       /* just log warning */
       char source_str[INET_ADDRSTRLEN];
       char group_str[INET_ADDRSTRLEN];
@@ -2341,7 +2341,7 @@ static void static_mroute_add_all()
   struct static_route *s_route;
 
   for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
-    if (pim_mroute_add(&s_route->c_oil)) {
+    if (pim_mroute_add(&s_route->c_oil, __PRETTY_FUNCTION__)) {
       /* just log warning */
       char source_str[INET_ADDRSTRLEN];
       char group_str[INET_ADDRSTRLEN];
@@ -2360,7 +2360,7 @@ static void static_mroute_del_all()
    struct static_route *s_route;
 
    for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
-     if (pim_mroute_del(&s_route->c_oil)) {
+     if (pim_mroute_del(&s_route->c_oil, __PRETTY_FUNCTION__)) {
        /* just log warning */
        char source_str[INET_ADDRSTRLEN];
        char group_str[INET_ADDRSTRLEN];
index 01fa5295258bdf360bb96b4bf36b8c73f4b877a3..fdae0b9a2244d1ff633513898b0c2f2b2c1d8a46 100644 (file)
@@ -402,7 +402,7 @@ pim_mroute_msg_wrvifwhole (int fd, struct interface *ifp, const char *buf)
             up->channel_oil = pim_channel_oil_add (&sg, pim_ifp->mroute_vif_index);
           pim_upstream_inherited_olist (up);
           if (!up->channel_oil->installed)
-            pim_mroute_add (up->channel_oil);
+            pim_mroute_add (up->channel_oil, __PRETTY_FUNCTION__);
          pim_upstream_set_sptbit (up, ifp);
        }
       else
@@ -423,7 +423,7 @@ pim_mroute_msg_wrvifwhole (int fd, struct interface *ifp, const char *buf)
   pim_ifp = ifp->info;
   oil = pim_channel_oil_add (&sg, pim_ifp->mroute_vif_index);
   if (!oil->installed)
-    pim_mroute_add (oil);
+    pim_mroute_add (oil, __PRETTY_FUNCTION__);
   if (pim_if_connected_to_source (ifp, sg.src))
     {
       up = pim_upstream_add (&sg, ifp, PIM_UPSTREAM_FLAG_MASK_FHR, __PRETTY_FUNCTION__);
@@ -745,7 +745,7 @@ int pim_mroute_del_vif(int vif_index)
   return 0;
 }
 
-int pim_mroute_add(struct channel_oil *c_oil)
+int pim_mroute_add(struct channel_oil *c_oil, const char *name)
 {
   int err;
   int orig = 0;
@@ -805,11 +805,22 @@ int pim_mroute_add(struct channel_oil *c_oil)
     return -2;
   }
 
+  if (PIM_DEBUG_MROUTE)
+    {
+      struct prefix_sg sg;
+
+      sg.src = c_oil->oil.mfcc_origin;
+      sg.grp = c_oil->oil.mfcc_mcastgrp;
+
+      zlog_debug("%s(%s), Added Route: %s to mroute table",
+                __PRETTY_FUNCTION__, name, pim_str_sg_dump(&sg));
+    }
+
   c_oil->installed = 1;
   return 0;
 }
 
-int pim_mroute_del (struct channel_oil *c_oil)
+int pim_mroute_del (struct channel_oil *c_oil, const char *name)
 {
   int err;
 
@@ -832,6 +843,16 @@ int pim_mroute_del (struct channel_oil *c_oil)
     return -2;
   }
 
+  if (PIM_DEBUG_MROUTE)
+    {
+      struct prefix_sg sg;
+
+      sg.src = c_oil->oil.mfcc_origin;
+      sg.grp = c_oil->oil.mfcc_mcastgrp;
+
+      zlog_debug("%s(%s), Deleted Route: %s from mroute table",
+                __PRETTY_FUNCTION__, name, pim_str_sg_dump(&sg));
+    }
   c_oil->installed = 0;
 
   return 0;
index ce300f0ab0a5d2fce29c583ba10f6f499b79af2b..b3f56aa724bc5252f0abc5401758b4ebff3b2034 100644 (file)
@@ -172,8 +172,8 @@ int pim_mroute_socket_disable(void);
 int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr, unsigned char flags);
 int pim_mroute_del_vif(int vif_index);
 
-int pim_mroute_add(struct channel_oil *c_oil);
-int pim_mroute_del(struct channel_oil *c_oil);
+int pim_mroute_add(struct channel_oil *c_oil, const char *name);
+int pim_mroute_del(struct channel_oil *c_oil, const char *name);
 
 int pim_mroute_msg(int fd, const char *buf, int buf_size);
 
index 6e77afd40a01400c831e4e755467d2ec003ac149..e002de03003e7374d156c198c160c16e4546c75a 100644 (file)
@@ -247,7 +247,7 @@ pim_channel_del_oif (struct channel_oil *channel_oil,
 
   channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = 0;
 
-  if (pim_mroute_add (channel_oil)) {
+  if (pim_mroute_add (channel_oil, __PRETTY_FUNCTION__)) {
     if (PIM_DEBUG_MROUTE)
       {
         char group_str[INET_ADDRSTRLEN];
@@ -387,7 +387,7 @@ int pim_channel_add_oif(struct channel_oil *channel_oil,
 
   channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = PIM_MROUTE_MIN_TTL;
 
-  if (pim_mroute_add(channel_oil)) {
+  if (pim_mroute_add(channel_oil, __PRETTY_FUNCTION__)) {
     if (PIM_DEBUG_MROUTE)
       {
        char group_str[INET_ADDRSTRLEN];
index 443e7cacaa8a13bf49cf8b0d7682920cd1436fe0..c3c40ff210775a95c9ad0d25112aef3883dec21e 100644 (file)
@@ -175,7 +175,7 @@ int pim_static_add(struct interface *iif, struct interface *oif, struct in_addr
       listnode_add(qpim_static_route_list, s_route);
    }
 
-   if (pim_mroute_add(&s_route->c_oil))
+   if (pim_mroute_add(&s_route->c_oil, __PRETTY_FUNCTION__))
    {
       char gifaddr_str[INET_ADDRSTRLEN];
       char sifaddr_str[INET_ADDRSTRLEN];
@@ -254,23 +254,23 @@ int pim_static_del(struct interface *iif, struct interface *oif, struct in_addr
 
          /* If there are no more outputs then delete the whole route, otherwise set the route with the new outputs */
          if (s_route->c_oil.oil_ref_count <= 0 ?
-                 pim_mroute_del(&s_route->c_oil) : pim_mroute_add(&s_route->c_oil)) {
-            char gifaddr_str[INET_ADDRSTRLEN];
-            char sifaddr_str[INET_ADDRSTRLEN];
-            pim_inet4_dump("<ifaddr?>", group, gifaddr_str, sizeof(gifaddr_str));
-            pim_inet4_dump("<ifaddr?>", source, sifaddr_str, sizeof(sifaddr_str));
-            zlog_warn("%s %s: Unable to remove static route(iif=%d,oif=%d,group=%s,source=%s)",
+            pim_mroute_del(&s_route->c_oil, __PRETTY_FUNCTION__) : pim_mroute_add(&s_route->c_oil, __PRETTY_FUNCTION__)) {
+          char gifaddr_str[INET_ADDRSTRLEN];
+          char sifaddr_str[INET_ADDRSTRLEN];
+          pim_inet4_dump("<ifaddr?>", group, gifaddr_str, sizeof(gifaddr_str));
+          pim_inet4_dump("<ifaddr?>", source, sifaddr_str, sizeof(sifaddr_str));
+          zlog_warn("%s %s: Unable to remove static route(iif=%d,oif=%d,group=%s,source=%s)",
                      __FILE__, __PRETTY_FUNCTION__,
                      iif_index,
                      oif_index,
                      gifaddr_str,
                      sifaddr_str);
 
-            s_route->oif_ttls[oif_index] = 1;
-            s_route->c_oil.oil.mfcc_ttls[oif_index] = 1;
-            ++s_route->c_oil.oil_ref_count;
+          s_route->oif_ttls[oif_index] = 1;
+          s_route->c_oil.oil.mfcc_ttls[oif_index] = 1;
+          ++s_route->c_oil.oil_ref_count;
 
-            return -1;
+          return -1;
          }
 
          s_route->c_oil.oif_creation[oif_index] = 0;
index 90adf606156979dd4b90aa4cda539bb0daad61b1..2b76cb91729355afc1c79a43d3f2746ceb06d39c 100644 (file)
@@ -188,7 +188,7 @@ pim_upstream_del(struct pim_upstream *up, const char *name)
   }
 
   pim_upstream_remove_children (up);
-  pim_mroute_del (up->channel_oil);
+  pim_mroute_del (up->channel_oil, __PRETTY_FUNCTION__);
   upstream_channel_oil_detach(up);
 
   if (up->sources)
index 4b8c36fbe12aa1f04bdef299175f12253fda4b23..cfce8909d677226154f6b51a04aada41c91b5cef 100644 (file)
@@ -379,7 +379,7 @@ static void scan_upstream_rpf_cache()
         * so install it.
         */
        if (up->channel_oil && !up->channel_oil->installed)
-          pim_mroute_add (up->channel_oil);
+          pim_mroute_add (up->channel_oil, __PRETTY_FUNCTION__);
 
        /*
          RFC 4601: 4.5.7.  Sending (S,G) Join/Prune Messages
@@ -442,14 +442,14 @@ pim_scan_individual_oil (struct channel_oil *c_oil)
                     __FILE__, __PRETTY_FUNCTION__, c_oil->oil.mfcc_parent,
                     source_str, group_str);
         }
-      pim_mroute_del (c_oil);
+      pim_mroute_del (c_oil, __PRETTY_FUNCTION__);
       return;
     }
 
   if (input_iface_vif_index == c_oil->oil.mfcc_parent)
     {
       if (!c_oil->installed)
-        pim_mroute_add (c_oil);
+        pim_mroute_add (c_oil, __PRETTY_FUNCTION__);
 
       /* RPF unchanged */
       return;
@@ -494,7 +494,7 @@ pim_scan_individual_oil (struct channel_oil *c_oil)
     c_oil->oil.mfcc_parent = input_iface_vif_index;
 
     /* update kernel multicast forwarding cache (MFC) */
-    if (pim_mroute_add(c_oil))
+    if (pim_mroute_add(c_oil, __PRETTY_FUNCTION__))
       {
        if (PIM_DEBUG_MROUTE)
          {
@@ -931,7 +931,7 @@ static int del_oif(struct channel_oil *channel_oil,
 
   channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = 0;
 
-  if (pim_mroute_add(channel_oil)) {
+  if (pim_mroute_add(channel_oil, __PRETTY_FUNCTION__)) {
     char group_str[INET_ADDRSTRLEN];
     char source_str[INET_ADDRSTRLEN];
     pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
@@ -948,7 +948,7 @@ static int del_oif(struct channel_oil *channel_oil,
   --channel_oil->oil_size;
 
   if (channel_oil->oil_size < 1) {
-    if (pim_mroute_del(channel_oil)) {
+    if (pim_mroute_del(channel_oil, __PRETTY_FUNCTION__)) {
       if (PIM_DEBUG_MROUTE)
        {
          /* just log a warning in case of failure */