summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorlteo <lteo@openbsd.org>2013-06-17 02:31:37 +0000
committerlteo <lteo@openbsd.org>2013-06-17 02:31:37 +0000
commitc2b46a14fe91831a2d55c0074fd77be82a9e8778 (patch)
treef5c20902940763bd2f11a2dd4a4bb14a154cd2a5 /sys
parentunbreak build; OK bmercer@, patrick@ (diff)
downloadwireguard-openbsd-c2b46a14fe91831a2d55c0074fd77be82a9e8778.tar.xz
wireguard-openbsd-c2b46a14fe91831a2d55c0074fd77be82a9e8778.zip
In icmp_do_exthdr(), calculate the ICMP extension header checksums with
in4_cksum() instead of in_cksum(). This gets rid of the clunky m_data/m_len dance, which was described as "disgusting" in the original comments. :) Tested on a small MPLS test network (since icmp_do_exthdr() is currently only used by MPLS code, specifically mpls_do_error()). ok bluhm henning mikeb
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_icmp.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 4e62bb9d028..62bec749f6e 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.101 2013/06/05 15:22:32 bluhm Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.102 2013/06/17 02:31:37 lteo Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -1135,13 +1135,8 @@ icmp_do_exthdr(struct mbuf *m, u_int16_t class, u_int8_t ctype, void *buf,
n = m_getptr(m, hlen + off, &off);
if (n == NULL)
panic("icmp_do_exthdr: m_getptr failure");
- /* this is disgusting, in_cksum() is stupid */
- n->m_data += off;
- n->m_len -= off;
- ieh = mtod(n, struct icmp_ext_hdr *);
- ieh->ieh_cksum = in_cksum(n, sizeof(hdr) + len);
- n->m_data -= off;
- n->m_len += off;
+ ieh = (struct icmp_ext_hdr *)(mtod(n, caddr_t) + off);
+ ieh->ieh_cksum = in4_cksum(n, 0, off, sizeof(hdr) + len);
ip->ip_len = htons(m->m_pkthdr.len);