Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 ip6_undefer_csum:
details: https://anonhg.NetBSD.org/src/rev/a84eb3fa2123
branches: trunk
changeset: 764492:a84eb3fa2123
user: yamt <yamt%NetBSD.org@localhost>
date: Mon Apr 25 22:07:57 2011 +0000
description:
ip6_undefer_csum:
- don't forget ntohs
- KNF
diffstat:
sys/netinet6/in6_offload.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diffs (52 lines):
diff -r 468f44c1c2df -r a84eb3fa2123 sys/netinet6/in6_offload.c
--- a/sys/netinet6/in6_offload.c Mon Apr 25 22:04:32 2011 +0000
+++ b/sys/netinet6/in6_offload.c Mon Apr 25 22:07:57 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_offload.c,v 1.5 2010/12/11 22:37:47 matt Exp $ */
+/* $NetBSD: in6_offload.c,v 1.6 2011/04/25 22:07:57 yamt Exp $ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.5 2010/12/11 22:37:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.6 2011/04/25 22:07:57 yamt Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@@ -195,22 +195,27 @@
void
ip6_undefer_csum(struct mbuf *m, size_t hdrlen, int csum_flags)
{
+ const size_t ip6_plen_offset =
+ hdrlen + offsetof(struct ip6_hdr, ip6_plen);
+ size_t l4hdroff;
+ size_t l4offset;
+ uint16_t plen;
+ uint16_t csum;
+
KASSERT(m->m_flags & M_PKTHDR);
KASSERT((m->m_pkthdr.csum_flags & csum_flags) == csum_flags);
KASSERT(csum_flags == M_CSUM_UDPv6 || csum_flags == M_CSUM_TCPv6);
- const size_t ip6_plen_offset = hdrlen + offsetof(struct ip6_hdr, ip6_plen);
- uint16_t plen;
-
if (__predict_true(hdrlen + sizeof(struct ip6_hdr) <= m->m_len)) {
plen = *(uint16_t *)(mtod(m, char *) + ip6_plen_offset);
} else {
m_copydata(m, ip6_plen_offset, sizeof(plen), &plen);
}
+ plen = ntohs(plen);
- const size_t l4hdroff = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data);
- size_t l4offset = hdrlen + l4hdroff;
- uint16_t csum = in6_cksum(m, 0, l4offset, plen - l4hdroff);
+ l4hdroff = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data);
+ l4offset = hdrlen + l4hdroff;
+ csum = in6_cksum(m, 0, l4offset, plen - l4hdroff);
if (csum == 0 && (csum_flags & M_CSUM_UDPv6) != 0)
csum = 0xffff;
Home |
Main Index |
Thread Index |
Old Index