]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Only report bad packet checksums if we see a preponderance of them.
authorTed Lemon <source@isc.org>
Thu, 25 Mar 1999 21:58:13 +0000 (21:58 +0000)
committerTed Lemon <source@isc.org>
Thu, 25 Mar 1999 21:58:13 +0000 (21:58 +0000)
common/packet.c

index 6be23ecf2987a298606ae41e266e1403360e6725..c96b6573998aea1c3a5f90121ae6d29f7a8c2c4a 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: packet.c,v 1.21 1999/03/16 05:50:36 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: packet.c,v 1.22 1999/03/25 21:58:13 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -231,6 +231,7 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
   struct udphdr *udp;
   u_int32_t ip_len = (buf [bufix] & 0xf) << 2;
   u_int32_t sum, usum;
+  static int packets_seen, packets_bad_checksum;
 
   ip = (struct ip *)(buf + bufix);
   udp = (struct udphdr *)(buf + bufix + ip_len);
@@ -247,8 +248,10 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
 
   /* Check the IP header checksum - it should be zero. */
   if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
-         log_info ("Bad IP checksum: %x",
-               wrapsum (checksum (buf + bufix, sizeof *ip, 0)));
+         if (packets_seen &&
+             (++packets_seen / ++packets_bad_checksum) < 2)
+                 log_info ("Bad IP checksum: %x",
+                           wrapsum (checksum (buf + bufix, sizeof *ip, 0)));
          return -1;
   }