summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-23 05:55:41 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-23 05:55:41 +0000
commitefe1ad994e0998d5d2b00d4767308edddff4ecfb (patch)
treef3429a70cf481cbc63ca33076455c1b608f60ab0
parentae00984fc1e10216066de39d37f08fe65da6f7a4 (diff)
Count input/output hardware-checksummed IP packets.
-rw-r--r--sys/netinet/ip_input.c4
-rw-r--r--sys/netinet/ip_output.c33
2 files changed, 20 insertions, 17 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 6e521d7748f..d2041d5c5a6 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.78 2001/06/23 03:39:03 angelos Exp $ */
+/* $OpenBSD: ip_input.c,v 1.79 2001/06/23 05:55:40 angelos Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -336,9 +336,11 @@ ipv4_input(m)
if (m->m_pkthdr.csum & M_IPV4_CSUM_IN_BAD ||
in_cksum(m, hlen) != 0) {
ipstat.ips_badsum++;
+ ipstat.ips_inhwcsum++;
goto bad;
}
+ ipstat.ips_inhwcsum++;
m->m_pkthdr.csum &= ~M_IPV4_CSUM_IN_OK;
}
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index dfd4cc19d63..34cbe2ee9e8 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.106 2001/06/23 03:10:21 provos Exp $ */
+/* $OpenBSD: ip_output.c,v 1.107 2001/06/23 05:55:40 angelos Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -586,15 +586,29 @@ sendit:
}
#endif /* IPSEC */
+ /* Catch routing changes wrt. hardware checksumming for TCP or UDP. */
+ if (m->m_pkthdr.csum & M_TCPV4_CSUM_OUT &&
+ !(ifp->if_capabilities & IFCAP_CSUM_TCPv4)) {
+ /* XXX Compute TCP checksum */
+ m->m_pkthdr.csum &= ~M_TCPV4_CSUM_OUT; /* Clear */
+ }
+
+ if (m->m_pkthdr.csum & M_UDPV4_CSUM_OUT &&
+ !(ifp->if_capabilities & IFCAP_CSUM_UDPv4)) {
+ /* XXX Compute UDP checksum */
+ m->m_pkthdr.csum &= ~M_UDPV4_CSUM_OUT; /* Clear */
+ }
+
/*
* If small enough for interface, can just send directly.
*/
if ((u_int16_t)ip->ip_len <= ifp->if_mtu) {
ip->ip_len = htons((u_int16_t)ip->ip_len);
ip->ip_off = htons((u_int16_t)ip->ip_off);
- if (ifp->if_capabilities & IFCAP_CSUM_IPv4)
+ if (ifp->if_capabilities & IFCAP_CSUM_IPv4) {
m->m_pkthdr.csum |= M_IPV4_CSUM_OUT;
- else {
+ ipstat.ips_outhwcsum++;
+ } else {
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, hlen);
}
@@ -602,19 +616,6 @@ sendit:
goto done;
}
- /* Catch routing changes. */
- if (m->m_pkthdr.csum & M_TCPV4_CSUM_OUT &&
- !(ifp->if_capabilities & IFCAP_CSUM_TCPv4)) {
- /* XXX Compute TCP checksum */
- m->m_pkthdr.csum &= ~M_TCPV4_CSUM_OUT; /* Clear */
- }
-
- if (m->m_pkthdr.csum & M_UDPV4_CSUM_OUT &&
- !(ifp->if_capabilities & IFCAP_CSUM_UDPv4)) {
- /* XXX Compute UDP checksum */
- m->m_pkthdr.csum &= ~M_UDPV4_CSUM_OUT; /* Clear */
- }
-
/*
* Too large for interface; fragment if possible.
* Must be able to put at least 8 bytes per fragment.