From 0f055c0d5d2be277d2ecb0271e55620b13f5f341 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 17 Nov 2016 09:39:56 -0500 Subject: [PATCH] pimd: Further refine debugs in pim_sock_read path 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 --- pimd/pim_pim.c | 47 ++++++++++------------------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index bef3a8a34a..96d2111ce2 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -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("", ip_hdr->ip_src, src_str, sizeof(src_str)); - pim_inet4_dump("", 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("", ip_hdr->ip_src, src_str, sizeof(src_str)); + pim_inet4_dump("", 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, ""); - if (!inet_ntop(AF_INET, &to.sin_addr, to_str, sizeof(to_str))) - sprintf(to_str, ""); - - 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) { -- 2.39.5