pimd: Cleanup zebra debugs to be protected by debug commands

pimd is very chatty without any pim debugs turned on.
This commit fixes a bunch of the debugs to be protected
by appropriate pim debug statement.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 6f806a1..de56d04 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -256,14 +256,14 @@
 {
   struct pim_interface *pim_ifp;
 
-  {
+  if (PIM_DEBUG_ZEBRA) {
     char old_str[100];
     char new_str[100];
     pim_inet4_dump("<old?>", old_addr, old_str, sizeof(old_str));
     pim_inet4_dump("<new?>", new_addr, new_str, sizeof(new_str));
-    zlog_info("%s: %s: primary address changed from %s to %s on interface %s",
-	      __PRETTY_FUNCTION__, caller,
-	      old_str, new_str, ifp->name);
+    zlog_debug("%s: %s: primary address changed from %s to %s on interface %s",
+	       __PRETTY_FUNCTION__, caller,
+	       old_str, new_str, ifp->name);
   }
 
   pim_ifp = ifp->info;
@@ -329,8 +329,8 @@
     return;
 
   changed = 1; /* true */
-  zlog_debug("FIXME T31 C15 %s: on interface %s: acting on any addr change",
-	     __PRETTY_FUNCTION__, ifp->name);
+  zlog_info("FIXME T31 C15 %s: on interface %s: acting on any addr change",
+	    __PRETTY_FUNCTION__, ifp->name);
 
   if (PIM_DEBUG_ZEBRA) {
     zlog_debug("%s: on interface %s: %s",
@@ -382,7 +382,7 @@
   if (!if_is_operative(ifp))
     return;
 
-  /* if (PIM_DEBUG_ZEBRA) */ {
+  if (PIM_DEBUG_ZEBRA) {
     char buf[BUFSIZ];
     prefix2str(ifc->address, buf, BUFSIZ);
     zlog_debug("%s: %s ifindex=%d connected IP address %s %s",
@@ -501,7 +501,7 @@
   ifp = ifc->ifp;
   zassert(ifp);
 
-  /* if (PIM_DEBUG_ZEBRA) */ {
+  if (PIM_DEBUG_ZEBRA) {
     char buf[BUFSIZ];
     prefix2str(ifc->address, buf, BUFSIZ);
     zlog_debug("%s: %s ifindex=%d disconnected IP address %s %s",
@@ -1055,14 +1055,14 @@
     return -4;
   }
 
-  {
+  if (PIM_DEBUG_IGMP_EVENTS) {
     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_debug("%s: issued static igmp join for channel (S,G)=(%s,%s) on interface %s",
-	       __PRETTY_FUNCTION__,
-	       source_str, group_str, ifp->name);
+	      __PRETTY_FUNCTION__,
+	      source_str, group_str, ifp->name);
   }
 
   return 0;
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index e253a0e..e801f4e 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -103,9 +103,11 @@
   enum pim_ifjoin_state old_state = ch->ifjoin_state;
 
   if (old_state == new_state) {
-    zlog_debug("%s calledby %s: non-transition on state %d (%s)",
-	       __PRETTY_FUNCTION__, caller, new_state,
-	       pim_ifchannel_ifjoin_name(new_state));
+    if (PIM_DEBUG_PIM_EVENTS) {
+      zlog_debug("%s calledby %s: non-transition on state %d (%s)",
+		 __PRETTY_FUNCTION__, caller, new_state,
+		 pim_ifchannel_ifjoin_name(new_state));
+    }
     return;
   }
 
@@ -286,7 +288,7 @@
   if (ch->local_ifmembership == membership)
     return;
 
-  /* if (PIM_DEBUG_PIM_EVENTS) */ {
+  if (PIM_DEBUG_PIM_EVENTS) {
     char src_str[100];
     char grp_str[100];
     pim_inet4_dump("<src?>", ch->source_addr, src_str, sizeof(src_str));
diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c
index 72a3538..8932dc3 100644
--- a/pimd/pim_neighbor.c
+++ b/pimd/pim_neighbor.c
@@ -125,7 +125,7 @@
   /* DR changed ? */
   if (old_dr_addr.s_addr != pim_ifp->pim_dr_addr.s_addr) {
 
-    /* if (PIM_DEBUG_PIM_EVENTS) */ {
+    if (PIM_DEBUG_PIM_EVENTS) {
       char dr_old_str[100];
       char dr_new_str[100];
       pim_inet4_dump("<old_dr?>", old_dr_addr, dr_old_str, sizeof(dr_old_str));
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c
index dedc60a..38339da 100644
--- a/pimd/pim_rpf.c
+++ b/pimd/pim_rpf.c
@@ -61,7 +61,7 @@
   if (num_ifindex > 1) {
     char addr_str[100];
     pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-    zlog_debug("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)",
+    zlog_info("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)",
 	      __FILE__, __PRETTY_FUNCTION__,
 	      num_ifindex, addr_str, first_ifindex);
     /* debug warning only, do not return */
@@ -136,22 +136,22 @@
   }
 
   rpf->rpf_addr = pim_rpf_find_rpf_addr(up);
-  if (PIM_INADDR_IS_ANY(rpf->rpf_addr)) {
+  if (PIM_INADDR_IS_ANY(rpf->rpf_addr) && PIM_DEBUG_PIM_EVENTS) {
     /* RPF'(S,G) not found */
     char src_str[100];
     char grp_str[100];
     pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
     pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
-    zlog_warn("%s %s: RPF'(%s,%s) not found: won't send join upstream",
-              __FILE__, __PRETTY_FUNCTION__,
-              src_str, grp_str);
+    zlog_debug("%s %s: RPF'(%s,%s) not found: won't send join upstream",
+	       __FILE__, __PRETTY_FUNCTION__,
+	       src_str, grp_str);
     /* warning only */
   }
 
   /* detect change in pim_nexthop */
   if (nexthop_mismatch(&rpf->source_nexthop, &save_nexthop)) {
 
-    /* if (PIM_DEBUG_PIM_EVENTS) */ {
+    if (PIM_DEBUG_PIM_EVENTS) {
       char src_str[100];
       char grp_str[100];
       char nhaddr_str[100];
@@ -176,7 +176,7 @@
   /* detect change in RPF_interface(S) */
   if (save_nexthop.interface != rpf->source_nexthop.interface) {
 
-    /* if (PIM_DEBUG_PIM_EVENTS) */ {
+    if (PIM_DEBUG_PIM_EVENTS) {
       char src_str[100];
       char grp_str[100];
       pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
diff --git a/pimd/pim_signals.c b/pimd/pim_signals.c
index d1350b0..afd0259 100644
--- a/pimd/pim_signals.c
+++ b/pimd/pim_signals.c
@@ -36,7 +36,7 @@
 
 static void pim_sighup()
 {
-  zlog_debug ("SIGHUP received, ignoring");
+  zlog_info ("SIGHUP received, ignoring");
 }
 
 static void pim_sigint()
@@ -55,7 +55,7 @@
 
 static void pim_sigusr1()
 {
-  zlog_debug ("SIGUSR1 received");
+  zlog_info ("SIGUSR1 received");
   zlog_rotate (NULL);
 }
 
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index 1a39271..3ca9edd 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -762,7 +762,7 @@
   if (num_ifindex > 1) {
     char addr_str[100];
     pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-    zlog_debug("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)",
+    zlog_info("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)",
 	       __FILE__, __PRETTY_FUNCTION__,
 	       num_ifindex, addr_str, first_ifindex);
     /* debug warning only, do not return */
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 297a2a8..b5b219e 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -283,14 +283,14 @@
       nexthop_tab[num_ifindex].ifindex             = 0;
       nexthop_tab[num_ifindex].protocol_distance   = distance;
       nexthop_tab[num_ifindex].route_metric        = metric;
-      {
+      if (PIM_DEBUG_ZEBRA) {
 	char addr_str[100];
 	char nexthop_str[100];
 	pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
 	pim_inet4_dump("<nexthop?>", nexthop_tab[num_ifindex].nexthop_addr, nexthop_str, sizeof(nexthop_str));
-	zlog_warn("%s %s: zebra returned recursive nexthop %s for address %s",
-		  __FILE__, __PRETTY_FUNCTION__,
-		  nexthop_str, addr_str);
+	zlog_debug("%s %s: zebra returned recursive nexthop %s for address %s",
+		   __FILE__, __PRETTY_FUNCTION__,
+		   nexthop_str, addr_str);
       }
       ++num_ifindex;
       break;
@@ -375,7 +375,7 @@
 
     num_ifindex = zclient_lookup_nexthop_once(qpim_zclient_lookup, nexthop_tab,
 					      PIM_NEXTHOP_IFINDEX_TAB_SIZE, addr);
-    if (num_ifindex < 1) {
+    if ((num_ifindex < 1) && PIM_DEBUG_ZEBRA) {
       char addr_str[100];
       pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
       zlog_warn("%s %s: lookup=%d/%d: could not find nexthop ifindex for address %s",
@@ -400,15 +400,15 @@
     if (first_ifindex > 0) {
       /* found: first ifindex is non-recursive nexthop */
 
-      if (lookup > 0) {
+      if ((lookup > 0) && PIM_DEBUG_ZEBRA) {
 	/* Report non-recursive success after first lookup */
 	char addr_str[100];
 	pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-	zlog_info("%s %s: lookup=%d/%d: found non-recursive ifindex=%d for address %s dist=%d met=%d",
-		  __FILE__, __PRETTY_FUNCTION__,
-		  lookup, max_lookup, first_ifindex, addr_str,
-		  nexthop_tab[0].protocol_distance,
-		  nexthop_tab[0].route_metric);
+	zlog_debug("%s %s: lookup=%d/%d: found non-recursive ifindex=%d for address %s dist=%d met=%d",
+		   __FILE__, __PRETTY_FUNCTION__,
+		   lookup, max_lookup, first_ifindex, addr_str,
+		   nexthop_tab[0].protocol_distance,
+		   nexthop_tab[0].route_metric);
 
 	/* use last address as nexthop address */
 	nexthop_tab[0].nexthop_addr = addr;
@@ -421,12 +421,12 @@
       return num_ifindex;
     }
 
-    {
+    if (PIM_DEBUG_ZEBRA) {
       char addr_str[100];
       char nexthop_str[100];
       pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
       pim_inet4_dump("<nexthop?>", nexthop_addr, nexthop_str, sizeof(nexthop_str));
-      zlog_warn("%s %s: lookup=%d/%d: zebra returned recursive nexthop %s for address %s dist=%d met=%d",
+      zlog_debug("%s %s: lookup=%d/%d: zebra returned recursive nexthop %s for address %s dist=%d met=%d",
 		__FILE__, __PRETTY_FUNCTION__,
 		lookup, max_lookup, nexthop_str, addr_str,
 		nexthop_tab[0].protocol_distance,
@@ -437,11 +437,13 @@
 
   } /* for (max_lookup) */
 
-  char addr_str[100];
-  pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-  zlog_warn("%s %s: lookup=%d/%d: failure searching recursive nexthop ifindex for address %s",
-	    __FILE__, __PRETTY_FUNCTION__,
-	    lookup, max_lookup, addr_str);
+  if (PIM_DEBUG_ZEBRA) {
+    char addr_str[100];
+    pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
+    zlog_warn("%s %s: lookup=%d/%d: failure searching recursive nexthop ifindex for address %s",
+	      __FILE__, __PRETTY_FUNCTION__,
+	      lookup, max_lookup, addr_str);
+  }
 
   return -2;
 }