]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Further refine debugs in pim_sock_read path
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 17 Nov 2016 14:39:56 +0000 (09:39 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:16 +0000 (20:26 -0500)
When we received a packet we were dumping packet information
with debugs on 2 times for each packet where we had overlapping
data being passed.

Since debugs are expensive, reduce the count to 1.

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

index bef3a8a34a3bcee8b6e94cfe98c1f4fbc9bccc74..96d2111ce2cbd7eb2bf68387983a79a185a01e56 100644 (file)
@@ -150,20 +150,8 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
   }
 
   ip_hdr = (struct ip *) buf;
-
-  if (PIM_DEBUG_PIM_PACKETS)
-    {
-      pim_inet4_dump("<src?>", ip_hdr->ip_src, src_str, sizeof(src_str));
-      pim_inet4_dump("<dst?>", ip_hdr->ip_dst, dst_str, sizeof(dst_str));
-    }
-
   ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
 
-  if (PIM_DEBUG_PIM_PACKETS) {
-    zlog_debug("Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
-              src_str, dst_str, ifp->name, len, ip_hlen, ip_hdr->ip_p);
-  }
-
   if (ip_hdr->ip_p != PIM_IP_PROTO_PIM) {
     if (PIM_DEBUG_PIM_PACKETS)
       zlog_debug("IP packet protocol=%d is not PIM=%d",
@@ -174,26 +162,23 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
   if (ip_hlen < PIM_IP_HEADER_MIN_LEN) {
     if (PIM_DEBUG_PIM_PACKETS)
       zlog_debug("IP packet header size=%zu shorter than minimum=%d",
-                ip_hlen, PIM_IP_HEADER_MIN_LEN);
+                ip_hlen, PIM_IP_HEADER_MIN_LEN);
     return -1;
   }
   if (ip_hlen > PIM_IP_HEADER_MAX_LEN) {
     if (PIM_DEBUG_PIM_PACKETS)
       zlog_debug("IP packet header size=%zu greater than maximum=%d",
-                ip_hlen, PIM_IP_HEADER_MAX_LEN);
+                ip_hlen, PIM_IP_HEADER_MAX_LEN);
     return -1;
   }
 
   pim_msg = buf + ip_hlen;
   pim_msg_len = len - ip_hlen;
 
-  if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
-    pim_pkt_dump(__PRETTY_FUNCTION__, pim_msg, pim_msg_len);
-  }
-
   if (pim_msg_len < PIM_PIM_MIN_LEN) {
-    zlog_warn("PIM message size=%d shorter than minimum=%d",
-             pim_msg_len, PIM_PIM_MIN_LEN);
+    if (PIM_DEBUG_PIM_PACKETS)
+      zlog_debug("PIM message size=%d shorter than minimum=%d",
+                pim_msg_len, PIM_PIM_MIN_LEN);
     return -1;
   }
 
@@ -222,9 +207,14 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
   }
 
   if (PIM_DEBUG_PIM_PACKETS) {
+    pim_inet4_dump("<src?>", ip_hdr->ip_src, src_str, sizeof(src_str));
+    pim_inet4_dump("<dst?>", ip_hdr->ip_dst, dst_str, sizeof(dst_str));
     zlog_debug("Recv PIM %s packet from %s to %s on %s: ttl=%d pim_version=%d pim_msg_size=%d checksum=%x",
               pim_pim_msgtype2str (pim_type), src_str, dst_str, ifp->name,
               ip_hdr->ip_ttl, pim_version, pim_msg_len, checksum);
+    if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
+      pim_pkt_dump(__PRETTY_FUNCTION__, pim_msg, pim_msg_len);
+    }
   }
 
   switch (pim_type)
@@ -310,23 +300,6 @@ static int pim_sock_read(struct thread *t)
                              &to, &tolen,
                              &ifindex);
 
-  if (PIM_DEBUG_PIM_PACKETS) {
-    char from_str[INET_ADDRSTRLEN];
-    char to_str[INET_ADDRSTRLEN];
-    
-    if (!inet_ntop(AF_INET, &from.sin_addr, from_str, sizeof(from_str)))
-      sprintf(from_str, "<from?>");
-    if (!inet_ntop(AF_INET, &to.sin_addr, to_str, sizeof(to_str)))
-      sprintf(to_str, "<to?>");
-    
-    zlog_debug("Recv IP PIM pkt size=%d from %s to %s on fd=%d on ifindex=%d (sock_ifindex=%d)",
-              len, from_str, to_str, fd, ifindex, ifp->ifindex);
-
-    if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
-      pim_pkt_dump(__PRETTY_FUNCTION__, buf, len);
-    }
-  }
-
 #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
   /* ifindex sanity check */
   if (ifindex != (int) ifp->ifindex) {