summaryrefslogtreecommitdiff
path: root/sys/dev/ic/hme.c
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2006-01-12 15:06:13 +0000
committerBrad Smith <brad@cvs.openbsd.org>2006-01-12 15:06:13 +0000
commit89ea3802de539e5fbf173ab41da10f5f3239e559 (patch)
treeb4db396ac5ec5a7e0294e4d228a458964ba71632 /sys/dev/ic/hme.c
parent9d8e9330a35dbb4f9da9024018086d07a642d0fe (diff)
- add a missing htons() to the receive checksum routine to fix
checksumming on little endian systems. - only set the Ok flag in the checksum routine. Checksumming fix from: Pyun YongHyeon <pyunyh at gmail dot com>
Diffstat (limited to 'sys/dev/ic/hme.c')
-rw-r--r--sys/dev/ic/hme.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c
index b4a2f078df0..6b73d056cfe 100644
--- a/sys/dev/ic/hme.c
+++ b/sys/dev/ic/hme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hme.c,v 1.40 2005/12/16 06:08:13 brad Exp $ */
+/* $OpenBSD: hme.c,v 1.41 2006/01/12 15:06:12 brad Exp $ */
/* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */
/*-
@@ -114,7 +114,7 @@ void hme_mediastatus(struct ifnet *, struct ifmediareq *);
int hme_eint(struct hme_softc *, u_int);
int hme_rint(struct hme_softc *);
int hme_tint(struct hme_softc *);
-/* TCP/UDP checksum offloading support */
+/* TCP/UDP checksum offload support */
void hme_rxcksum(struct mbuf *, u_int32_t);
void
@@ -752,7 +752,7 @@ hme_rxcksum(struct mbuf *m, u_int32_t flags)
struct ip *ip;
struct udphdr *uh;
int32_t hlen, len, pktlen;
- u_int16_t cksum, flag_bad, flag_ok, *opts;
+ u_int16_t cksum, *opts;
u_int32_t temp32;
union pseudoh {
struct hdr {
@@ -790,8 +790,6 @@ hme_rxcksum(struct mbuf *m, u_int32_t flags)
case IPPROTO_TCP:
if (pktlen < (hlen + sizeof(struct tcphdr)))
return;
- flag_ok = M_TCP_CSUM_IN_OK;
- flag_bad = M_TCP_CSUM_IN_BAD;
break;
case IPPROTO_UDP:
if (pktlen < (hlen + sizeof(struct udphdr)))
@@ -799,14 +797,12 @@ hme_rxcksum(struct mbuf *m, u_int32_t flags)
uh = (struct udphdr *)((caddr_t)ip + hlen);
if (uh->uh_sum == 0)
return; /* no checksum */
- flag_ok = M_UDP_CSUM_IN_OK;
- flag_bad = M_UDP_CSUM_IN_BAD;
break;
default:
return;
}
- cksum = ~(flags & HME_XD_RXCKSUM);
+ cksum = htons(~(flags & HME_XD_RXCKSUM));
/* cksum fixup for IP options */
len = hlen - sizeof(struct ip);
if (len > 0) {
@@ -829,10 +825,10 @@ hme_rxcksum(struct mbuf *m, u_int32_t flags)
temp32 = (temp32 >> 16) + (temp32 & 65535);
temp32 += (temp32 >> 16);
cksum = ~temp32;
- if (cksum != 0)
- m->m_pkthdr.csum_flags |= flag_bad;
- else
- m->m_pkthdr.csum_flags |= flag_ok;
+ if (cksum == 0) {
+ m->m_pkthdr.csum_flags |=
+ M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK;
+ }
}
/*
@@ -879,9 +875,7 @@ hme_rint(sc)
}
ifp->if_ipackets++;
-#if 0
hme_rxcksum(m, flags);
-#endif
#if NBPFILTER > 0
if (ifp->if_bpf)