Module Name: src
Committed By: maxv
Date: Mon Feb 26 08:50:25 UTC 2018
Modified Files:
src/sys/netinet: tcp_subr.c
src/sys/netipsec: ipsec.c ipsec.h
src/sys/rump/librump/rumpnet: net_stub.c
Log Message:
Dedup: merge ipsec4_hdrsiz and ipsec6_hdrsiz into ipsec_hdrsiz.
ok ozaki-r@
To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.137 -r1.138 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.67 -r1.68 src/sys/netipsec/ipsec.h
cvs rdiff -u -r1.27 -r1.28 src/sys/rump/librump/rumpnet/net_stub.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.272 src/sys/netinet/tcp_subr.c:1.273
--- src/sys/netinet/tcp_subr.c:1.272 Fri Jan 19 07:53:01 2018
+++ src/sys/netinet/tcp_subr.c Mon Feb 26 08:50:25 2018
@@ -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 @@ ipsec4_hdrsiz_tcp(struct tcpcb *tp)
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 @@ ipsec6_hdrsiz_tcp(struct tcpcb *tp)
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 */
Index: src/sys/netipsec/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.137 src/sys/netipsec/ipsec.c:1.138
--- src/sys/netipsec/ipsec.c:1.137 Mon Feb 26 08:42:16 2018
+++ src/sys/netipsec/ipsec.c Mon Feb 26 08:50:25 2018
@@ -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 @@ ipsec4_forward(struct mbuf *m, int *dest
}
/* 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 @@ ipsec_sp_hdrsiz(const struct secpolicy *
}
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 @@ ipsec4_hdrsiz(struct mbuf *m, u_int dir,
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.
Index: src/sys/netipsec/ipsec.h
diff -u src/sys/netipsec/ipsec.h:1.67 src/sys/netipsec/ipsec.h:1.68
--- src/sys/netipsec/ipsec.h:1.67 Wed Feb 21 16:18:52 2018
+++ src/sys/netipsec/ipsec.h Mon Feb 26 08:50:25 2018
@@ -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 @@ struct tcpcb;
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;
Index: src/sys/rump/librump/rumpnet/net_stub.c
diff -u src/sys/rump/librump/rumpnet/net_stub.c:1.27 src/sys/rump/librump/rumpnet/net_stub.c:1.28
--- src/sys/rump/librump/rumpnet/net_stub.c:1.27 Wed Aug 2 01:28:02 2017
+++ src/sys/rump/librump/rumpnet/net_stub.c Mon Feb 26 08:50:25 2018
@@ -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_output,rumpnet_stub)
__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_check_policy,rumpnet
__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);