Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 Revert r1.148
details: https://anonhg.NetBSD.org/src/rev/524e2bd12f04
branches: trunk
changeset: 817399:524e2bd12f04
user: roy <roy%NetBSD.org@localhost>
date: Fri Aug 19 12:26:01 2016 +0000
description:
Revert r1.148
IP6_EXTHDR_GET ensures that a icmp6 header can be fetched from the mbuf
so m_pullup does not need to be called.
While here, we can safely increament interface error stats even with an
invalidated mbuf because we have a saved reference to the interface.
diffstat:
sys/netinet6/icmp6.c | 28 +++++++++-------------------
1 files changed, 9 insertions(+), 19 deletions(-)
diffs (70 lines):
diff -r 8320b980515f -r 524e2bd12f04 sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c Fri Aug 19 11:51:27 2016 +0000
+++ b/sys/netinet6/icmp6.c Fri Aug 19 12:26:01 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp6.c,v 1.195 2016/08/01 03:15:31 ozaki-r Exp $ */
+/* $NetBSD: icmp6.c,v 1.196 2016/08/19 12:26:01 roy Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.195 2016/08/01 03:15:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.196 2016/08/19 12:26:01 roy Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -452,7 +452,7 @@
struct icmp6_hdr *icmp6, *nicmp6;
int off = *offp;
int icmp6len = m->m_pkthdr.len - *offp;
- int code, sum, noff, i;
+ int code, sum, noff;
struct ifnet *rcvif;
struct psref psref;
@@ -475,29 +475,18 @@
goto freeit;
}
- i = off + sizeof(*icmp6);
- if ((m->m_len < i || M_READONLY(m)) && (m = m_pullup(m, i)) == 0) {
+ ip6 = mtod(m, struct ip6_hdr *);
+ IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
+ if (icmp6 == NULL) {
ICMP6_STATINC(ICMP6_STAT_TOOSHORT);
-#if 0 /* m is 0 here */
icmp6_ifstat_inc(rcvif, ifs6_in_error);
-#endif
goto freeit;
}
- ip6 = mtod(m, struct ip6_hdr *);
+ KASSERT(IP6_HDR_ALIGNED_P(icmp6));
+
/*
* calculate the checksum
*/
- IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
- if (icmp6 == NULL) {
- m_put_rcvif_psref(rcvif, &psref);
- ICMP6_STATINC(ICMP6_STAT_TOOSHORT);
- /* m is invalid */
- /*icmp6_ifstat_inc(rcvif, ifs6_in_error);*/
- return IPPROTO_DONE;
- }
- KASSERT(IP6_HDR_ALIGNED_P(icmp6));
- code = icmp6->icmp6_code;
-
if ((sum = in6_cksum(m, IPPROTO_ICMPV6, off, icmp6len)) != 0) {
nd6log(LOG_ERR, "ICMP6 checksum error(%d|%x) %s\n",
icmp6->icmp6_type, sum, ip6_sprintf(&ip6->ip6_src));
@@ -524,6 +513,7 @@
}
#endif
+ code = icmp6->icmp6_code;
ICMP6_STATINC(ICMP6_STAT_INHIST + icmp6->icmp6_type);
switch (icmp6->icmp6_type) {
Home |
Main Index |
Thread Index |
Old Index