Module Name: src
Committed By: ozaki-r
Date: Fri Mar 3 07:13:06 UTC 2017
Modified Files:
src/sys/netinet: dccp_usrreq.c ip_output.c ip_var.h raw_ip.c
sctp_output.c tcp_input.c tcp_output.c tcp_subr.c udp_usrreq.c
src/sys/netinet6: ip6_output.c ip6_var.h raw_ip6.c udp6_output.c
src/sys/netipsec: ipsec.c ipsec.h ipsec6.h
Log Message:
Pass inpcb/in6pcb instead of socket to ip_output/ip6_output
- Passing a socket to Layer 3 is layer violation and even unnecessary
- The change makes codes of callers and IPsec a bit simple
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.274 -r1.275 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.117 -r1.118 src/sys/netinet/ip_var.h
cvs rdiff -u -r1.162 -r1.163 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.9 -r1.10 src/sys/netinet/sctp_output.c
cvs rdiff -u -r1.354 -r1.355 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.194 -r1.195 src/sys/netinet/tcp_output.c
cvs rdiff -u -r1.269 -r1.270 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.230 -r1.231 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.190 -r1.191 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.73 -r1.74 src/sys/netinet6/ip6_var.h
cvs rdiff -u -r1.155 -r1.156 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.54 -r1.55 src/sys/netinet6/udp6_output.c
cvs rdiff -u -r1.69 -r1.70 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.37 -r1.38 src/sys/netipsec/ipsec.h
cvs rdiff -u -r1.14 -r1.15 src/sys/netipsec/ipsec6.h
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/dccp_usrreq.c
diff -u src/sys/netinet/dccp_usrreq.c:1.12 src/sys/netinet/dccp_usrreq.c:1.13
--- src/sys/netinet/dccp_usrreq.c:1.12 Mon Jan 16 15:44:47 2017
+++ src/sys/netinet/dccp_usrreq.c Fri Mar 3 07:13:06 2017
@@ -1,5 +1,5 @@
/* $KAME: dccp_usrreq.c,v 1.67 2005/11/03 16:05:04 nishida Exp $ */
-/* $NetBSD: dccp_usrreq.c,v 1.12 2017/01/16 15:44:47 christos Exp $ */
+/* $NetBSD: dccp_usrreq.c,v 1.13 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (c) 2003 Joacim H�ggmark, Magnus Erixzon, Nils-Erik Mattsson
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.12 2017/01/16 15:44:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.13 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1620,7 +1620,7 @@ again:
DCCP_DEBUG((LOG_INFO, "Calling ip_output, mbuf->m_len = %u, mbuf->m_pkthdr.len = %u\n", m->m_len, m->m_pkthdr.len));
error = ip_output(m, inp->inp_options, &inp->inp_route,
(inp->inp_socket->so_options & SO_DONTROUTE), 0,
- inp->inp_socket);
+ inp);
}
if (error) {
Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.274 src/sys/netinet/ip_output.c:1.275
--- src/sys/netinet/ip_output.c:1.274 Thu Mar 2 05:29:31 2017
+++ src/sys/netinet/ip_output.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.274 2017/03/02 05:29:31 ozaki-r Exp $ */
+/* $NetBSD: ip_output.c,v 1.275 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.274 2017/03/02 05:29:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.275 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -225,7 +225,7 @@ ip_if_output(struct ifnet * const ifp, s
*/
int
ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
- struct ip_moptions *imo, struct socket *so)
+ struct ip_moptions *imo, struct inpcb *inp)
{
struct rtentry *rt;
struct ip *ip;
@@ -588,7 +588,7 @@ sendit:
bool ipsec_done = false;
/* Perform IPsec processing, if any. */
- error = ipsec4_output(m, so, flags, &sp, &mtu, &natt_frag,
+ error = ipsec4_output(m, inp, flags, &sp, &mtu, &natt_frag,
&ipsec_done);
if (error || ipsec_done)
goto done;
@@ -713,10 +713,7 @@ sendit:
*/
if (ntohs(ip->ip_off) & IP_DF) {
if (flags & IP_RETURNMTU) {
- struct inpcb *inp;
-
- KASSERT(so && solocked(so));
- inp = sotoinpcb(so);
+ KASSERT(inp != NULL);
inp->inp_errormtu = mtu;
}
error = EMSGSIZE;
@@ -750,7 +747,7 @@ sendit:
if (natt_frag) {
error = ip_output(m, opt, ro,
flags | IP_RAWOUTPUT | IP_NOIPNEWID,
- imo, so);
+ imo, inp);
} else {
KASSERT((m->m_pkthdr.csum_flags &
(M_CSUM_UDPv4 | M_CSUM_TCPv4)) == 0);
Index: src/sys/netinet/ip_var.h
diff -u src/sys/netinet/ip_var.h:1.117 src/sys/netinet/ip_var.h:1.118
--- src/sys/netinet/ip_var.h:1.117 Thu Feb 16 08:12:44 2017
+++ src/sys/netinet/ip_var.h Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_var.h,v 1.117 2017/02/16 08:12:44 knakahara Exp $ */
+/* $NetBSD: ip_var.h,v 1.118 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -213,7 +213,7 @@ void ip_freemoptions(struct ip_moptions
int ip_optcopy(struct ip *, struct ip *);
u_int ip_optlen(struct inpcb *);
int ip_output(struct mbuf *, struct mbuf *, struct route *, int,
- struct ip_moptions *, struct socket *);
+ struct ip_moptions *, struct inpcb *);
int ip_fragment(struct mbuf *, struct ifnet *, u_long);
void ip_reass_init(void);
Index: src/sys/netinet/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.162 src/sys/netinet/raw_ip.c:1.163
--- src/sys/netinet/raw_ip.c:1.162 Tue Jan 24 07:09:24 2017
+++ src/sys/netinet/raw_ip.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_ip.c,v 1.162 2017/01/24 07:09:24 ozaki-r Exp $ */
+/* $NetBSD: raw_ip.c,v 1.163 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.162 2017/01/24 07:09:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.163 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -383,7 +383,7 @@ rip_output(struct mbuf *m, struct inpcb
* will be stored in inp_errormtu.
*/
return ip_output(m, opts, &inp->inp_route, flags, inp->inp_moptions,
- inp->inp_socket);
+ inp);
}
/*
Index: src/sys/netinet/sctp_output.c
diff -u src/sys/netinet/sctp_output.c:1.9 src/sys/netinet/sctp_output.c:1.10
--- src/sys/netinet/sctp_output.c:1.9 Fri Dec 23 11:11:28 2016
+++ src/sys/netinet/sctp_output.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sctp_output.c,v 1.9 2016/12/23 11:11:28 maya Exp $ */
+/* $NetBSD: sctp_output.c,v 1.10 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $KAME: sctp_output.c,v 1.48 2005/06/16 18:29:24 jinmei Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.9 2016/12/23 11:11:28 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.10 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -2251,7 +2251,7 @@ sctp_lowlevel_chunk_output(struct sctp_i
}
ret = ip_output(m, inp->ip_inp.inp.inp_options,
ro, o_flgs, inp->ip_inp.inp.inp_moptions,
- (struct socket *)inp->sctp_socket);
+ &inp->ip_inp.inp);
if ((rt) && (have_mtu) && (net) && (have_mtu > net->mtu)) {
rt->rt_ifp->if_mtu = have_mtu;
}
@@ -2449,7 +2449,7 @@ sctp_lowlevel_chunk_output(struct sctp_i
ro,
o_flgs,
((struct in6pcb *)inp)->in6p_moptions,
- (struct socket *)inp->sctp_socket,
+ (struct in6pcb *)inp,
&ifp);
if (net) {
/* for link local this must be done */
Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.354 src/sys/netinet/tcp_input.c:1.355
--- src/sys/netinet/tcp_input.c:1.354 Tue Feb 7 02:38:08 2017
+++ src/sys/netinet/tcp_input.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_input.c,v 1.354 2017/02/07 02:38:08 ozaki-r Exp $ */
+/* $NetBSD: tcp_input.c,v 1.355 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.354 2017/02/07 02:38:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.355 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -4535,7 +4535,6 @@ syn_cache_respond(struct syn_cache *sc,
struct tcpcb *tp = NULL;
struct tcphdr *th;
u_int hlen;
- struct socket *so;
#ifdef TCP_SIGNATURE
struct secasvar *sav = NULL;
u_int8_t *sigp = NULL;
@@ -4584,18 +4583,8 @@ syn_cache_respond(struct syn_cache *sc,
/* Fixup the mbuf. */
m->m_data += max_linkhdr;
- if (sc->sc_tp) {
+ if (sc->sc_tp)
tp = sc->sc_tp;
- if (tp->t_inpcb)
- so = tp->t_inpcb->inp_socket;
-#ifdef INET6
- else if (tp->t_in6pcb)
- so = tp->t_in6pcb->in6p_socket;
-#endif
- else
- so = NULL;
- } else
- so = NULL;
m_reset_rcvif(m);
memset(mtod(m, u_char *), 0, tlen);
@@ -4818,7 +4807,7 @@ syn_cache_respond(struct syn_cache *sc,
case AF_INET:
error = ip_output(m, sc->sc_ipopts, ro,
(ip_mtudisc ? IP_MTUDISC : 0),
- NULL, so);
+ NULL, tp ? tp->t_inpcb : NULL);
break;
#endif
#ifdef INET6
@@ -4827,7 +4816,8 @@ syn_cache_respond(struct syn_cache *sc,
(rt = rtcache_validate(ro)) != NULL ? rt->rt_ifp : NULL);
rtcache_unref(rt, ro);
- error = ip6_output(m, NULL /*XXX*/, ro, 0, NULL, so, NULL);
+ error = ip6_output(m, NULL /*XXX*/, ro, 0, NULL,
+ tp ? tp->t_in6pcb : NULL, NULL);
break;
#endif
default:
Index: src/sys/netinet/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.194 src/sys/netinet/tcp_output.c:1.195
--- src/sys/netinet/tcp_output.c:1.194 Wed Jan 4 15:09:37 2017
+++ src/sys/netinet/tcp_output.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_output.c,v 1.194 2017/01/04 15:09:37 martin Exp $ */
+/* $NetBSD: tcp_output.c,v 1.195 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.194 2017/01/04 15:09:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.195 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1680,7 +1680,7 @@ timer:
opts = NULL;
error = ip_output(m, opts, ro,
(tp->t_mtudisc ? IP_MTUDISC : 0) |
- (so->so_options & SO_DONTROUTE), NULL, so);
+ (so->so_options & SO_DONTROUTE), NULL, tp->t_inpcb);
break;
}
#endif
@@ -1694,7 +1694,7 @@ timer:
else
opts = NULL;
error = ip6_output(m, opts, ro, so->so_options & SO_DONTROUTE,
- NULL, so, NULL);
+ NULL, tp->t_in6pcb, NULL);
break;
}
#endif
Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.269 src/sys/netinet/tcp_subr.c:1.270
--- src/sys/netinet/tcp_subr.c:1.269 Mon Jan 2 01:18:42 2017
+++ src/sys/netinet/tcp_subr.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_subr.c,v 1.269 2017/01/02 01:18:42 christos Exp $ */
+/* $NetBSD: tcp_subr.c,v 1.270 2017/03/03 07:13:06 ozaki-r 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.269 2017/01/02 01:18:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.270 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -649,7 +649,6 @@ tcp_respond(struct tcpcb *tp, struct mbu
#endif
int family; /* family on packet, not inpcb/in6pcb! */
struct tcphdr *th;
- struct socket *so;
if (tp != NULL && (flags & TH_RST) == 0) {
#ifdef DIAGNOSTIC
@@ -892,15 +891,6 @@ tcp_respond(struct tcpcb *tp, struct mbu
#endif
}
- if (tp && tp->t_inpcb)
- so = tp->t_inpcb->inp_socket;
-#ifdef INET6
- else if (tp && tp->t_in6pcb)
- so = tp->t_in6pcb->in6p_socket;
-#endif
- else
- so = NULL;
-
if (tp != NULL && tp->t_inpcb != NULL) {
ro = &tp->t_inpcb->inp_route;
#ifdef DIAGNOSTIC
@@ -941,12 +931,14 @@ tcp_respond(struct tcpcb *tp, struct mbu
#ifdef INET
case AF_INET:
error = ip_output(m, NULL, ro,
- (tp && tp->t_mtudisc ? IP_MTUDISC : 0), NULL, so);
+ (tp && tp->t_mtudisc ? IP_MTUDISC : 0), NULL,
+ tp ? tp->t_inpcb : NULL);
break;
#endif
#ifdef INET6
case AF_INET6:
- error = ip6_output(m, NULL, ro, 0, NULL, so, NULL);
+ error = ip6_output(m, NULL, ro, 0, NULL,
+ tp ? tp->t_in6pcb : NULL, NULL);
break;
#endif
default:
Index: src/sys/netinet/udp_usrreq.c
diff -u src/sys/netinet/udp_usrreq.c:1.230 src/sys/netinet/udp_usrreq.c:1.231
--- src/sys/netinet/udp_usrreq.c:1.230 Tue Jan 24 07:09:24 2017
+++ src/sys/netinet/udp_usrreq.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: udp_usrreq.c,v 1.230 2017/01/24 07:09:24 ozaki-r Exp $ */
+/* $NetBSD: udp_usrreq.c,v 1.231 2017/03/03 07:13:06 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.230 2017/01/24 07:09:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.231 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -848,7 +848,7 @@ udp_output(struct mbuf *m, struct inpcb
return (ip_output(m, inp->inp_options, ro,
inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
- inp->inp_moptions, inp->inp_socket));
+ inp->inp_moptions, inp));
release:
m_freem(m);
Index: src/sys/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.190 src/sys/netinet6/ip6_output.c:1.191
--- src/sys/netinet6/ip6_output.c:1.190 Thu Mar 2 05:26:24 2017
+++ src/sys/netinet6/ip6_output.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_output.c,v 1.190 2017/03/02 05:26:24 ozaki-r Exp $ */
+/* $NetBSD: ip6_output.c,v 1.191 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.190 2017/03/02 05:26:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.191 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -222,7 +222,7 @@ ip6_output(
struct route *ro,
int flags,
struct ip6_moptions *im6o,
- struct socket *so,
+ struct in6pcb *in6p,
struct ifnet **ifpp /* XXX: just for statistics */
)
{
@@ -311,7 +311,7 @@ ip6_output(
if (ipsec_used) {
/* Check the security policy (SP) for the packet */
- sp = ipsec6_check_policy(m, so, flags, &needipsec, &error);
+ sp = ipsec6_check_policy(m, in6p, flags, &needipsec, &error);
if (error != 0) {
/*
* Hack: -EINVAL is used to signal that a packet
Index: src/sys/netinet6/ip6_var.h
diff -u src/sys/netinet6/ip6_var.h:1.73 src/sys/netinet6/ip6_var.h:1.74
--- src/sys/netinet6/ip6_var.h:1.73 Thu Mar 2 05:24:23 2017
+++ src/sys/netinet6/ip6_var.h Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_var.h,v 1.73 2017/03/02 05:24:23 ozaki-r Exp $ */
+/* $NetBSD: ip6_var.h,v 1.74 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -349,10 +349,8 @@ void ip6_forward(struct mbuf *, int);
void ip6_mloopback(struct ifnet *, struct mbuf *,
const struct sockaddr_in6 *);
-int ip6_output(struct mbuf *, struct ip6_pktopts *,
- struct route *, int,
- struct ip6_moptions *, struct socket *,
- struct ifnet **);
+int ip6_output(struct mbuf *, struct ip6_pktopts *, struct route *, int,
+ struct ip6_moptions *, struct in6pcb *, struct ifnet **);
int ip6_if_output(struct ifnet * const, struct ifnet * const,
struct mbuf * const,
const struct sockaddr_in6 * const, const struct rtentry *);
Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.155 src/sys/netinet6/raw_ip6.c:1.156
--- src/sys/netinet6/raw_ip6.c:1.155 Tue Jan 24 07:09:25 2017
+++ src/sys/netinet6/raw_ip6.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_ip6.c,v 1.155 2017/01/24 07:09:25 ozaki-r Exp $ */
+/* $NetBSD: raw_ip6.c,v 1.156 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.155 2017/01/24 07:09:25 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.156 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -514,7 +514,7 @@ rip6_output(struct mbuf *m, struct socke
struct ifnet *ret_oifp = NULL;
error = ip6_output(m, optp, &in6p->in6p_route, 0,
- in6p->in6p_moptions, so, &ret_oifp);
+ in6p->in6p_moptions, in6p, &ret_oifp);
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
if (ret_oifp)
icmp6_ifoutstat_inc(ret_oifp, type, code);
Index: src/sys/netinet6/udp6_output.c
diff -u src/sys/netinet6/udp6_output.c:1.54 src/sys/netinet6/udp6_output.c:1.55
--- src/sys/netinet6/udp6_output.c:1.54 Mon Oct 31 04:16:25 2016
+++ src/sys/netinet6/udp6_output.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: udp6_output.c,v 1.54 2016/10/31 04:16:25 ozaki-r Exp $ */
+/* $NetBSD: udp6_output.c,v 1.55 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.54 2016/10/31 04:16:25 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.55 2017/03/03 07:13:06 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -381,7 +381,7 @@ udp6_output(struct in6pcb * const in6p,
UDP6_STATINC(UDP6_STAT_OPACKETS);
error = ip6_output(m, optp, &in6p->in6p_route, 0,
- in6p->in6p_moptions, in6p->in6p_socket, NULL);
+ in6p->in6p_moptions, in6p, NULL);
break;
case AF_INET:
#ifdef INET
@@ -413,7 +413,7 @@ udp6_output(struct in6pcb * const in6p,
UDP_STATINC(UDP_STAT_OPACKETS);
error = ip_output(m, NULL, &in6p->in6p_route, flags /* XXX */,
- in6p->in6p_v4moptions, (struct socket *)in6p->in6p_socket);
+ in6p->in6p_v4moptions, NULL);
break;
#else
error = EAFNOSUPPORT;
Index: src/sys/netipsec/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.69 src/sys/netipsec/ipsec.c:1.70
--- src/sys/netipsec/ipsec.c:1.69 Mon Jan 16 15:44:47 2017
+++ src/sys/netipsec/ipsec.c Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.69 2017/01/16 15:44:47 christos Exp $ */
+/* $NetBSD: ipsec.c,v 1.70 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/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.69 2017/01/16 15:44:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.70 2017/03/03 07:13:06 ozaki-r Exp $");
/*
* IPsec controller part.
@@ -735,17 +735,13 @@ ipsec4_checkpolicy(struct mbuf *m, u_int
}
int
-ipsec4_output(struct mbuf *m, struct socket *so, int flags,
+ipsec4_output(struct mbuf *m, struct inpcb *inp, int flags,
struct secpolicy **sp_out, u_long *mtu, bool *natt_frag, bool *done)
{
const struct ip *ip = mtod(m, const struct ip *);
struct secpolicy *sp = NULL;
- struct inpcb *inp;
int error, s;
- inp = (so && so->so_proto->pr_domain->dom_family == AF_INET) ?
- (struct inpcb *)so->so_pcb : NULL;
-
/*
* Check the security policy (SP) for the packet and, if required,
* do IPsec-related processing. There are two cases here; the first
@@ -2384,18 +2380,14 @@ ipsec_dumpmbuf(struct mbuf *m)
#ifdef INET6
struct secpolicy *
-ipsec6_check_policy(struct mbuf *m, const struct socket *so,
+ipsec6_check_policy(struct mbuf *m, struct in6pcb *in6p,
int flags, int *needipsecp, int *errorp)
{
- struct in6pcb *in6p = NULL;
struct secpolicy *sp = NULL;
int s;
int error = 0;
int needipsec = 0;
- if (so != NULL && so->so_proto->pr_domain->dom_family == AF_INET6)
- in6p = sotoin6pcb(so);
-
if (!ipsec_outdone(m)) {
s = splsoftnet();
if (in6p != NULL &&
Index: src/sys/netipsec/ipsec.h
diff -u src/sys/netipsec/ipsec.h:1.37 src/sys/netipsec/ipsec.h:1.38
--- src/sys/netipsec/ipsec.h:1.37 Wed Apr 1 02:49:44 2015
+++ src/sys/netipsec/ipsec.h Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.h,v 1.37 2015/04/01 02:49:44 ozaki-r Exp $ */
+/* $NetBSD: ipsec.h,v 1.38 2017/03/03 07:13:06 ozaki-r 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 $ */
@@ -256,7 +256,7 @@ struct secpolicy *ipsec4_checkpolicy (st
int *, struct inpcb *);
struct secpolicy * ipsec_getpolicybyaddr(struct mbuf *, u_int,
int, int *);
-int ipsec4_output(struct mbuf *, struct socket *, int,
+int ipsec4_output(struct mbuf *, struct inpcb *, int,
struct secpolicy **, u_long *, bool *, bool *);
int ipsec4_input(struct mbuf *, int);
int ipsec4_forward(struct mbuf *, int *);
Index: src/sys/netipsec/ipsec6.h
diff -u src/sys/netipsec/ipsec6.h:1.14 src/sys/netipsec/ipsec6.h:1.15
--- src/sys/netipsec/ipsec6.h:1.14 Thu Jul 7 06:55:43 2016
+++ src/sys/netipsec/ipsec6.h Fri Mar 3 07:13:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec6.h,v 1.14 2016/07/07 06:55:43 msaitoh Exp $ */
+/* $NetBSD: ipsec6.h,v 1.15 2017/03/03 07:13:06 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/ipsec6.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $ */
/* $KAME: ipsec.h,v 1.44 2001/03/23 08:08:47 itojun Exp $ */
@@ -67,7 +67,7 @@ int ipsec6_get_policy (struct in6pcb *,
struct secpolicy *ipsec6_checkpolicy (struct mbuf *, u_int,
u_int, int *, struct in6pcb *);
struct secpolicy * ipsec6_check_policy(struct mbuf *,
- const struct socket *, int, int*,int*);
+ struct in6pcb *, int, int*,int*);
int ipsec6_in_reject (struct mbuf *, struct in6pcb *);
/*
* KAME ipsec6_in_reject_so(struct mbuf*, struct so) compatibility shim