summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-23 06:03:15 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-23 06:03:15 +0000
commita74e8403c89e62f9eb01ff5804d2389e799fc15f (patch)
tree5cb8531f4dc1ad4042b2542dd91858ff206968a3
parentf823e64df24b534f4830aa9e875e27f33eeb8dfa (diff)
Keep stats on TCP/UDP hardware checksumming.
-rw-r--r--sys/netinet/tcp_input.c13
-rw-r--r--sys/netinet/tcp_output.c3
-rw-r--r--sys/netinet/tcp_var.h4
-rw-r--r--sys/netinet/udp_usrreq.c19
-rw-r--r--sys/netinet/udp_var.h4
5 files changed, 31 insertions, 12 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 1b92826a59c..e8e31446c94 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.95 2001/06/23 02:27:10 angelos Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.96 2001/06/23 06:03:11 angelos Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -512,12 +512,17 @@ tcp_input(m, va_alist)
ti->ti_len = (u_int16_t)tlen;
HTONS(ti->ti_len);
if ((m->m_pkthdr.csum & M_TCP_CSUM_IN_OK) == 0) {
- if (m->m_pkthdr.csum & M_TCP_CSUM_IN_BAD ||
- (ti->ti_sum = in_cksum(m, len)) != 0) {
+ if (m->m_pkthdr.csum & M_TCP_CSUM_IN_BAD) {
+ tcpstat.tcps_inhwcsum++;
tcpstat.tcps_rcvbadsum++;
goto drop;
}
- }
+ if ((ti->ti_sum = in_cksum(m, len)) != 0) {
+ tcpstat.tcps_rcvbadsum++;
+ goto drop;
+ }
+ } else
+ tcpstat.tcps_inhwcsum++;
break;
}
#ifdef INET6
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 10ca016a510..5a0a32c4f23 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_output.c,v 1.39 2001/06/23 05:36:08 angelos Exp $ */
+/* $OpenBSD: tcp_output.c,v 1.40 2001/06/23 06:03:12 angelos Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@@ -960,6 +960,7 @@ send:
ifp = ro->ro_rt->rt_ifp;
if (ifp->if_capabilities & IFCAP_CSUM_TCPv4) {
m->m_pkthdr.csum |= M_TCPV4_CSUM_OUT;
+ tcpstat.tcps_outhwcsum++;
th->th_sum = in_cksum(m, (int)hdrlen);
break;
}
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 452112f9688..fd7a7e2c2d6 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_var.h,v 1.36 2001/06/09 07:03:43 angelos Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.37 2001/06/23 06:03:13 angelos Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@@ -275,6 +275,8 @@ struct tcpstat {
u_int32_t tcps_rcvbadsig; /* rcvd bad/missing TCP signatures */
u_int64_t tcps_rcvgoodsig; /* rcvd good TCP signatures */
+ u_int32_t tcps_inhwcsum; /* input hardware-checksummed packets */
+ u_int32_t tcps_outhwcsum; /* output hardware-checksummed packets */
};
/*
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 55ade377152..763494b2086 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.66 2001/06/23 05:36:08 angelos Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.67 2001/06/23 06:03:13 angelos Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -302,14 +302,22 @@ udp_input(m, va_alist)
sizeof ((struct ipovly *)ip)->ih_x1);
((struct ipovly *)ip)->ih_len = uh->uh_ulen;
- if (m->m_pkthdr.csum & M_UDP_CSUM_IN_BAD ||
- (uh->uh_sum = in_cksum(m, len +
- sizeof (struct ip))) != 0) {
+ if (m->m_pkthdr.csum & M_UDP_CSUM_IN_BAD) {
udpstat.udps_badsum++;
+ udpstat.udps_inhwcsum++;
m_freem(m);
return;
}
- }
+
+ if ((uh->uh_sum = in_cksum(m, len +
+ sizeof (struct ip))) != 0) {
+ udpstat.udps_badsum++;
+ m_freem(m);
+ return;
+ }
+ } else
+ udpstat.udps_inhwcsum++;
+
} else
udpstat.udps_nosum++;
@@ -943,6 +951,7 @@ udp_output(m, va_alist)
ifp = ro->ro_rt->rt_ifp;
if (ifp->if_capabilities & IFCAP_CSUM_UDPv4) {
m->m_pkthdr.csum |= M_UDPV4_CSUM_OUT;
+ udpstat.udps_outhwcsum++;
ui->ui_sum = in_cksum(m,
sizeof(struct udpiphdr));
goto skipudpcsum;
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index 2c0c3cf1938..258b4102339 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_var.h,v 1.11 2001/06/09 07:03:45 angelos Exp $ */
+/* $OpenBSD: udp_var.h,v 1.12 2001/06/23 06:03:14 angelos Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
@@ -68,8 +68,10 @@ struct udpstat {
u_long udps_nosec; /* dropped for lack of ipsec */
u_long udps_fullsock; /* not delivered, input socket full */
u_long udps_pcbhashmiss; /* input packets missing pcb hash */
+ u_long udps_inhwcsum; /* input hardware-csummed packets */
/* output statistics: */
u_long udps_opackets; /* total output packets */
+ u_long udps_outhwcsum; /* output hardware-csummed packets */
};
/*