summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-23 18:54:45 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-23 18:54:45 +0000
commitced2c454722870f31392314819901f8b783c25f5 (patch)
tree6dfb35ff54491f50a1b72b840812940eb8e3eb96
parent288fc71e386ca4ad0219628adfececd7c9db39d0 (diff)
Clear the checksum flags after verification. Also, don't count
checksum errors as hardware checksum packets as well.
-rw-r--r--sys/netinet/ip_input.c15
-rw-r--r--sys/netinet/tcp_input.c6
-rw-r--r--sys/netinet/udp_usrreq.c15
3 files changed, 21 insertions, 15 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 52e2a6683b7..702542d25cf 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.81 2001/06/23 18:45:29 angelos Exp $ */
+/* $OpenBSD: ip_input.c,v 1.82 2001/06/23 18:54:44 angelos Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -333,17 +333,20 @@ ipv4_input(m)
}
if ((m->m_pkthdr.csum & M_IPV4_CSUM_IN_OK) == 0) {
- if (m->m_pkthdr.csum & M_IPV4_CSUM_IN_BAD ||
- in_cksum(m, hlen) != 0) {
- ipstat.ips_badsum++;
+ if (m->m_pkthdr.csum & M_IPV4_CSUM_IN_BAD) {
ipstat.ips_inhwcsum++;
+ ipstat.ips_badsum++;
goto bad;
}
- ipstat.ips_inhwcsum++;
+ if (in_cksum(m, hlen) != 0) {
+ ipstat.ips_badsum++;
+ goto bad;
+ }
+ } else {
m->m_pkthdr.csum &= ~M_IPV4_CSUM_IN_OK;
- } else
ipstat.ips_inhwcsum++;
+ }
/*
* Convert fields to host representation.
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index e8e31446c94..77e378964e7 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.96 2001/06/23 06:03:11 angelos Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.97 2001/06/23 18:54:44 angelos Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -521,8 +521,10 @@ tcp_input(m, va_alist)
tcpstat.tcps_rcvbadsum++;
goto drop;
}
- } else
+ } else {
+ m->m_pkthdr.csum &= ~M_TCP_CSUM_IN_OK;
tcpstat.tcps_inhwcsum++;
+ }
break;
}
#ifdef INET6
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 663f559fbd4..094f2c22230 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.69 2001/06/23 16:15:56 fgsch Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.70 2001/06/23 18:54:44 angelos Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -298,10 +298,6 @@ udp_input(m, va_alist)
#endif /* INET6 */
if (uh->uh_sum) {
if ((m->m_pkthdr.csum & M_UDP_CSUM_IN_OK) == 0) {
- bzero(((struct ipovly *)ip)->ih_x1,
- sizeof ((struct ipovly *)ip)->ih_x1);
- ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
-
if (m->m_pkthdr.csum & M_UDP_CSUM_IN_BAD) {
udpstat.udps_badsum++;
udpstat.udps_inhwcsum++;
@@ -309,15 +305,20 @@ udp_input(m, va_alist)
return;
}
+ bzero(((struct ipovly *)ip)->ih_x1,
+ sizeof ((struct ipovly *)ip)->ih_x1);
+ ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
+
if ((uh->uh_sum = in_cksum(m, len +
sizeof (struct ip))) != 0) {
udpstat.udps_badsum++;
m_freem(m);
return;
}
- } else
+ } else {
+ m->m_pkthdr.csum &= ~M_UDP_CSUM_IN_OK;
udpstat.udps_inhwcsum++;
-
+ }
} else
udpstat.udps_nosum++;