1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-09 22:38:01 -08:00

Keep stats on TCP/UDP hardware checksumming.

This commit is contained in:
angelos 2001-06-23 06:03:11 +00:00
parent 528c0d0a0b
commit 67475e5f67
5 changed files with 31 additions and 12 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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 */
};
/*

View File

@ -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;

View File

@ -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 */
};
/*