Browse Source

pimd: Remove unused pim checksum in favour of quagga's version.

Everton Marques 5 years ago
parent
commit
93911267a3
9 changed files with 6 additions and 55 deletions
  1. 0 2
      pimd/Makefile.am
  2. 1 1
      pimd/pim_cmd.c
  3. 2 2
      pimd/pim_igmp.c
  4. 1 1
      pimd/pim_igmpv3.c
  5. 0 4
      pimd/pim_main.c
  6. 1 1
      pimd/pim_msg.c
  7. 1 1
      pimd/pim_pim.c
  8. 0 37
      pimd/pim_util.c
  9. 0 6
      pimd/pim_util.h

+ 0 - 2
pimd/Makefile.am

@@ -22,7 +22,6 @@
 # PIM_DEBUG_BYDEFAULT: Automatically enables all pimd "debug ..." commands
 # PIM_ZCLIENT_DEBUG: Support for internal ZEBRA client debugging
 # PIM_MOTD_VERSION: Includes pimd version in default MOTD
-# PIM_USE_QUAGGA_INET_CHECKSUM: Prefer Quagga inet checksum
 # PIM_CHECK_RECV_IFINDEX_SANITY: Compare socket ifindex with recv ifindex
 # PIM_REPORT_RECV_IFINDEX_MISMATCH: Report sock/recv ifindex mismatch
 # PIM_ENFORCE_LOOPFREE_MFC: Refuse adding looping MFC entries
@@ -36,7 +35,6 @@ PIM_DEFS += -DPIM_CHECK_RECV_IFINDEX_SANITY
 #PIM_DEFS += -DPIM_REPORT_RECV_IFINDEX_MISMATCH
 PIM_DEFS += -DPIM_ZCLIENT_DEBUG
 PIM_DEFS += -DPIM_MOTD_VERSION
-PIM_DEFS += -DPIM_USE_QUAGGA_INET_CHECKSUM
 PIM_DEFS += -DPIM_ENFORCE_LOOPFREE_MFC
 #PIM_DEFS += -DPIM_UNEXPECTED_KERNEL_UPCALL
 #PIM_DEFS += -DPIM_USE_QUAGGA_GETTIME

+ 1 - 1
pimd/pim_cmd.c

@@ -3590,7 +3590,7 @@ DEFUN (test_igmp_receive_report,
   igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4);   /* v3 report for one single group record */
 
   /* compute checksum */
-  *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = pim_inet_checksum(igmp_msg, igmp_msg_len);
+  *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = in_cksum(igmp_msg, igmp_msg_len);
 
   /* "receive" message */
 

+ 2 - 2
pimd/pim_igmp.c

@@ -299,7 +299,7 @@ static int recv_igmp_query(struct igmp_sock *igmp, int query_version,
   /* for computing checksum */
   *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0;
 
-  checksum = pim_inet_checksum(igmp_msg, igmp_msg_len);
+  checksum = in_cksum(igmp_msg, igmp_msg_len);
   if (checksum != recv_checksum) {
     zlog_warn("Recv IGMP query v%d from %s on %s: checksum mismatch: received=%x computed=%x",
 	      query_version, from_str, ifp->name, recv_checksum, checksum);
@@ -470,7 +470,7 @@ static int igmp_v3_report(struct igmp_sock *igmp,
   /* for computing checksum */
   *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0;
 
-  checksum = pim_inet_checksum(igmp_msg, igmp_msg_len);
+  checksum = in_cksum(igmp_msg, igmp_msg_len);
   if (checksum != recv_checksum) {
     zlog_warn("Recv IGMP report v3 from %s on %s: checksum mismatch: received=%x computed=%x",
 	      from_str, ifp->name, recv_checksum, checksum);

+ 1 - 1
pimd/pim_igmpv3.c

@@ -1651,7 +1651,7 @@ void pim_igmp_send_membership_query(struct igmp_group *group,
   query_buf[9]                                         = qqic;
   *(uint16_t *)(query_buf + IGMP_V3_NUMSOURCES_OFFSET) = htons(num_sources);
 
-  checksum = pim_inet_checksum(query_buf, msg_size);
+  checksum = in_cksum(query_buf, msg_size);
   *(uint16_t *)(query_buf + IGMP_V3_CHECKSUM_OFFSET) = checksum;
 
   if (PIM_DEBUG_IGMP_PACKETS) {

+ 0 - 4
pimd/pim_main.c

@@ -281,10 +281,6 @@ Hello, this is " QUAGGA_PROGNAME " " QUAGGA_VERSION " " PIMD_PROGNAME " " PIMD_V
 #endif
 #endif
 
-#ifdef PIM_USE_QUAGGA_INET_CHECKSUM
-  zlog_notice("PIM_USE_QUAGGA_INET_CHECKSUM: using Quagga's builtin checksum");
-#endif
-
 #ifdef PIM_UNEXPECTED_KERNEL_UPCALL
   zlog_notice("PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
 #endif

+ 1 - 1
pimd/pim_msg.c

@@ -46,7 +46,7 @@ void pim_msg_build_header(uint8_t *pim_msg, int pim_msg_size,
    */
 
   *(uint16_t *) PIM_MSG_HDR_OFFSET_CHECKSUM(pim_msg) = 0;
-  checksum = pim_inet_checksum(pim_msg, pim_msg_size);
+  checksum = in_cksum(pim_msg, pim_msg_size);
   *(uint16_t *) PIM_MSG_HDR_OFFSET_CHECKSUM(pim_msg) = checksum;
 }
 

+ 1 - 1
pimd/pim_pim.c

@@ -194,7 +194,7 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
   /* for computing checksum */
   *(uint16_t *) PIM_MSG_HDR_OFFSET_CHECKSUM(pim_msg) = 0;
 
-  checksum = pim_inet_checksum(pim_msg, pim_msg_len);
+  checksum = in_cksum(pim_msg, pim_msg_len);
   if (checksum != pim_checksum) {
     zlog_warn("Ignoring PIM pkt from %s with invalid checksum: received=%x calculated=%x",
 	      ifp->name, pim_checksum, checksum);

+ 0 - 37
pimd/pim_util.c

@@ -98,43 +98,6 @@ uint16_t igmp_msg_decode8to16(uint8_t code)
   return value;
 }
 
-#ifndef PIM_USE_QUAGGA_INET_CHECKSUM
-/*
-  RFC 3376: 4.1.2. Checksum
-
-  The Checksum is the 16-bit one's complement of the one's complement
-  sum of the whole IGMP message (the entire IP payload).  For
-  computing the checksum, the Checksum field is set to zero.  When
-  receiving packets, the checksum MUST be verified before processing a
-  packet.  [RFC-1071]
-*/
-uint16_t pim_inet_checksum(const char *buf, int size)
-{
-  const uint16_t *ptr;
-  uint32_t        sum;
-  uint16_t        checksum;
-
-  ptr = (const uint16_t *) buf;
-  sum = 0;
-  while (size > 1) {
-    sum += *ptr;
-    ++ptr;
-    size -= 2;
-  }
-
-  /* Add left-over byte, if any */
-  if (size > 0)
-    sum += (uint16_t) *(const uint8_t *) ptr;
-
-  /* Fold 32-bit sum to 16 bits */
-  sum = (sum & 0xffff) + (sum >> 16);
-
-  checksum = ~sum;
-
-  return checksum;
-}
-#endif /* PIM_USE_QUAGGA_INET_CHECKSUM */
-
 void pim_pkt_dump(const char *label, const uint8_t *buf, int size)
 {
   char dump_buf[1000];

+ 0 - 6
pimd/pim_util.h

@@ -32,12 +32,6 @@
 uint8_t igmp_msg_encode16to8(uint16_t value);
 uint16_t igmp_msg_decode8to16(uint8_t code);
 
-#ifdef PIM_USE_QUAGGA_INET_CHECKSUM
-#define pim_inet_checksum(buf,size) in_cksum(buf,size)
-#else
-uint16_t pim_inet_checksum(const char *buf, int size);
-#endif /* PIM_USE_QUAGGA_INET_CHECKSUM */
-
 void pim_pkt_dump(const char *label, const uint8_t *buf, int size);
 
 #endif /* PIM_UTIL_H */