- npf_cache_ip: re-fetch IPv6 header since nbufs might have been reallocated. trunk
authorrmind <rmind@NetBSD.org>
Fri, 23 Aug 2013 10:37:03 +0000
branchtrunk
changeset 220689 02d2ad2c3f05
parent 220688 673476c0fe29
child 220690 d796f1f2487a
- npf_cache_ip: re-fetch IPv6 header since nbufs might have been reallocated. - npf_cache_all: clear NBUF_DATAREF_RESET since npf_cache_ip() handles it.
sys/net/npf/npf_inet.c
--- a/sys/net/npf/npf_inet.c	Fri Aug 23 07:15:08 2013 +0000
+++ b/sys/net/npf/npf_inet.c	Fri Aug 23 10:37:03 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_inet.c,v 1.22 2013/06/02 02:20:04 rmind Exp $	*/
+/*	$NetBSD: npf_inet.c,v 1.23 2013/08/23 10:37:03 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.22 2013/06/02 02:20:04 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.23 2013/08/23 10:37:03 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -391,8 +391,12 @@
 			npc->npc_hlen += hlen;
 		}
 
-		/* Restore the offset. */
+		/*
+		 * Re-fetch the header pointers (nbufs might have been
+		 * reallocated).  Restore the original offset (if any).
+		 */
 		nbuf_reset(nbuf);
+		ip6 = nbuf_dataptr(nbuf);
 		if (off) {
 			nbuf_advance(nbuf, off, 0);
 		}
@@ -437,6 +441,7 @@
 	 */
 	flags = npf_cache_ip(npc, nbuf);
 	if ((flags & NPC_IP46) == 0 || (flags & NPC_IPFRAG) != 0) {
+		nbuf_unset_flag(nbuf, NBUF_DATAREF_RESET);
 		npc->npc_info |= flags;
 		return flags;
 	}