Remove the second argument from ip_reass_packet(). We want the IP header trunk
authormaxv <maxv@NetBSD.org>
Tue, 10 Jul 2018 15:46:58 +0000
branchtrunk
changeset 320506 afa3fccd4c6c
parent 320505 4ca603d67d3a
child 320515 5988d1844874
Remove the second argument from ip_reass_packet(). We want the IP header on the mbuf, not elsewhere. Simplifies the NPF reassembly code a little. No real functional change.
sys/net/npf/npf_handler.c
sys/netinet/ip_input.c
sys/netinet/ip_reass.c
sys/netinet/ip_var.h
--- a/sys/net/npf/npf_handler.c	Tue Jul 10 15:25:01 2018 +0000
+++ b/sys/net/npf/npf_handler.c	Tue Jul 10 15:46:58 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_handler.c,v 1.42 2018/07/10 15:25:01 maxv Exp $	*/
+/*	$NetBSD: npf_handler.c,v 1.43 2018/07/10 15:46:58 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2009-2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_handler.c,v 1.42 2018/07/10 15:25:01 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_handler.c,v 1.43 2018/07/10 15:46:58 maxv Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -83,8 +83,7 @@
 	nbuf_reset(nbuf);
 
 	if (npf_iscached(npc, NPC_IP4)) {
-		struct ip *ip = nbuf_dataptr(nbuf);
-		error = ip_reass_packet(&m, ip);
+		error = ip_reass_packet(&m);
 		KASSERT(!error || (m != NULL));
 	} else if (npf_iscached(npc, NPC_IP6)) {
 		error = ip6_reass_packet(&m, npc->npc_hlen);
--- a/sys/netinet/ip_input.c	Tue Jul 10 15:25:01 2018 +0000
+++ b/sys/netinet/ip_input.c	Tue Jul 10 15:46:58 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.384 2018/05/17 11:59:36 maxv Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.385 2018/07/10 15:46:58 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.384 2018/05/17 11:59:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.385 2018/07/10 15:46:58 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -752,7 +752,7 @@
 		/*
 		 * Pass to IP reassembly mechanism.
 		 */
-		if (ip_reass_packet(&m, ip) != 0) {
+		if (ip_reass_packet(&m) != 0) {
 			/* Failed; invalid fragment(s) or packet. */
 			goto out;
 		}
--- a/sys/netinet/ip_reass.c	Tue Jul 10 15:25:01 2018 +0000
+++ b/sys/netinet/ip_reass.c	Tue Jul 10 15:46:58 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_reass.c,v 1.17 2018/05/15 19:16:38 maxv Exp $	*/
+/*	$NetBSD: ip_reass.c,v 1.18 2018/07/10 15:46:58 maxv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_reass.c,v 1.17 2018/05/15 19:16:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_reass.c,v 1.18 2018/07/10 15:46:58 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -612,11 +612,12 @@
  * => On complete, m0 represents a constructed final packet.
  */
 int
-ip_reass_packet(struct mbuf **m0, struct ip *ip)
+ip_reass_packet(struct mbuf **m0)
 {
+	struct mbuf *m = *m0;
+	struct ip *ip = mtod(m, struct ip *);
 	const int hlen = ip->ip_hl << 2;
 	const int len = ntohs(ip->ip_len);
-	struct mbuf *m = *m0;
 	int ipsecflags = m->m_flags & (M_DECRYPTED|M_AUTHIPHDR);
 	ipfr_queue_t *fp;
 	ipfr_qent_t *ipqe;
--- a/sys/netinet/ip_var.h	Tue Jul 10 15:25:01 2018 +0000
+++ b/sys/netinet/ip_var.h	Tue Jul 10 15:46:58 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_var.h,v 1.125 2018/04/08 12:18:06 maxv Exp $	*/
+/*	$NetBSD: ip_var.h,v 1.126 2018/07/10 15:46:58 maxv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -209,7 +209,7 @@
 int	 ip_fragment(struct mbuf *, struct ifnet *, u_long);
 
 void	 ip_reass_init(void);
-int	 ip_reass_packet(struct mbuf **, struct ip *);
+int	 ip_reass_packet(struct mbuf **);
 void	 ip_reass_slowtimo(void);
 void	 ip_reass_drain(void);