Dedup: merge ipsec4_hdrsiz and ipsec6_hdrsiz into ipsec_hdrsiz. trunk
authormaxv <maxv@NetBSD.org>
Mon, 26 Feb 2018 08:50:25 +0000
branchtrunk
changeset 316449 1b9855be59d7
parent 316448 1efbf93e2e35
child 316450 0dec3dc2306a
Dedup: merge ipsec4_hdrsiz and ipsec6_hdrsiz into ipsec_hdrsiz. ok ozaki-r@
sys/netinet/tcp_subr.c
sys/netipsec/ipsec.c
sys/netipsec/ipsec.h
sys/rump/librump/rumpnet/net_stub.c
--- a/sys/netinet/tcp_subr.c	Mon Feb 26 08:42:16 2018 +0000
+++ b/sys/netinet/tcp_subr.c	Mon Feb 26 08:50:25 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.273 2018/02/26 08:50:25 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.273 2018/02/26 08:50:25 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2351,8 +2351,8 @@
 		return 0;
 	switch (tp->t_family) {
 	case AF_INET:
-		/* XXX: should use currect direction. */
-		hdrsiz = ipsec4_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, inp);
+		/* XXX: should use correct direction. */
+		hdrsiz = ipsec_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, inp);
 		break;
 	default:
 		hdrsiz = 0;
@@ -2373,8 +2373,8 @@
 		return 0;
 	switch (tp->t_family) {
 	case AF_INET6:
-		/* XXX: should use currect direction. */
-		hdrsiz = ipsec6_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, in6p);
+		/* XXX: should use correct direction. */
+		hdrsiz = ipsec_hdrsiz(tp->t_template, IPSEC_DIR_OUTBOUND, in6p);
 		break;
 	case AF_INET:
 		/* mapped address case - tricky */
--- a/sys/netipsec/ipsec.c	Mon Feb 26 08:42:16 2018 +0000
+++ b/sys/netipsec/ipsec.c	Mon Feb 26 08:50:25 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.137 2018/02/26 08:42:16 maxv Exp $ */
+/* $NetBSD: ipsec.c,v 1.138 2018/02/26 08:50:25 maxv Exp $ */
 /* $FreeBSD: src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
 /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.137 2018/02/26 08:42:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.138 2018/02/26 08:50:25 maxv Exp $");
 
 /*
  * IPsec controller part.
@@ -778,7 +778,7 @@
 	}
 
 	/* Count IPsec header size. */
-	ipsechdr = ipsec4_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL);
+	ipsechdr = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL);
 
 	/*
 	 * Find the correct route for outer IPv4 header, compute tunnel MTU.
@@ -1845,7 +1845,7 @@
 }
 
 size_t
-ipsec4_hdrsiz(struct mbuf *m, u_int dir, struct inpcb *inp)
+ipsec_hdrsiz(struct mbuf *m, u_int dir, void *inp)
 {
 	struct inpcb_hdr *inph = (struct inpcb_hdr *)inp;
 	struct secpolicy *sp;
@@ -1872,36 +1872,6 @@
 	return size;
 }
 
-#ifdef INET6
-size_t
-ipsec6_hdrsiz(struct mbuf *m, u_int dir, struct in6pcb *in6p)
-{
-	struct inpcb_hdr *inph = (struct inpcb_hdr *)in6p;
-	struct secpolicy *sp;
-	int error;
-	size_t size;
-
-	KASSERT(m != NULL);
-	KASSERTMSG(inph == NULL || inph->inph_socket != NULL,
-	    "socket w/o inpcb");
-
-	if (inph == NULL)
-		sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error);
-	else
-		sp = ipsec_getpolicybysock(m, dir, inph, &error);
-
-	if (sp != NULL) {
-		size = ipsec_sp_hdrsiz(sp, m);
-		KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_DATA, "size:%zu.\n", size);
-		KEY_SP_UNREF(&sp);
-	} else {
-		size = 0;
-	}
-
-	return size;
-}
-#endif
-
 /*
  * Check the variable replay window.
  * ipsec_chkreplay() performs replay check before ICV verification.
--- a/sys/netipsec/ipsec.h	Mon Feb 26 08:42:16 2018 +0000
+++ b/sys/netipsec/ipsec.h	Mon Feb 26 08:50:25 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.h,v 1.67 2018/02/21 16:18:52 maxv Exp $	*/
+/*	$NetBSD: ipsec.h,v 1.68 2018/02/26 08:50:25 maxv Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $	*/
 
@@ -304,7 +304,7 @@
 int ipsec_chkreplay(u_int32_t, const struct secasvar *);
 int ipsec_updatereplay(u_int32_t, const struct secasvar *);
 
-size_t ipsec4_hdrsiz(struct mbuf *, u_int, struct inpcb *);
+size_t ipsec_hdrsiz(struct mbuf *, u_int, void *);
 size_t ipsec4_hdrsiz_tcp(struct tcpcb *);
 
 union sockaddr_union;
--- a/sys/rump/librump/rumpnet/net_stub.c	Mon Feb 26 08:42:16 2018 +0000
+++ b/sys/rump/librump/rumpnet/net_stub.c	Mon Feb 26 08:50:25 2018 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: net_stub.c,v 1.27 2017/08/02 01:28:02 ozaki-r Exp $	*/
+/*	$NetBSD: net_stub.c,v 1.28 2018/02/26 08:50:25 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.27 2017/08/02 01:28:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: net_stub.c,v 1.28 2018/02/26 08:50:25 maxv Exp $");
 
 #include <sys/mutex.h>
 #include <sys/param.h>
@@ -91,7 +91,6 @@
 __weak_alias(ipsec4_common_input,rumpnet_stub);
 __weak_alias(ipsec4_delete_pcbpolicy,rumpnet_stub);
 __weak_alias(ipsec4_forward,rumpnet_stub);
-__weak_alias(ipsec4_hdrsiz,rumpnet_stub);
 __weak_alias(ipsec4_input,rumpnet_stub);
 __weak_alias(ipsec4_in_reject,rumpnet_stub);
 __weak_alias(ipsec4_set_policy,rumpnet_stub);
@@ -101,9 +100,9 @@
 __weak_alias(ipsec6_delete_pcbpolicy,rumpnet_stub);
 __weak_alias(ipsec6_get_policy,rumpnet_stub);
 __weak_alias(ipsec6_in_reject,rumpnet_stub);
-__weak_alias(ipsec6_hdrsiz,rumpnet_stub);
 __weak_alias(ipsec6_process_packet,rumpnet_stub);
 __weak_alias(ipsec6_set_policy,rumpnet_stub);
+__weak_alias(ipsec_hdrsiz,rumpnet_stub);
 __weak_alias(ipsec_init_policy,rumpnet_stub);
 __weak_alias(ipsec_pcbconn,rumpnet_stub);
 __weak_alias(ipsec_pcbdisconn,rumpnet_stub);