summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorozaki-r <ozaki-r@NetBSD.org>2022-10-28 05:18:39 +0000
committerozaki-r <ozaki-r@NetBSD.org>2022-10-28 05:18:39 +0000
commit140683a5e6f35842e5eed3c33780e49d9bf8a812 (patch)
tree77357d085f843e7308803167c41f06f5e704fbd6 /sys/netinet6
parent175db7a8c8851b70e4b3cb1f7ffbaaf3c82e42a7 (diff)
inpcb: integrate data structures of PCB into one
Data structures of network protocol control blocks (PCBs), i.e., struct inpcb, in6pcb and inpcb_hdr, are not organized well. Users of the data structures have to handle them separately and thus the code is cluttered and duplicated. The commit integrates the data structures into one, struct inpcb. As a result, users of PCBs only have to handle just one data structure, so the code becomes simple. One drawback is that the data size of PCB for IPv4 increases by 40 bytes (from 248 bytes to 288 bytes).
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/icmp6.c55
-rw-r--r--sys/netinet6/in6_pcb.c566
-rw-r--r--sys/netinet6/in6_pcb.h141
-rw-r--r--sys/netinet6/in6_src.c40
-rw-r--r--sys/netinet6/ip6_input.c28
-rw-r--r--sys/netinet6/ip6_output.c121
-rw-r--r--sys/netinet6/ip6_var.h12
-rw-r--r--sys/netinet6/raw_ip6.c150
-rw-r--r--sys/netinet6/udp6_usrreq.c212
-rw-r--r--sys/netinet6/udp6_var.h4
10 files changed, 518 insertions, 811 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index eec4a88aef4..b747ccb2bdc 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp6.c,v 1.252 2022/08/29 09:14:02 knakahara Exp $ */
+/* $NetBSD: icmp6.c,v 1.253 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.252 2022/08/29 09:14:02 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.253 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -90,6 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.252 2022/08/29 09:14:02 knakahara Exp $"
#include <net/nd.h>
#include <netinet/in.h>
+#include <netinet/in_pcb.h>
#include <netinet/in_var.h>
#include <netinet/ip6.h>
#include <netinet/wqinput.h>
@@ -1939,9 +1940,8 @@ icmp6_rip6_input(struct mbuf **mp, int off)
{
struct mbuf *m = *mp;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
- struct inpcb_hdr *inph;
- struct in6pcb *in6p;
- struct in6pcb *last = NULL;
+ struct inpcb *inp;
+ struct inpcb *last = NULL;
struct sockaddr_in6 rip6src;
struct icmp6_hdr *icmp6;
struct mbuf *n, *opts = NULL;
@@ -1962,21 +1962,20 @@ icmp6_rip6_input(struct mbuf **mp, int off)
return IPPROTO_DONE;
}
- TAILQ_FOREACH(inph, &raw6cbtable.inpt_queue, inph_queue) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ TAILQ_FOREACH(inp, &raw6cbtable.inpt_queue, inp_queue) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (in6p->in6p_ip6.ip6_nxt != IPPROTO_ICMPV6)
+ if (inp->inp_ip6.ip6_nxt != IPPROTO_ICMPV6)
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &ip6->ip6_dst))
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, &ip6->ip6_src))
continue;
- if (in6p->in6p_icmp6filt &&
+ if (inp->inp_icmp6filt &&
ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
- in6p->in6p_icmp6filt))
+ inp->inp_icmp6filt))
continue;
if (last == NULL) {
@@ -1988,23 +1987,23 @@ icmp6_rip6_input(struct mbuf **mp, int off)
}
#endif
else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, &opts, ip6, n);
/* strip intermediate headers */
m_adj(n, off);
- if (sbappendaddr(&last->in6p_socket->so_rcv,
+ if (sbappendaddr(&last->inp_socket->so_rcv,
sin6tosa(&rip6src), n, opts) == 0) {
- soroverflow(last->in6p_socket);
+ soroverflow(last->inp_socket);
m_freem(n);
if (opts)
m_freem(opts);
} else {
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
}
opts = NULL;
}
- last = in6p;
+ last = inp;
}
#ifdef IPSEC
@@ -2015,18 +2014,18 @@ icmp6_rip6_input(struct mbuf **mp, int off)
} else
#endif
if (last) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, &opts, ip6, m);
/* strip intermediate headers */
m_adj(m, off);
- if (sbappendaddr(&last->in6p_socket->so_rcv,
+ if (sbappendaddr(&last->inp_socket->so_rcv,
sin6tosa(&rip6src), m, opts) == 0) {
- soroverflow(last->in6p_socket);
+ soroverflow(last->inp_socket);
m_freem(m);
if (opts)
m_freem(opts);
} else {
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
}
} else {
m_freem(m);
@@ -2741,7 +2740,7 @@ int
icmp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
{
int error = 0;
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
if (sopt->sopt_level != IPPROTO_ICMPV6)
return rip6_ctloutput(op, so, sopt);
@@ -2756,7 +2755,7 @@ icmp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
error = sockopt_get(sopt, &fil, sizeof(fil));
if (error)
break;
- memcpy(in6p->in6p_icmp6filt, &fil,
+ memcpy(inp->inp_icmp6filt, &fil,
sizeof(struct icmp6_filter));
error = 0;
break;
@@ -2772,11 +2771,11 @@ icmp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
switch (sopt->sopt_name) {
case ICMP6_FILTER:
{
- if (in6p->in6p_icmp6filt == NULL) {
+ if (inp->inp_icmp6filt == NULL) {
error = EINVAL;
break;
}
- error = sockopt_set(sopt, in6p->in6p_icmp6filt,
+ error = sockopt_set(sopt, inp->inp_icmp6filt,
sizeof(struct icmp6_filter));
break;
}
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 53fbd5903d5..4e29badc167 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.c,v 1.171 2022/10/14 19:39:32 ryo Exp $ */
+/* $NetBSD: in6_pcb.c,v 1.172 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.171 2022/10/14 19:39:32 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.172 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -129,76 +129,19 @@ int ip6_anonportmax = IPV6PORT_ANONMAX;
int ip6_lowportmin = IPV6PORT_RESERVEDMIN;
int ip6_lowportmax = IPV6PORT_RESERVEDMAX;
-static struct pool in6pcb_pool;
-
-static int
-in6pcb_poolinit(void)
-{
-
- pool_init(&in6pcb_pool, sizeof(struct in6pcb), 0, 0, 0, "in6pcbpl",
- NULL, IPL_SOFTNET);
- return 0;
-}
-
void
in6_pcbinit(struct inpcbtable *table, int bindhashsize, int connecthashsize)
{
- static ONCE_DECL(control);
in_pcbinit(table, bindhashsize, connecthashsize);
table->inpt_lastport = (u_int16_t)ip6_anonportmax;
-
- RUN_ONCE(&control, in6pcb_poolinit);
-}
-
-int
-in6_pcballoc(struct socket *so, void *v)
-{
- struct inpcbtable *table = v;
- struct in6pcb *in6p;
- int s;
-
- KASSERT(so->so_proto->pr_domain->dom_family == AF_INET6);
-
- in6p = pool_get(&in6pcb_pool, PR_NOWAIT);
- if (in6p == NULL)
- return (ENOBUFS);
- memset((void *)in6p, 0, sizeof(*in6p));
- in6p->in6p_af = AF_INET6;
- in6p->in6p_table = table;
- in6p->in6p_socket = so;
- in6p->in6p_hops = -1; /* use kernel default */
- in6p->in6p_icmp6filt = NULL;
- in6p->in6p_portalgo = PORTALGO_DEFAULT;
- in6p->in6p_bindportonsend = false;
-#if defined(IPSEC)
- if (ipsec_enabled) {
- int error = ipsec_init_pcbpolicy(so, &in6p->in6p_sp);
- if (error != 0) {
- pool_put(&in6pcb_pool, in6p);
- return error;
- }
- in6p->in6p_sp->sp_inph = (struct inpcb_hdr *)in6p;
- }
-#endif /* IPSEC */
- s = splsoftnet();
- TAILQ_INSERT_HEAD(&table->inpt_queue, (struct inpcb_hdr*)in6p,
- inph_queue);
- LIST_INSERT_HEAD(IN6PCBHASH_PORT(table, in6p->in6p_lport),
- &in6p->in6p_head, inph_lhash);
- in6_pcbstate(in6p, IN6P_ATTACHED);
- splx(s);
- if (ip6_v6only)
- in6p->in6p_flags |= IN6P_IPV6_V6ONLY;
- so->so_pcb = (void *)in6p;
- return (0);
}
/*
- * Bind address from sin6 to in6p.
+ * Bind address from sin6 to inp.
*/
static int
-in6_pcbbind_addr(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
+in6_pcbbind_addr(struct inpcb *inp, struct sockaddr_in6 *sin6, struct lwp *l)
{
int error;
int s;
@@ -220,7 +163,7 @@ in6_pcbbind_addr(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
s = pserialize_read_enter();
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0) {
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
error = EINVAL;
goto out;
}
@@ -236,7 +179,7 @@ in6_pcbbind_addr(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
struct ifaddr *ifa;
ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
if (ifa == NULL &&
- (in6p->in6p_flags & IN6P_BINDANY) == 0) {
+ (inp->inp_flags & IN6P_BINDANY) == 0) {
error = EADDRNOTAVAIL;
goto out;
}
@@ -247,10 +190,10 @@ in6_pcbbind_addr(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
} else if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
struct ifaddr *ifa = NULL;
- if ((in6p->in6p_flags & IN6P_FAITH) == 0) {
+ if ((inp->inp_flags & IN6P_FAITH) == 0) {
ifa = ifa_ifwithaddr(sin6tosa(sin6));
if (ifa == NULL &&
- (in6p->in6p_flags & IN6P_BINDANY) == 0) {
+ (inp->inp_flags & IN6P_BINDANY) == 0) {
error = EADDRNOTAVAIL;
goto out;
}
@@ -276,7 +219,7 @@ in6_pcbbind_addr(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
goto out;
}
}
- in6p->in6p_laddr = sin6->sin6_addr;
+ inp->inp_laddr6 = sin6->sin6_addr;
error = 0;
out:
pserialize_read_exit(s);
@@ -284,13 +227,13 @@ out:
}
/*
- * Bind port from sin6 to in6p.
+ * Bind port from sin6 to inp.
*/
static int
-in6_pcbbind_port(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
+in6_pcbbind_port(struct inpcb *inp, struct sockaddr_in6 *sin6, struct lwp *l)
{
- struct inpcbtable *table = in6p->in6p_table;
- struct socket *so = in6p->in6p_socket;
+ struct inpcbtable *table = inp->inp_table;
+ struct socket *so = inp->inp_socket;
int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
int error;
@@ -348,12 +291,12 @@ in6_pcbbind_port(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
}
{
- struct in6pcb *t;
+ struct inpcb *t;
struct vestigial_inpcb vestige;
t = in6_pcblookup_port(table, &sin6->sin6_addr,
sin6->sin6_port, wild, &vestige);
- if (t && (reuseport & t->in6p_socket->so_options) == 0)
+ if (t && (reuseport & t->inp_socket->so_options) == 0)
return (EADDRINUSE);
if (!t
&& vestige.valid
@@ -364,17 +307,17 @@ in6_pcbbind_port(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
if (sin6->sin6_port == 0) {
int e;
- e = in6_pcbsetport(sin6, in6p, l);
+ e = in6_pcbsetport(sin6, inp, l);
if (e != 0)
return (e);
} else {
- in6p->in6p_lport = sin6->sin6_port;
- in6_pcbstate(in6p, IN6P_BOUND);
+ inp->inp_lport = sin6->sin6_port;
+ in_pcbstate(inp, INP_BOUND);
}
- LIST_REMOVE(&in6p->in6p_head, inph_lhash);
- LIST_INSERT_HEAD(IN6PCBHASH_PORT(table, in6p->in6p_lport),
- &in6p->in6p_head, inph_lhash);
+ LIST_REMOVE(inp, inp_lhash);
+ LIST_INSERT_HEAD(IN6PCBHASH_PORT(table, inp->inp_lport),
+ inp, inp_lhash);
return (0);
}
@@ -382,20 +325,20 @@ in6_pcbbind_port(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
int
in6_pcbbind(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
{
- struct in6pcb *in6p = v;
+ struct inpcb *inp = v;
struct sockaddr_in6 lsin6;
int error;
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return (EINVAL);
/*
* If we already have a local port or a local address it means we're
* bounded.
*/
- if (in6p->in6p_lport || !(IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) ||
- (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr) &&
- in6p->in6p_laddr.s6_addr32[3] == 0)))
+ if (inp->inp_lport || !(IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) ||
+ (IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6) &&
+ inp->inp_laddr6.s6_addr32[3] == 0)))
return (EINVAL);
if (NULL != sin6) {
@@ -405,30 +348,30 @@ in6_pcbbind(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
} else {
/* We always bind to *something*, even if it's "anything". */
lsin6 = *((const struct sockaddr_in6 *)
- in6p->in6p_socket->so_proto->pr_domain->dom_sa_any);
+ inp->inp_socket->so_proto->pr_domain->dom_sa_any);
sin6 = &lsin6;
}
/* Bind address. */
- error = in6_pcbbind_addr(in6p, sin6, l);
+ error = in6_pcbbind_addr(inp, sin6, l);
if (error)
return (error);
/* Bind port. */
- error = in6_pcbbind_port(in6p, sin6, l);
+ error = in6_pcbbind_port(inp, sin6, l);
if (error) {
/*
* Reset the address here to "any" so we don't "leak" the
- * in6pcb.
+ * inpcb.
*/
- in6p->in6p_laddr = in6addr_any;
+ inp->inp_laddr6 = in6addr_any;
return (error);
}
#if 0
- in6p->in6p_flowinfo = 0; /* XXX */
+ inp->inp_flowinfo = 0; /* XXX */
#endif
return (0);
}
@@ -442,7 +385,7 @@ in6_pcbbind(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
int
in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
{
- struct in6pcb *in6p = v;
+ struct inpcb *inp = v;
struct in6_addr *in6a = NULL;
struct in6_addr ia6;
struct ifnet *ifp = NULL; /* outgoing interface */
@@ -458,7 +401,7 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
(void)&in6a; /* XXX fool gcc */
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return (EINVAL);
if (sin6->sin6_len != sizeof(*sin6))
@@ -469,7 +412,7 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
return (EADDRNOTAVAIL);
if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) &&
- in6p->in6p_socket->so_type == SOCK_STREAM)
+ inp->inp_socket->so_type == SOCK_STREAM)
return EADDRNOTAVAIL;
if (sin6->sin6_scope_id == 0 && !ip6_use_defzone)
@@ -479,15 +422,15 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
/* sanity check for mapped address case */
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
return EINVAL;
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr))
- in6p->in6p_laddr.s6_addr16[5] = htons(0xffff);
- if (!IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr))
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6))
+ inp->inp_laddr6.s6_addr16[5] = htons(0xffff);
+ if (!IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6))
return EINVAL;
} else
{
- if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr))
+ if (IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6))
return EINVAL;
}
@@ -497,8 +440,8 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
bound = curlwp_bind();
/* Source address selection. */
- if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr) &&
- in6p->in6p_laddr.s6_addr32[3] == 0) {
+ if (IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6) &&
+ inp->inp_laddr6.s6_addr32[3] == 0) {
#ifdef INET
struct sockaddr_in sin;
struct in_ifaddr *ia4;
@@ -509,8 +452,8 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
sin.sin_family = AF_INET;
memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr32[3],
sizeof(sin.sin_addr));
- ia4 = in_selectsrc(&sin, &in6p->in6p_route,
- in6p->in6p_socket->so_options, NULL, &error, &_psref);
+ ia4 = in_selectsrc(&sin, &inp->inp_route,
+ inp->inp_socket->so_options, NULL, &error, &_psref);
if (ia4 == NULL) {
if (error == 0)
error = EADDRNOTAVAIL;
@@ -533,8 +476,8 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
* with the address specified by setsockopt(IPV6_PKTINFO).
* Is it the intended behavior?
*/
- error = in6_selectsrc(sin6, in6p->in6p_outputopts,
- in6p->in6p_moptions, &in6p->in6p_route, &in6p->in6p_laddr,
+ error = in6_selectsrc(sin6, inp->inp_outputopts6,
+ inp->inp_moptions6, &inp->inp_route, &inp->inp_laddr6,
&ifp, &psref, &ia6);
if (error == 0)
in6a = &ia6;
@@ -555,127 +498,89 @@ in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
}
if (ifp != NULL) {
- in6p->in6p_ip6.ip6_hlim = (u_int8_t)in6_selecthlim(in6p, ifp);
+ inp->inp_ip6.ip6_hlim = (u_int8_t)in6_selecthlim(inp, ifp);
if_put(ifp, &psref);
} else
- in6p->in6p_ip6.ip6_hlim = (u_int8_t)in6_selecthlim_rt(in6p);
+ inp->inp_ip6.ip6_hlim = (u_int8_t)in6_selecthlim_rt(inp);
curlwp_bindx(bound);
- if (in6_pcblookup_connect(in6p->in6p_table, &sin6->sin6_addr,
+ if (in6_pcblookup_connect(inp->inp_table, &sin6->sin6_addr,
sin6->sin6_port,
- IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) ? in6a : &in6p->in6p_laddr,
- in6p->in6p_lport, 0, &vestige)
+ IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) ? in6a : &inp->inp_laddr6,
+ inp->inp_lport, 0, &vestige)
|| vestige.valid)
return (EADDRINUSE);
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) ||
- (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr) &&
- in6p->in6p_laddr.s6_addr32[3] == 0))
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) ||
+ (IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6) &&
+ inp->inp_laddr6.s6_addr32[3] == 0))
{
- if (in6p->in6p_lport == 0) {
- error = in6_pcbbind(in6p, NULL, l);
+ if (inp->inp_lport == 0) {
+ error = in6_pcbbind(inp, NULL, l);
if (error != 0)
return error;
}
- in6p->in6p_laddr = *in6a;
+ inp->inp_laddr6 = *in6a;
}
- in6p->in6p_faddr = sin6->sin6_addr;
- in6p->in6p_fport = sin6->sin6_port;
+ inp->inp_faddr6 = sin6->sin6_addr;
+ inp->inp_fport = sin6->sin6_port;
/* Late bind, if needed */
- if (in6p->in6p_bindportonsend) {
+ if (inp->inp_bindportonsend) {
struct sockaddr_in6 lsin = *((const struct sockaddr_in6 *)
- in6p->in6p_socket->so_proto->pr_domain->dom_sa_any);
- lsin.sin6_addr = in6p->in6p_laddr;
+ inp->inp_socket->so_proto->pr_domain->dom_sa_any);
+ lsin.sin6_addr = inp->inp_laddr6;
lsin.sin6_port = 0;
- if ((error = in6_pcbbind_port(in6p, &lsin, l)) != 0)
+ if ((error = in6_pcbbind_port(inp, &lsin, l)) != 0)
return error;
}
- in6_pcbstate(in6p, IN6P_CONNECTED);
- in6p->in6p_flowinfo &= ~IPV6_FLOWLABEL_MASK;
+ in_pcbstate(inp, INP_CONNECTED);
+ inp->inp_flowinfo &= ~IPV6_FLOWLABEL_MASK;
if (ip6_auto_flowlabel)
- in6p->in6p_flowinfo |=
+ inp->inp_flowinfo |=
(htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK);
#if defined(IPSEC)
- if (ipsec_enabled && in6p->in6p_socket->so_type == SOCK_STREAM)
- ipsec_pcbconn(in6p->in6p_sp);
+ if (ipsec_enabled && inp->inp_socket->so_type == SOCK_STREAM)
+ ipsec_pcbconn(inp->inp_sp);
#endif
return (0);
}
void
-in6_pcbdisconnect(struct in6pcb *in6p)
+in6_pcbdisconnect(struct inpcb *inp)
{
- memset((void *)&in6p->in6p_faddr, 0, sizeof(in6p->in6p_faddr));
- in6p->in6p_fport = 0;
- in6_pcbstate(in6p, IN6P_BOUND);
- in6p->in6p_flowinfo &= ~IPV6_FLOWLABEL_MASK;
+ memset((void *)&inp->inp_faddr6, 0, sizeof(inp->inp_faddr6));
+ inp->inp_fport = 0;
+ in_pcbstate(inp, INP_BOUND);
+ inp->inp_flowinfo &= ~IPV6_FLOWLABEL_MASK;
#if defined(IPSEC)
if (ipsec_enabled)
- ipsec_pcbdisconn(in6p->in6p_sp);
+ ipsec_pcbdisconn(inp->inp_sp);
#endif
- if (in6p->in6p_socket->so_state & SS_NOFDREF)
- in6_pcbdetach(in6p);
+ if (inp->inp_socket->so_state & SS_NOFDREF)
+ in_pcbdetach(inp);
}
void
-in6_pcbdetach(struct in6pcb *in6p)
+in6_setsockaddr(struct inpcb *inp, struct sockaddr_in6 *sin6)
{
- struct socket *so = in6p->in6p_socket;
- int s;
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return;
-#if defined(IPSEC)
- if (ipsec_enabled)
- ipsec_delete_pcbpolicy(in6p);
-#endif
- so->so_pcb = NULL;
-
- s = splsoftnet();
- in6_pcbstate(in6p, IN6P_ATTACHED);
- LIST_REMOVE(&in6p->in6p_head, inph_lhash);
- TAILQ_REMOVE(&in6p->in6p_table->inpt_queue, &in6p->in6p_head,
- inph_queue);
- splx(s);
-
- if (in6p->in6p_options) {
- m_freem(in6p->in6p_options);
- }
- if (in6p->in6p_outputopts != NULL) {
- ip6_clearpktopts(in6p->in6p_outputopts, -1);
- free(in6p->in6p_outputopts, M_IP6OPT);
- }
- rtcache_free(&in6p->in6p_route);
- ip6_freemoptions(in6p->in6p_moptions);
- ip_freemoptions(in6p->in6p_v4moptions);
- sofree(so); /* drops the socket's lock */
-
- pool_put(&in6pcb_pool, in6p);
- mutex_enter(softnet_lock); /* reacquire it */
-}
-
-void
-in6_setsockaddr(struct in6pcb *in6p, struct sockaddr_in6 *sin6)
-{
-
- if (in6p->in6p_af != AF_INET6)
- return;
-
- sockaddr_in6_init(sin6, &in6p->in6p_laddr, in6p->in6p_lport, 0, 0);
+ sockaddr_in6_init(sin6, &inp->inp_laddr6, inp->inp_lport, 0, 0);
(void)sa6_recoverscope(sin6); /* XXX: should catch errors */
}
void
-in6_setpeeraddr(struct in6pcb *in6p, struct sockaddr_in6 *sin6)
+in6_setpeeraddr(struct inpcb *inp, struct sockaddr_in6 *sin6)
{
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return;
- sockaddr_in6_init(sin6, &in6p->in6p_faddr, in6p->in6p_fport, 0, 0);
+ sockaddr_in6_init(sin6, &inp->inp_faddr6, inp->inp_fport, 0, 0);
(void)sa6_recoverscope(sin6); /* XXX: should catch errors */
}
@@ -696,9 +601,9 @@ in6_setpeeraddr(struct in6pcb *in6p, struct sockaddr_in6 *sin6)
int
in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
u_int fport_arg, const struct sockaddr *src, u_int lport_arg, int cmd,
- void *cmdarg, void (*notify)(struct in6pcb *, int))
+ void *cmdarg, void (*notify)(struct inpcb *, int))
{
- struct inpcb_hdr *inph;
+ struct inpcb *inp;
struct sockaddr_in6 sa6_src;
const struct sockaddr_in6 *sa6_dst;
u_int16_t fport = fport_arg, lport = lport_arg;
@@ -737,11 +642,10 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
}
errno = inet6ctlerrmap[cmd];
- TAILQ_FOREACH(inph, &table->inpt_queue, inph_queue) {
- struct in6pcb *in6p = (struct in6pcb *)inph;
+ TAILQ_FOREACH(inp, &table->inpt_queue, inp_queue) {
struct rtentry *rt = NULL;
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
continue;
/*
@@ -776,22 +680,22 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
* icmp6_mtudisc_update().
*/
if ((PRC_IS_REDIRECT(cmd) || cmd == PRC_HOSTDEAD) &&
- IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
- (rt = rtcache_validate(&in6p->in6p_route)) != NULL &&
+ IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) &&
+ (rt = rtcache_validate(&inp->inp_route)) != NULL &&
!(rt->rt_flags & RTF_HOST)) {
const struct sockaddr_in6 *dst6;
dst6 = (const struct sockaddr_in6 *)
- rtcache_getdst(&in6p->in6p_route);
+ rtcache_getdst(&inp->inp_route);
if (dst6 == NULL)
;
else if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr,
&sa6_dst->sin6_addr)) {
- rtcache_unref(rt, &in6p->in6p_route);
+ rtcache_unref(rt, &inp->inp_route);
goto do_notify;
}
}
- rtcache_unref(rt, &in6p->in6p_route);
+ rtcache_unref(rt, &inp->inp_route);
/*
* If the error designates a new path MTU for a destination
@@ -802,10 +706,10 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
* sockets disconnected.
* XXX: should we avoid to notify the value to TCP sockets?
*/
- if (cmd == PRC_MSGSIZE && (in6p->in6p_flags & IN6P_MTU) != 0 &&
- (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) ||
- IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &sa6_dst->sin6_addr))) {
- ip6_notify_pmtu(in6p, (const struct sockaddr_in6 *)dst,
+ if (cmd == PRC_MSGSIZE && (inp->inp_flags & IN6P_MTU) != 0 &&
+ (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6) ||
+ IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, &sa6_dst->sin6_addr))) {
+ ip6_notify_pmtu(inp, (const struct sockaddr_in6 *)dst,
(u_int32_t *)cmdarg);
}
@@ -818,23 +722,23 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
* as usual.
*/
if (lport == 0 && fport == 0 && flowinfo &&
- in6p->in6p_socket != NULL &&
- flowinfo == (in6p->in6p_flowinfo & IPV6_FLOWLABEL_MASK) &&
- IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &sa6_src.sin6_addr))
+ inp->inp_socket != NULL &&
+ flowinfo == (inp->inp_flowinfo & IPV6_FLOWLABEL_MASK) &&
+ IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &sa6_src.sin6_addr))
goto do_notify;
- else if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr,
+ else if (!IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6,
&sa6_dst->sin6_addr) ||
- in6p->in6p_socket == NULL ||
- (lport && in6p->in6p_lport != lport) ||
+ inp->inp_socket == NULL ||
+ (lport && inp->inp_lport != lport) ||
(!IN6_IS_ADDR_UNSPECIFIED(&sa6_src.sin6_addr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,
+ !IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6,
&sa6_src.sin6_addr)) ||
- (fport && in6p->in6p_fport != fport))
+ (fport && inp->inp_fport != fport))
continue;
do_notify:
if (notify)
- (*notify)(in6p, errno);
+ (*notify)(inp, errno);
nmatch++;
}
return nmatch;
@@ -843,24 +747,23 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
void
in6_pcbpurgeif0(struct inpcbtable *table, struct ifnet *ifp)
{
- struct inpcb_hdr *inph;
+ struct inpcb *inp;
struct ip6_moptions *im6o;
struct in6_multi_mship *imm, *nimm;
KASSERT(ifp != NULL);
- TAILQ_FOREACH(inph, &table->inpt_queue, inph_queue) {
- struct in6pcb *in6p = (struct in6pcb *)inph;
+ TAILQ_FOREACH(inp, &table->inpt_queue, inp_queue) {
bool need_unlock = false;
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
continue;
- /* The caller holds either one of in6ps' lock */
- if (!in6p_locked(in6p)) {
- in6p_lock(in6p);
+ /* The caller holds either one of inps' lock */
+ if (!inp_locked(inp)) {
+ inp_lock(inp);
need_unlock = true;
}
- im6o = in6p->in6p_moptions;
+ im6o = inp->inp_moptions6;
if (im6o) {
/*
* Unselect the outgoing interface if it is being
@@ -884,10 +787,10 @@ in6_pcbpurgeif0(struct inpcbtable *table, struct ifnet *ifp)
}
}
- in_purgeifmcast(in6p->in6p_v4moptions, ifp);
+ in_purgeifmcast(inp->inp_moptions, ifp);
if (need_unlock)
- in6p_unlock(in6p);
+ inp_unlock(inp);
}
}
@@ -895,88 +798,43 @@ void
in6_pcbpurgeif(struct inpcbtable *table, struct ifnet *ifp)
{
struct rtentry *rt;
- struct inpcb_hdr *inph;
+ struct inpcb *inp;
- TAILQ_FOREACH(inph, &table->inpt_queue, inph_queue) {
- struct in6pcb *in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ TAILQ_FOREACH(inp, &table->inpt_queue, inp_queue) {
+ if (inp->inp_af != AF_INET6)
continue;
- if ((rt = rtcache_validate(&in6p->in6p_route)) != NULL &&
+ if ((rt = rtcache_validate(&inp->inp_route)) != NULL &&
rt->rt_ifp == ifp) {
- rtcache_unref(rt, &in6p->in6p_route);
- in6_rtchange(in6p, 0);
+ rtcache_unref(rt, &inp->inp_route);
+ in6_rtchange(inp, 0);
} else
- rtcache_unref(rt, &in6p->in6p_route);
+ rtcache_unref(rt, &inp->inp_route);
}
}
/*
- * Check for alternatives when higher level complains
- * about service problems. For now, invalidate cached
- * routing information. If the route was created dynamically
- * (by a redirect), time to try a default gateway again.
- */
-void
-in6_losing(struct in6pcb *in6p)
-{
- struct rtentry *rt;
- struct rt_addrinfo info;
-
- if (in6p->in6p_af != AF_INET6)
- return;
-
- if ((rt = rtcache_validate(&in6p->in6p_route)) == NULL)
- return;
-
- memset(&info, 0, sizeof(info));
- info.rti_info[RTAX_DST] = rtcache_getdst(&in6p->in6p_route);
- info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
- rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0);
- if (rt->rt_flags & RTF_DYNAMIC) {
- int error;
- struct rtentry *nrt;
-
- error = rtrequest(RTM_DELETE, rt_getkey(rt),
- rt->rt_gateway, rt_mask(rt), rt->rt_flags, &nrt);
- rtcache_unref(rt, &in6p->in6p_route);
- if (error == 0) {
- rt_newmsg_dynamic(RTM_DELETE, nrt);
- rt_free(nrt);
- }
- } else
- rtcache_unref(rt, &in6p->in6p_route);
- /*
- * A new route can be allocated
- * the next time output is attempted.
- */
- rtcache_free(&in6p->in6p_route);
-}
-
-/*
* After a routing change, flush old routing. A new route can be
* allocated the next time output is attempted.
*/
void
-in6_rtchange(struct in6pcb *in6p, int errno)
+in6_rtchange(struct inpcb *inp, int errno)
{
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return;
- rtcache_free(&in6p->in6p_route);
+ rtcache_free(&inp->inp_route);
/*
* A new route can be allocated the next time
* output is attempted.
*/
}
-struct in6pcb *
+struct inpcb *
in6_pcblookup_port(struct inpcbtable *table, struct in6_addr *laddr6,
u_int lport_arg, int lookup_wildcard, struct vestigial_inpcb *vp)
{
struct inpcbhead *head;
- struct inpcb_hdr *inph;
- struct in6pcb *in6p, *match = NULL;
+ struct inpcb *inp, *match = NULL;
int matchwild = 3, wildcard;
u_int16_t lport = lport_arg;
@@ -984,59 +842,58 @@ in6_pcblookup_port(struct inpcbtable *table, struct in6_addr *laddr6,
vp->valid = 0;
head = IN6PCBHASH_PORT(table, lport);
- LIST_FOREACH(inph, head, inph_lhash) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ LIST_FOREACH(inp, head, inp_lhash) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (in6p->in6p_lport != lport)
+ if (inp->inp_lport != lport)
continue;
wildcard = 0;
- if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ if (IN6_IS_ADDR_V4MAPPED(&inp->inp_faddr6)) {
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
}
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
wildcard++;
- if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ if (IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6)) {
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
if (!IN6_IS_ADDR_V4MAPPED(laddr6))
continue;
/* duplicate of IPv4 logic */
wildcard = 0;
- if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr) &&
- in6p->in6p_faddr.s6_addr32[3])
+ if (IN6_IS_ADDR_V4MAPPED(&inp->inp_faddr6) &&
+ inp->inp_faddr6.s6_addr32[3])
wildcard++;
- if (!in6p->in6p_laddr.s6_addr32[3]) {
+ if (!inp->inp_laddr6.s6_addr32[3]) {
if (laddr6->s6_addr32[3])
wildcard++;
} else {
if (!laddr6->s6_addr32[3])
wildcard++;
else {
- if (in6p->in6p_laddr.s6_addr32[3] !=
+ if (inp->inp_laddr6.s6_addr32[3] !=
laddr6->s6_addr32[3])
continue;
}
}
- } else if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
+ } else if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) {
if (IN6_IS_ADDR_V4MAPPED(laddr6)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
}
if (!IN6_IS_ADDR_UNSPECIFIED(laddr6))
wildcard++;
} else {
if (IN6_IS_ADDR_V4MAPPED(laddr6)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
}
if (IN6_IS_ADDR_UNSPECIFIED(laddr6))
wildcard++;
else {
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,
+ if (!IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6,
laddr6))
continue;
}
@@ -1044,7 +901,7 @@ in6_pcblookup_port(struct inpcbtable *table, struct in6_addr *laddr6,
if (wildcard && !lookup_wildcard)
continue;
if (wildcard < matchwild) {
- match = in6p;
+ match = inp;
matchwild = wildcard;
if (matchwild == 0)
break;
@@ -1105,11 +962,11 @@ in6_pcblookup_port(struct inpcbtable *table, struct in6_addr *laddr6,
}
/*
- * WARNING: return value (rtentry) could be IPv4 one if in6pcb is connected to
+ * WARNING: return value (rtentry) could be IPv4 one if inpcb is connected to
* IPv4 mapped address.
*/
struct rtentry *
-in6_pcbrtentry(struct in6pcb *in6p)
+in6_pcbrtentry(struct inpcb *inp)
{
struct rtentry *rt;
struct route *ro;
@@ -1121,9 +978,9 @@ in6_pcbrtentry(struct in6pcb *in6p)
#endif
} cdst;
- ro = &in6p->in6p_route;
+ ro = &inp->inp_route;
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return (NULL);
cdst.sa = rtcache_getdst(ro);
@@ -1131,27 +988,27 @@ in6_pcbrtentry(struct in6pcb *in6p)
;
#ifdef INET
else if (cdst.sa->sa_family == AF_INET) {
- KASSERT(IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr));
- if (cdst.sa4->sin_addr.s_addr != in6p->in6p_faddr.s6_addr32[3])
+ KASSERT(IN6_IS_ADDR_V4MAPPED(&inp->inp_faddr6));
+ if (cdst.sa4->sin_addr.s_addr != inp->inp_faddr6.s6_addr32[3])
rtcache_free(ro);
}
#endif
else {
if (!IN6_ARE_ADDR_EQUAL(&cdst.sa6->sin6_addr,
- &in6p->in6p_faddr))
+ &inp->inp_faddr6))
rtcache_free(ro);
}
if ((rt = rtcache_validate(ro)) == NULL)
rt = rtcache_update(ro, 1);
#ifdef INET
- if (rt == NULL && IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
+ if (rt == NULL && IN6_IS_ADDR_V4MAPPED(&inp->inp_faddr6)) {
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
struct in_addr addr;
- addr.s_addr = in6p->in6p_faddr.s6_addr32[3];
+ addr.s_addr = inp->inp_faddr6.s6_addr32[3];
sockaddr_in_init(&u.dst4, &addr, 0);
if (rtcache_setdst(ro, &u.dst) != 0)
@@ -1160,13 +1017,13 @@ in6_pcbrtentry(struct in6pcb *in6p)
rt = rtcache_init(ro);
} else
#endif
- if (rt == NULL && !IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
+ if (rt == NULL && !IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
- sockaddr_in6_init(&u.dst6, &in6p->in6p_faddr, 0, 0, 0);
+ sockaddr_in6_init(&u.dst6, &inp->inp_faddr6, 0, 0, 0);
if (rtcache_setdst(ro, &u.dst) != 0)
return NULL;
@@ -1176,50 +1033,48 @@ in6_pcbrtentry(struct in6pcb *in6p)
}
void
-in6_pcbrtentry_unref(struct rtentry *rt, struct in6pcb *in6p)
+in6_pcbrtentry_unref(struct rtentry *rt, struct inpcb *inp)
{
- rtcache_unref(rt, &in6p->in6p_route);
+ rtcache_unref(rt, &inp->inp_route);
}
-struct in6pcb *
+struct inpcb *
in6_pcblookup_connect(struct inpcbtable *table, const struct in6_addr *faddr6,
u_int fport_arg, const struct in6_addr *laddr6, u_int lport_arg,
int faith,
struct vestigial_inpcb *vp)
{
struct inpcbhead *head;
- struct inpcb_hdr *inph;
- struct in6pcb *in6p;
+ struct inpcb *inp;
u_int16_t fport = fport_arg, lport = lport_arg;
if (vp)
vp->valid = 0;
head = IN6PCBHASH_CONNECT(table, faddr6, fport, laddr6, lport);
- LIST_FOREACH(inph, head, inph_hash) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ LIST_FOREACH(inp, head, inp_hash) {
+ if (inp->inp_af != AF_INET6)
continue;
/* find exact match on both source and dest */
- if (in6p->in6p_fport != fport)
+ if (inp->inp_fport != fport)
continue;
- if (in6p->in6p_lport != lport)
+ if (inp->inp_lport != lport)
continue;
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
continue;
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, faddr6))
+ if (!IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, faddr6))
continue;
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr))
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6))
continue;
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, laddr6))
+ if (!IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, laddr6))
continue;
if ((IN6_IS_ADDR_V4MAPPED(laddr6) ||
IN6_IS_ADDR_V4MAPPED(faddr6)) &&
- (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
+ (inp->inp_flags & IN6P_IPV6_V6ONLY))
continue;
- return in6p;
+ return inp;
}
if (vp && table->vestige) {
if ((*table->vestige->lookup6)(faddr6, fport_arg,
@@ -1230,34 +1085,32 @@ in6_pcblookup_connect(struct inpcbtable *table, const struct in6_addr *faddr6,
return NULL;
}
-struct in6pcb *
+struct inpcb *
in6_pcblookup_bind(struct inpcbtable *table, const struct in6_addr *laddr6,
u_int lport_arg, int faith)
{
struct inpcbhead *head;
- struct inpcb_hdr *inph;
- struct in6pcb *in6p;
+ struct inpcb *inp;
u_int16_t lport = lport_arg;
#ifdef INET
struct in6_addr zero_mapped;
#endif
head = IN6PCBHASH_BIND(table, laddr6, lport);
- LIST_FOREACH(inph, head, inph_hash) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ LIST_FOREACH(inp, head, inp_hash) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (faith && (in6p->in6p_flags & IN6P_FAITH) == 0)
+ if (faith && (inp->inp_flags & IN6P_FAITH) == 0)
continue;
- if (in6p->in6p_fport != 0)
+ if (inp->inp_fport != 0)
continue;
- if (in6p->in6p_lport != lport)
+ if (inp->inp_lport != lport)
continue;
if (IN6_IS_ADDR_V4MAPPED(laddr6) &&
- (in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ (inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
- if (IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, laddr6))
+ if (IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, laddr6))
goto out;
}
#ifdef INET
@@ -1265,76 +1118,73 @@ in6_pcblookup_bind(struct inpcbtable *table, const struct in6_addr *laddr6,
memset(&zero_mapped, 0, sizeof(zero_mapped));
zero_mapped.s6_addr16[5] = 0xffff;
head = IN6PCBHASH_BIND(table, &zero_mapped, lport);
- LIST_FOREACH(inph, head, inph_hash) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ LIST_FOREACH(inp, head, inp_hash) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (faith && (in6p->in6p_flags & IN6P_FAITH) == 0)
+ if (faith && (inp->inp_flags & IN6P_FAITH) == 0)
continue;
- if (in6p->in6p_fport != 0)
+ if (inp->inp_fport != 0)
continue;
- if (in6p->in6p_lport != lport)
+ if (inp->inp_lport != lport)
continue;
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
- if (IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &zero_mapped))
+ if (IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &zero_mapped))
goto out;
}
}
#endif
head = IN6PCBHASH_BIND(table, &zeroin6_addr, lport);
- LIST_FOREACH(inph, head, inph_hash) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ LIST_FOREACH(inp, head, inp_hash) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (faith && (in6p->in6p_flags & IN6P_FAITH) == 0)
+ if (faith && (inp->inp_flags & IN6P_FAITH) == 0)
continue;
- if (in6p->in6p_fport != 0)
+ if (inp->inp_fport != 0)
continue;
- if (in6p->in6p_lport != lport)
+ if (inp->inp_lport != lport)
continue;
if (IN6_IS_ADDR_V4MAPPED(laddr6) &&
- (in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
+ (inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)
continue;
- if (IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &zeroin6_addr))
+ if (IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &zeroin6_addr))
goto out;
}
return (NULL);
out:
- inph = &in6p->in6p_head;
- if (inph != LIST_FIRST(head)) {
- LIST_REMOVE(inph, inph_hash);
- LIST_INSERT_HEAD(head, inph, inph_hash);
+ if (inp != LIST_FIRST(head)) {
+ LIST_REMOVE(inp, inp_hash);
+ LIST_INSERT_HEAD(head, inp, inp_hash);
}
- return in6p;
+ return inp;
}
void
-in6_pcbstate(struct in6pcb *in6p, int state)
+in6_pcbstate(struct inpcb *inp, int state)
{
- if (in6p->in6p_af != AF_INET6)
+ if (inp->inp_af != AF_INET6)
return;
- if (in6p->in6p_state > IN6P_ATTACHED)
- LIST_REMOVE(&in6p->in6p_head, inph_hash);
+ if (inp->inp_state > INP_ATTACHED)
+ LIST_REMOVE(inp, inp_hash);
switch (state) {
- case IN6P_BOUND:
- LIST_INSERT_HEAD(IN6PCBHASH_BIND(in6p->in6p_table,
- &in6p->in6p_laddr, in6p->in6p_lport), &in6p->in6p_head,
- inph_hash);
+ case INP_BOUND:
+ LIST_INSERT_HEAD(IN6PCBHASH_BIND(inp->inp_table,
+ &inp->inp_laddr6, inp->inp_lport), inp,
+ inp_hash);
break;
- case IN6P_CONNECTED:
- LIST_INSERT_HEAD(IN6PCBHASH_CONNECT(in6p->in6p_table,
- &in6p->in6p_faddr, in6p->in6p_fport,
- &in6p->in6p_laddr, in6p->in6p_lport), &in6p->in6p_head,
- inph_hash);
+ case INP_CONNECTED:
+ LIST_INSERT_HEAD(IN6PCBHASH_CONNECT(inp->inp_table,
+ &inp->inp_faddr6, inp->inp_fport,
+ &inp->inp_laddr6, inp->inp_lport), inp,
+ inp_hash);
break;
}
- in6p->in6p_state = state;
+ inp->inp_state = state;
}
diff --git a/sys/netinet6/in6_pcb.h b/sys/netinet6/in6_pcb.h
index abc84a7570d..79f563608a9 100644
--- a/sys/netinet6/in6_pcb.h
+++ b/sys/netinet6/in6_pcb.h
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.h,v 1.53 2022/06/15 04:31:22 knakahara Exp $ */
+/* $NetBSD: in6_pcb.h,v 1.54 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
/*
@@ -64,143 +64,6 @@
#ifndef _NETINET6_IN6_PCB_H_
#define _NETINET6_IN6_PCB_H_
-#include <sys/queue.h>
-#include <netinet/in_pcb_hdr.h>
-#include <netinet/ip6.h>
-
-/*
- * Common structure pcb for internet protocol implementation.
- * Here are stored pointers to local and foreign host table
- * entries, local and foreign socket numbers, and pointers
- * up (to a socket structure) and down (to a protocol-specific)
- * control block.
- */
-struct icmp6_filter;
-
-struct in6pcb {
- struct inpcb_hdr in6p_head;
-#define in6p_queue in6p_head.inph_queue
-#define in6p_af in6p_head.inph_af
-#define in6p_ppcb in6p_head.inph_ppcb
-#define in6p_state in6p_head.inph_state
-#define in6p_portalgo in6p_head.inph_portalgo
-#define in6p_socket in6p_head.inph_socket
-#define in6p_table in6p_head.inph_table
-#define in6p_sp in6p_head.inph_sp
- struct route in6p_route; /* placeholder for routing entry */
- u_int16_t in6p_fport; /* foreign port */
- u_int16_t in6p_lport; /* local port */
- u_int32_t in6p_flowinfo; /* priority and flowlabel */
- int in6p_flags; /* generic IP6/datagram flags */
- int in6p_hops; /* default hop limit */
- struct ip6_hdr in6p_ip6; /* header prototype */
- struct mbuf *in6p_options; /* IP6 options */
- struct ip6_pktopts *in6p_outputopts; /* IP6 options for outgoing packets */
- struct ip6_moptions *in6p_moptions; /* IP6 multicast options */
- struct icmp6_filter *in6p_icmp6filt;
- int in6p_cksum; /* IPV6_CHECKSUM setsockopt */
- bool in6p_bindportonsend;
- struct ip_moptions *in6p_v4moptions;/* IP4 multicast options */
- pcb_overudp_cb_t in6p_overudp_cb;
- void *in6p_overudp_arg;
-};
-
-#define in6p_faddr in6p_ip6.ip6_dst
-#define in6p_laddr in6p_ip6.ip6_src
-
-#define in6p_lock(in6p) solock((in6p)->in6p_socket)
-#define in6p_unlock(in6p) sounlock((in6p)->in6p_socket)
-#define in6p_locked(in6p) solocked((in6p)->in6p_socket)
-
-/* states in inp_state: */
-#define IN6P_ATTACHED INP_ATTACHED
-#define IN6P_BOUND INP_BOUND
-#define IN6P_CONNECTED INP_CONNECTED
-
-/*
- * Flags in in6p_flags
- * We define KAME's original flags in higher 16 bits as much as possible
- * for compatibility with *bsd*s.
- */
-#define IN6P_RECVOPTS 0x00001000 /* receive incoming IP6 options */
-#define IN6P_RECVRETOPTS 0x00002000 /* receive IP6 options for reply */
-#define IN6P_RECVDSTADDR 0x00004000 /* receive IP6 dst address */
-#define IN6P_IPV6_V6ONLY 0x00008000 /* restrict AF_INET6 socket for v6 */
-#define IN6P_PKTINFO 0x00010000 /* receive IP6 dst and I/F */
-#define IN6P_HOPLIMIT 0x00020000 /* receive hoplimit */
-#define IN6P_HOPOPTS 0x00040000 /* receive hop-by-hop options */
-#define IN6P_DSTOPTS 0x00080000 /* receive dst options after rthdr */
-#define IN6P_RTHDR 0x00100000 /* receive routing header */
-#define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */
-#define IN6P_TCLASS 0x00400000 /* traffic class */
-#define IN6P_BINDANY 0x00800000 /* allow bind to any address */
-#define IN6P_HIGHPORT 0x01000000 /* user wants "high" port binding */
-#define IN6P_LOWPORT 0x02000000 /* user wants "low" port binding */
-#define IN6P_ANONPORT 0x04000000 /* port chosen for user */
-#define IN6P_FAITH 0x08000000 /* accept FAITH'ed connections */
-/* XXX should move to an UDP control block */
-#define IN6P_ESPINUDP INP_ESPINUDP /* ESP over UDP for NAT-T */
-
-#define IN6P_RFC2292 0x40000000 /* RFC2292 */
-#define IN6P_MTU 0x80000000 /* use minimum MTU */
-
-#define IN6P_CONTROLOPTS (IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
- IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
- IN6P_TCLASS|IN6P_RFC2292|\
- IN6P_MTU)
-
-#ifdef _KERNEL
-/* compute hash value for foreign and local in6_addr and port */
-#define IN6_HASH(faddr, fport, laddr, lport) \
- (((faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \
- (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3] ^ \
- (laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \
- (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3]) \
- + (fport) + (lport))
-
-#define sotoin6pcb(so) ((struct in6pcb *)(so)->so_pcb)
-
-void in6_losing(struct in6pcb *);
-void in6_pcbinit(struct inpcbtable *, int, int);
-int in6_pcballoc(struct socket *, void *);
-int in6_pcbbind(void *, struct sockaddr_in6 *, struct lwp *);
-int in6_pcbconnect(void *, struct sockaddr_in6 *, struct lwp *);
-void in6_pcbdetach(struct in6pcb *);
-void in6_pcbdisconnect(struct in6pcb *);
-struct in6pcb *in6_pcblookup_port(struct inpcbtable *, struct in6_addr *,
- u_int, int, struct vestigial_inpcb *);
-int in6_pcbnotify(struct inpcbtable *, const struct sockaddr *,
- u_int, const struct sockaddr *, u_int, int, void *,
- void (*)(struct in6pcb *, int));
-void in6_pcbpurgeif0(struct inpcbtable *, struct ifnet *);
-void in6_pcbpurgeif(struct inpcbtable *, struct ifnet *);
-void in6_pcbstate(struct in6pcb *, int);
-void in6_rtchange(struct in6pcb *, int);
-void in6_setpeeraddr(struct in6pcb *, struct sockaddr_in6 *);
-void in6_setsockaddr(struct in6pcb *, struct sockaddr_in6 *);
-
-/* in in6_src.c */
-int in6_selecthlim(struct in6pcb *, struct ifnet *);
-int in6_selecthlim_rt(struct in6pcb *);
-int in6_pcbsetport(struct sockaddr_in6 *, struct in6pcb *, struct lwp *);
-
-extern struct rtentry *
- in6_pcbrtentry(struct in6pcb *);
-extern void
- in6_pcbrtentry_unref(struct rtentry *, struct in6pcb *);
-extern struct in6pcb *in6_pcblookup_connect(struct inpcbtable *,
- const struct in6_addr *, u_int, const struct in6_addr *, u_int, int,
- struct vestigial_inpcb *);
-extern struct in6pcb *in6_pcblookup_bind(struct inpcbtable *,
- const struct in6_addr *, u_int, int);
-
-static inline void
-in6_pcb_register_overudp_cb(struct in6pcb *in6p, pcb_overudp_cb_t cb, void *arg)
-{
-
- in6p->in6p_overudp_cb = cb;
- in6p->in6p_overudp_arg = arg;
-}
-#endif /* _KERNEL */
+#include <netinet/in_pcb.h>
#endif /* !_NETINET6_IN6_PCB_H_ */
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 178eb31b676..a0805e4ed8b 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_src.c,v 1.88 2021/08/10 06:29:56 kardel Exp $ */
+/* $NetBSD: in6_src.c,v 1.89 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $ */
/*
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.88 2021/08/10 06:29:56 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.89 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -809,10 +809,10 @@ out:
* 3. The system default hoplimit.
*/
int
-in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp)
+in6_selecthlim(struct inpcb *inp, struct ifnet *ifp)
{
- if (in6p && in6p->in6p_hops >= 0)
- return (in6p->in6p_hops);
+ if (inp && inp->inp_hops6 >= 0)
+ return (inp->inp_hops6);
else if (ifp)
return (ND_IFINFO(ifp)->chlim);
else
@@ -820,35 +820,35 @@ in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp)
}
int
-in6_selecthlim_rt(struct in6pcb *in6p)
+in6_selecthlim_rt(struct inpcb *inp)
{
struct rtentry *rt;
- if (in6p == NULL)
- return in6_selecthlim(in6p, NULL);
+ if (inp == NULL)
+ return in6_selecthlim(inp, NULL);
- rt = rtcache_validate(&in6p->in6p_route);
+ rt = rtcache_validate(&inp->inp_route);
if (rt != NULL) {
- int ret = in6_selecthlim(in6p, rt->rt_ifp);
- rtcache_unref(rt, &in6p->in6p_route);
+ int ret = in6_selecthlim(inp, rt->rt_ifp);
+ rtcache_unref(rt, &inp->inp_route);
return ret;
} else
- return in6_selecthlim(in6p, NULL);
+ return in6_selecthlim(inp, NULL);
}
/*
* Find an empty port and set it to the specified PCB.
*/
int
-in6_pcbsetport(struct sockaddr_in6 *sin6, struct in6pcb *in6p, struct lwp *l)
+in6_pcbsetport(struct sockaddr_in6 *sin6, struct inpcb *inp, struct lwp *l)
{
- struct socket *so = in6p->in6p_socket;
- struct inpcbtable *table = in6p->in6p_table;
+ struct socket *so = inp->inp_socket;
+ struct inpcbtable *table = inp->inp_table;
u_int16_t lport, *lastport;
enum kauth_network_req req;
int error = 0;
- if (in6p->in6p_flags & IN6P_LOWPORT) {
+ if (inp->inp_flags & IN6P_LOWPORT) {
#ifndef IPNOPRIVPORTS
req = KAUTH_REQ_NETWORK_BIND_PRIVPORT;
#else
@@ -870,14 +870,14 @@ in6_pcbsetport(struct sockaddr_in6 *sin6, struct in6pcb *in6p, struct lwp *l)
/*
* Use RFC6056 randomized port selection
*/
- error = portalgo_randport(&lport, &in6p->in6p_head, l->l_cred);
+ error = portalgo_randport(&lport, inp, l->l_cred);
if (error)
return error;
- in6p->in6p_flags |= IN6P_ANONPORT;
+ inp->inp_flags |= IN6P_ANONPORT;
*lastport = lport;
- in6p->in6p_lport = htons(lport);
- in6_pcbstate(in6p, IN6P_BOUND);
+ inp->inp_lport = htons(lport);
+ in6_pcbstate(inp, INP_BOUND);
return (0); /* success */
}
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 64ffd8d6877..02601d9357e 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_input.c,v 1.226 2022/10/24 01:54:19 knakahara Exp $ */
+/* $NetBSD: ip6_input.c,v 1.227 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.226 2022/10/24 01:54:19 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.227 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -1063,12 +1063,12 @@ ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
}
void
-ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
+ip6_savecontrol(struct inpcb *inp, struct mbuf **mp,
struct ip6_hdr *ip6, struct mbuf *m)
{
- struct socket *so = in6p->in6p_socket;
+ struct socket *so = inp->inp_socket;
#ifdef RFC2292
-#define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y))
+#define IS2292(x, y) ((inp->inp_flags & IN6P_RFC2292) ? (x) : (y))
#else
#define IS2292(x, y) (y)
#endif
@@ -1083,7 +1083,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
return;
/* RFC 2292 sec. 5 */
- if ((in6p->in6p_flags & IN6P_PKTINFO) != 0) {
+ if ((inp->inp_flags & IN6P_PKTINFO) != 0) {
struct in6_pktinfo pi6;
memcpy(&pi6.ipi6_addr, &ip6->ip6_dst, sizeof(struct in6_addr));
@@ -1095,7 +1095,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
mp = &(*mp)->m_next;
}
- if (in6p->in6p_flags & IN6P_HOPLIMIT) {
+ if (inp->inp_flags & IN6P_HOPLIMIT) {
int hlim = ip6->ip6_hlim & 0xff;
*mp = sbcreatecontrol(&hlim, sizeof(hlim),
@@ -1104,7 +1104,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
mp = &(*mp)->m_next;
}
- if ((in6p->in6p_flags & IN6P_TCLASS) != 0) {
+ if ((inp->inp_flags & IN6P_TCLASS) != 0) {
u_int32_t flowinfo;
int tclass;
@@ -1126,7 +1126,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
* returned to normal user.
* See also RFC3542 section 8 (or RFC2292 section 6).
*/
- if ((in6p->in6p_flags & IN6P_HOPOPTS) != 0) {
+ if ((inp->inp_flags & IN6P_HOPOPTS) != 0) {
/*
* Check if a hop-by-hop options header is contatined in the
* received packet, and if so, store the options as ancillary
@@ -1170,7 +1170,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
}
/* IPV6_DSTOPTS and IPV6_RTHDR socket options */
- if (in6p->in6p_flags & (IN6P_DSTOPTS | IN6P_RTHDR)) {
+ if (inp->inp_flags & (IN6P_DSTOPTS | IN6P_RTHDR)) {
struct ip6_hdr *xip6 = mtod(m, struct ip6_hdr *);
int nxt = xip6->ip6_nxt, off = sizeof(struct ip6_hdr);
@@ -1219,7 +1219,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
switch (nxt) {
case IPPROTO_DSTOPTS:
- if (!(in6p->in6p_flags & IN6P_DSTOPTS))
+ if (!(inp->inp_flags & IN6P_DSTOPTS))
break;
*mp = sbcreatecontrol(ip6e, elen,
@@ -1230,7 +1230,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
break;
case IPPROTO_ROUTING:
- if (!(in6p->in6p_flags & IN6P_RTHDR))
+ if (!(inp->inp_flags & IN6P_RTHDR))
break;
*mp = sbcreatecontrol(ip6e, elen,
@@ -1271,14 +1271,14 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
void
-ip6_notify_pmtu(struct in6pcb *in6p, const struct sockaddr_in6 *dst,
+ip6_notify_pmtu(struct inpcb *inp, const struct sockaddr_in6 *dst,
uint32_t *mtu)
{
struct socket *so;
struct mbuf *m_mtu;
struct ip6_mtuinfo mtuctl;
- so = in6p->in6p_socket;
+ so = inp->inp_socket;
if (mtu == NULL)
return;
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 5d4a7b746a3..18634b407ce 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_output.c,v 1.229 2021/09/21 15:07:43 christos Exp $ */
+/* $NetBSD: ip6_output.c,v 1.230 2022/10/28 05:18:39 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.229 2021/09/21 15:07:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.230 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -121,8 +121,8 @@ static int ip6_pcbopt(int, u_char *, int, struct ip6_pktopts **,
static int ip6_getpcbopt(struct ip6_pktopts *, int, struct sockopt *);
static int ip6_setpktopt(int, u_char *, int, struct ip6_pktopts *, kauth_cred_t,
int, int, int);
-static int ip6_setmoptions(const struct sockopt *, struct in6pcb *);
-static int ip6_getmoptions(struct sockopt *, struct in6pcb *);
+static int ip6_setmoptions(const struct sockopt *, struct inpcb *);
+static int ip6_getmoptions(struct sockopt *, struct inpcb *);
static int ip6_copyexthdr(struct mbuf **, void *, int);
static int ip6_insertfraghdr(struct mbuf *, struct mbuf *, int,
struct ip6_frag **);
@@ -196,7 +196,7 @@ ip6_output(
struct route *ro,
int flags,
struct ip6_moptions *im6o,
- struct in6pcb *in6p,
+ struct inpcb *inp,
struct ifnet **ifpp /* XXX: just for statistics */
)
{
@@ -286,7 +286,7 @@ ip6_output(
#ifdef IPSEC
if (ipsec_used) {
/* Check the security policy (SP) for the packet */
- sp = ipsec6_check_policy(m, in6p, flags, &needipsec, &error);
+ sp = ipsec6_check_policy(m, inp, flags, &needipsec, &error);
if (error != 0) {
/*
* Hack: -EINVAL is used to signal that a packet
@@ -1297,7 +1297,7 @@ ip6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
{
int optdatalen, uproto;
void *optdata;
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
struct ip_moptions **mopts;
int error, optval;
int level, optname;
@@ -1319,7 +1319,7 @@ ip6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
case IP_MULTICAST_IF:
case IP_MULTICAST_LOOP:
case IP_MULTICAST_TTL:
- mopts = &in6p->in6p_v4moptions;
+ mopts = &inp->inp_moptions;
switch (op) {
case PRCO_GETOPT:
return ip_getmoptions(*mopts, sopt);
@@ -1341,7 +1341,7 @@ ip6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
switch (optname) {
#ifdef RFC2292
case IPV6_2292PKTOPTIONS:
- error = ip6_pcbopts(&in6p->in6p_outputopts, so, sopt);
+ error = ip6_pcbopts(&inp->inp_outputopts6, so, sopt);
break;
#endif
@@ -1388,29 +1388,29 @@ ip6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
error = EINVAL;
else {
/* -1 = kernel default */
- in6p->in6p_hops = optval;
+ inp->inp_hops6 = optval;
}
break;
#define OPTSET(bit) \
do { \
if (optval) \
- in6p->in6p_flags |= (bit); \
+ inp->inp_flags |= (bit); \
else \
- in6p->in6p_flags &= ~(bit); \
+ inp->inp_flags &= ~(bit); \
} while (/*CONSTCOND*/ 0)
#ifdef RFC2292
#define OPTSET2292(bit) \
do { \
-in6p->in6p_flags |= IN6P_RFC2292; \
+inp->inp_flags |= IN6P_RFC2292; \
if (optval) \
- in6p->in6p_flags |= (bit); \
+ inp->inp_flags |= (bit); \
else \
- in6p->in6p_flags &= ~(bit); \
+ inp->inp_flags &= ~(bit); \
} while (/*CONSTCOND*/ 0)
#endif
-#define OPTBIT(bit) (in6p->in6p_flags & (bit) ? 1 : 0)
+#define OPTBIT(bit) (inp->inp_flags & (bit) ? 1 : 0)
case IPV6_RECVPKTINFO:
#ifdef RFC2292
@@ -1434,7 +1434,7 @@ else \
break;
}
#endif
- optp = &in6p->in6p_outputopts;
+ optp = &inp->inp_outputopts6;
error = ip6_pcbopt(IPV6_HOPLIMIT,
(u_char *)&optval,
sizeof(optval),
@@ -1519,8 +1519,8 @@ else \
* available only prior to bind(2).
* see ipng mailing list, Jun 22 2001.
*/
- if (in6p->in6p_lport ||
- !IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
+ if (inp->inp_lport ||
+ !IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) {
error = EINVAL;
break;
}
@@ -1563,7 +1563,7 @@ else \
error = sockopt_get(sopt, &tclass, sizeof(tclass));
if (error)
break;
- optp = &in6p->in6p_outputopts;
+ optp = &inp->inp_outputopts6;
error = ip6_pcbopt(optname,
(u_char *)&tclass,
sizeof(tclass),
@@ -1581,7 +1581,7 @@ else \
break;
{
struct ip6_pktopts **optp;
- optp = &in6p->in6p_outputopts;
+ optp = &inp->inp_outputopts6;
error = ip6_pcbopt(optname,
(u_char *)&optval,
sizeof(optval),
@@ -1669,7 +1669,7 @@ else \
free(optbuf, M_IP6OPT);
break;
}
- optp = &in6p->in6p_outputopts;
+ optp = &inp->inp_outputopts6;
error = ip6_pcbopt(optname, optbuf, optbuflen,
optp, kauth_cred_get(), uproto);
@@ -1683,7 +1683,7 @@ else \
case IPV6_MULTICAST_LOOP:
case IPV6_JOIN_GROUP:
case IPV6_LEAVE_GROUP:
- error = ip6_setmoptions(sopt, in6p);
+ error = ip6_setmoptions(sopt, inp);
break;
case IPV6_PORTRANGE:
@@ -1693,18 +1693,18 @@ else \
switch (optval) {
case IPV6_PORTRANGE_DEFAULT:
- in6p->in6p_flags &= ~(IN6P_LOWPORT);
- in6p->in6p_flags &= ~(IN6P_HIGHPORT);
+ inp->inp_flags &= ~(IN6P_LOWPORT);
+ inp->inp_flags &= ~(IN6P_HIGHPORT);
break;
case IPV6_PORTRANGE_HIGH:
- in6p->in6p_flags &= ~(IN6P_LOWPORT);
- in6p->in6p_flags |= IN6P_HIGHPORT;
+ inp->inp_flags &= ~(IN6P_LOWPORT);
+ inp->inp_flags |= IN6P_HIGHPORT;
break;
case IPV6_PORTRANGE_LOW:
- in6p->in6p_flags &= ~(IN6P_HIGHPORT);
- in6p->in6p_flags |= IN6P_LOWPORT;
+ inp->inp_flags &= ~(IN6P_HIGHPORT);
+ inp->inp_flags |= IN6P_LOWPORT;
break;
default:
@@ -1718,14 +1718,13 @@ else \
if (error)
break;
- error = portalgo_algo_index_select(
- (struct inpcb_hdr *)in6p, optval);
+ error = portalgo_algo_index_select(inp, optval);
break;
#if defined(IPSEC)
case IPV6_IPSEC_POLICY:
if (ipsec_enabled) {
- error = ipsec_set_policy(in6p,
+ error = ipsec_set_policy(inp,
sopt->sopt_data, sopt->sopt_size,
kauth_cred_get());
} else
@@ -1784,7 +1783,7 @@ else \
break;
case IPV6_UNICAST_HOPS:
- optval = in6p->in6p_hops;
+ optval = inp->inp_hops6;
break;
case IPV6_RECVPKTINFO:
@@ -1814,7 +1813,7 @@ else \
case IPV6_PORTRANGE:
{
int flags;
- flags = in6p->in6p_flags;
+ flags = inp->inp_flags;
if (flags & IN6P_HIGHPORT)
optval = IPV6_PORTRANGE_HIGH;
else if (flags & IN6P_LOWPORT)
@@ -1841,7 +1840,7 @@ else \
{
u_long pmtu = 0;
struct ip6_mtuinfo mtuinfo;
- struct route *ro = &in6p->in6p_route;
+ struct route *ro = &inp->inp_route;
struct rtentry *rt;
union {
struct sockaddr dst;
@@ -1855,7 +1854,7 @@ else \
* routing, or optional information to specify
* the outgoing interface.
*/
- sockaddr_in6_init(&u.dst6, &in6p->in6p_faddr, 0, 0, 0);
+ sockaddr_in6_init(&u.dst6, &inp->inp_faddr6, 0, 0, 0);
rt = rtcache_lookup(ro, &u.dst);
error = ip6_getpmtu(rt, NULL, &pmtu, NULL);
rtcache_unref(rt, ro);
@@ -1911,7 +1910,7 @@ else \
case IPV6_DONTFRAG:
case IPV6_USE_MIN_MTU:
case IPV6_PREFER_TEMPADDR:
- error = ip6_getpcbopt(in6p->in6p_outputopts,
+ error = ip6_getpcbopt(inp->inp_outputopts6,
optname, sopt);
break;
@@ -1920,11 +1919,11 @@ else \
case IPV6_MULTICAST_LOOP:
case IPV6_JOIN_GROUP:
case IPV6_LEAVE_GROUP:
- error = ip6_getmoptions(sopt, in6p);
+ error = ip6_getmoptions(sopt, inp);
break;
case IPV6_PORTALGO:
- optval = ((struct inpcb_hdr *)in6p)->inph_portalgo;
+ optval = inp->inp_portalgo;
error = sockopt_setint(sopt, optval);
break;
@@ -1937,7 +1936,7 @@ else \
* XXX: this will return EINVAL as sopt is
* empty
*/
- error = ipsec_get_policy(in6p, sopt->sopt_data,
+ error = ipsec_get_policy(inp, sopt->sopt_data,
sopt->sopt_size, &m);
if (!error)
error = sockopt_setmbuf(sopt, m);
@@ -1960,7 +1959,7 @@ ip6_raw_ctloutput(int op, struct socket *so, struct sockopt *sopt)
{
int error = 0, optval;
const int icmp6off = offsetof(struct icmp6_hdr, icmp6_cksum);
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int level, optname;
KASSERT(sopt != NULL);
@@ -1995,14 +1994,14 @@ ip6_raw_ctloutput(int op, struct socket *so, struct sockopt *sopt)
if (optval != icmp6off)
error = EINVAL;
} else
- in6p->in6p_cksum = optval;
+ inp->inp_cksum6 = optval;
break;
case PRCO_GETOPT:
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
optval = icmp6off;
else
- optval = in6p->in6p_cksum;
+ optval = inp->inp_cksum6;
error = sockopt_setint(sopt, optval);
break;
@@ -2423,17 +2422,17 @@ ip6_get_membership(const struct sockopt *sopt, struct ifnet **ifp,
* Set the IP6 multicast options in response to user setsockopt().
*/
static int
-ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
+ip6_setmoptions(const struct sockopt *sopt, struct inpcb *inp)
{
int error = 0;
u_int loop, ifindex;
struct ipv6_mreq mreq;
struct in6_addr ia;
struct ifnet *ifp;
- struct ip6_moptions *im6o = in6p->in6p_moptions;
+ struct ip6_moptions *im6o = inp->inp_moptions6;
struct in6_multi_mship *imm;
- KASSERT(in6p_locked(in6p));
+ KASSERT(inp_locked(inp));
if (im6o == NULL) {
/*
@@ -2443,7 +2442,7 @@ ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
im6o = malloc(sizeof(*im6o), M_IPMOPTS, M_NOWAIT);
if (im6o == NULL)
return (ENOBUFS);
- in6p->in6p_moptions = im6o;
+ inp->inp_moptions6 = im6o;
im6o->im6o_multicast_if_index = 0;
im6o->im6o_multicast_hlim = ip6_defmcasthlim;
im6o->im6o_multicast_loop = IPV6_DEFAULT_MULTICAST_LOOP;
@@ -2532,7 +2531,7 @@ ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
}
if (IN6_IS_ADDR_V4MAPPED(&ia)) {
- error = ip_setmoptions(&in6p->in6p_v4moptions, sopt);
+ error = ip_setmoptions(&inp->inp_moptions, sopt);
goto put_break;
}
/*
@@ -2586,7 +2585,7 @@ ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
break;
if (IN6_IS_ADDR_V4MAPPED(&mreq.ipv6mr_multiaddr)) {
- error = ip_setmoptions(&in6p->in6p_v4moptions, sopt);
+ error = ip_setmoptions(&inp->inp_moptions, sopt);
break;
}
/*
@@ -2659,7 +2658,7 @@ ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
*/
LIST_REMOVE(imm, i6mm_chain);
in6_leavegroup(imm);
- /* in6m_ifp should not leave thanks to in6p_lock */
+ /* in6m_ifp should not leave thanks to inp_lock */
break;
}
@@ -2675,8 +2674,8 @@ ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
im6o->im6o_multicast_hlim == ip6_defmcasthlim &&
im6o->im6o_multicast_loop == IPV6_DEFAULT_MULTICAST_LOOP &&
LIST_EMPTY(&im6o->im6o_memberships)) {
- free(in6p->in6p_moptions, M_IPMOPTS);
- in6p->in6p_moptions = NULL;
+ free(inp->inp_moptions6, M_IPMOPTS);
+ inp->inp_moptions6 = NULL;
}
return (error);
@@ -2686,11 +2685,11 @@ ip6_setmoptions(const struct sockopt *sopt, struct in6pcb *in6p)
* Return the IP6 multicast options in response to user getsockopt().
*/
static int
-ip6_getmoptions(struct sockopt *sopt, struct in6pcb *in6p)
+ip6_getmoptions(struct sockopt *sopt, struct inpcb *inp)
{
u_int optval;
int error;
- struct ip6_moptions *im6o = in6p->in6p_moptions;
+ struct ip6_moptions *im6o = inp->inp_moptions6;
switch (sopt->sopt_name) {
case IPV6_MULTICAST_IF:
@@ -2738,7 +2737,7 @@ ip6_freemoptions(struct ip6_moptions *im6o)
if (im6o == NULL)
return;
- /* The owner of im6o (in6p) should be protected by solock */
+ /* The owner of im6o (inp) should be protected by solock */
LIST_FOREACH_SAFE(imm, &im6o->im6o_memberships, i6mm_chain, nimm) {
LIST_REMOVE(imm, i6mm_chain);
in6_leavegroup(imm);
@@ -3299,21 +3298,21 @@ ip6_splithdr(struct mbuf *m, struct ip6_exthdrs *exthdrs)
* Compute IPv6 extension header length.
*/
int
-ip6_optlen(struct in6pcb *in6p)
+ip6_optlen(struct inpcb *inp)
{
int len;
- if (!in6p->in6p_outputopts)
+ if (!inp->inp_outputopts6)
return 0;
len = 0;
#define elen(x) \
(((struct ip6_ext *)(x)) ? (((struct ip6_ext *)(x))->ip6e_len + 1) << 3 : 0)
- len += elen(in6p->in6p_outputopts->ip6po_hbh);
- len += elen(in6p->in6p_outputopts->ip6po_dest1);
- len += elen(in6p->in6p_outputopts->ip6po_rthdr);
- len += elen(in6p->in6p_outputopts->ip6po_dest2);
+ len += elen(inp->inp_outputopts6->ip6po_hbh);
+ len += elen(inp->inp_outputopts6->ip6po_dest1);
+ len += elen(inp->inp_outputopts6->ip6po_rthdr);
+ len += elen(inp->inp_outputopts6->ip6po_dest2);
return len;
#undef elen
}
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index 920055c4759..6c689cddb9b 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_var.h,v 1.92 2022/10/24 01:54:19 knakahara Exp $ */
+/* $NetBSD: ip6_var.h,v 1.93 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -288,7 +288,7 @@ extern int ip6_maxflows; /* maximum amount of flows for ip6ff */
extern int ip6_hashsize; /* size of hash table */
#endif
-struct in6pcb;
+struct inpcb;
extern const struct pr_usrreqs rip6_usrreqs;
int icmp6_ctloutput(int, struct socket *, struct sockopt *);
@@ -306,9 +306,9 @@ int ip6_lasthdr(struct mbuf *, int, int, int *);
struct ip6_hdr;
int ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *);
int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *);
-void ip6_savecontrol(struct in6pcb *, struct mbuf **, struct ip6_hdr *,
+void ip6_savecontrol(struct inpcb *, struct mbuf **, struct ip6_hdr *,
struct mbuf *);
-void ip6_notify_pmtu(struct in6pcb *, const struct sockaddr_in6 *,
+void ip6_notify_pmtu(struct inpcb *, const struct sockaddr_in6 *,
u_int32_t *);
int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
@@ -317,7 +317,7 @@ void ip6_forward(struct mbuf *, int, struct ifnet *);
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 in6pcb *, struct ifnet **);
+ struct ip6_moptions *, struct inpcb *, struct ifnet **);
int ip6_if_output(struct ifnet * const, struct ifnet * const,
struct mbuf * const,
const struct sockaddr_in6 * const, const struct rtentry *);
@@ -328,7 +328,7 @@ int ip6_setpktopts(struct mbuf *, struct ip6_pktopts *,
struct ip6_pktopts *, kauth_cred_t, int);
void ip6_clearpktopts(struct ip6_pktopts *, int);
struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int);
-int ip6_optlen(struct in6pcb *);
+int ip6_optlen(struct inpcb *);
void ip6_statinc(u_int);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 8e0694947de..b2dcbedd6b4 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_ip6.c,v 1.178 2022/05/28 10:36:23 andvar Exp $ */
+/* $NetBSD: raw_ip6.c,v 1.179 2022/10/28 05:18:39 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.178 2022/05/28 10:36:23 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.179 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -135,24 +135,24 @@ rip6_init(void)
}
static void
-rip6_sbappendaddr(struct in6pcb *last, struct ip6_hdr *ip6,
+rip6_sbappendaddr(struct inpcb *last, struct ip6_hdr *ip6,
const struct sockaddr *sa, int hlen, struct mbuf *n)
{
struct mbuf *opts = NULL;
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, &opts, ip6, n);
m_adj(n, hlen);
- if (sbappendaddr(&last->in6p_socket->so_rcv, sa, n, opts) == 0) {
- soroverflow(last->in6p_socket);
+ if (sbappendaddr(&last->inp_socket->so_rcv, sa, n, opts) == 0) {
+ soroverflow(last->inp_socket);
m_freem(n);
if (opts)
m_freem(opts);
RIP6_STATINC(RIP6_STAT_FULLSOCK);
} else {
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
}
}
@@ -166,9 +166,8 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
{
struct mbuf *m = *mp;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
- struct inpcb_hdr *inph;
- struct in6pcb *in6p;
- struct in6pcb *last = NULL;
+ struct inpcb *inp;
+ struct inpcb *last = NULL;
struct sockaddr_in6 rip6src;
struct mbuf *n;
@@ -189,20 +188,19 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
return IPPROTO_DONE;
}
- TAILQ_FOREACH(inph, &raw6cbtable.inpt_queue, inph_queue) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ TAILQ_FOREACH(inp, &raw6cbtable.inpt_queue, inp_queue) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (in6p->in6p_ip6.ip6_nxt &&
- in6p->in6p_ip6.ip6_nxt != proto)
+ if (inp->inp_ip6.ip6_nxt &&
+ inp->inp_ip6.ip6_nxt != proto)
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &ip6->ip6_dst))
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, &ip6->ip6_src))
continue;
- if (in6p->in6p_cksum != -1) {
+ if (inp->inp_cksum6 != -1) {
RIP6_STATINC(RIP6_STAT_ISUM);
if (in6_cksum(m, proto, *offp,
m->m_pkthdr.len - *offp)) {
@@ -224,7 +222,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
*offp, n);
}
- last = in6p;
+ last = inp;
}
#ifdef IPSEC
@@ -264,7 +262,7 @@ rip6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
struct ip6ctlparam *ip6cp = NULL;
const struct sockaddr_in6 *sa6_src = NULL;
void *cmdarg;
- void (*notify)(struct in6pcb *, int) = in6_rtchange;
+ void (*notify)(struct inpcb *, int) = in6_rtchange;
int nxt;
if (sa->sa_family != AF_INET6 ||
@@ -299,7 +297,7 @@ rip6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
if (ip6 && cmd == PRC_MSGSIZE) {
const struct sockaddr_in6 *sa6 = (const struct sockaddr_in6 *)sa;
int valid = 0;
- struct in6pcb *in6p;
+ struct inpcb *inp;
/*
* Check to see if we have a valid raw IPv6 socket
@@ -308,11 +306,11 @@ rip6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
* XXX chase extension headers, or pass final nxt value
* from icmp6_notify_error()
*/
- in6p = NULL;
- in6p = in6_pcblookup_connect(&raw6cbtable, &sa6->sin6_addr, 0,
+ inp = NULL;
+ inp = in6_pcblookup_connect(&raw6cbtable, &sa6->sin6_addr, 0,
(const struct in6_addr *)&sa6_src->sin6_addr, 0, 0, 0);
#if 0
- if (!in6p) {
+ if (!inp) {
/*
* As the use of sendto(2) is fairly popular,
* we may want to allow non-connected pcb too.
@@ -320,13 +318,13 @@ rip6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
* We should at least check if the local
* address (= s) is really ours.
*/
- in6p = in6_pcblookup_bind(&raw6cbtable,
+ inp = in6_pcblookup_bind(&raw6cbtable,
&sa6->sin6_addr, 0, 0);
}
#endif
- if (in6p && in6p->in6p_ip6.ip6_nxt &&
- in6p->in6p_ip6.ip6_nxt == nxt)
+ if (inp && inp->inp_ip6.ip6_nxt &&
+ inp->inp_ip6.ip6_nxt == nxt)
valid++;
/*
@@ -362,7 +360,7 @@ rip6_output(struct mbuf *m, struct socket * const so,
{
struct in6_addr *dst;
struct ip6_hdr *ip6;
- struct in6pcb *in6p;
+ struct inpcb *inp;
u_int plen = m->m_pkthdr.len;
int error = 0;
struct ip6_pktopts opt, *optp = NULL;
@@ -372,18 +370,18 @@ rip6_output(struct mbuf *m, struct socket * const so,
int bound = curlwp_bind();
struct psref psref;
- in6p = sotoin6pcb(so);
+ inp = sotoinpcb(so);
dst = &dstsock->sin6_addr;
if (control) {
if ((error = ip6_setpktopts(control, &opt,
- in6p->in6p_outputopts,
+ inp->inp_outputopts6,
kauth_cred_get(), so->so_proto->pr_protocol)) != 0) {
goto bad;
}
optp = &opt;
} else
- optp = in6p->in6p_outputopts;
+ optp = inp->inp_outputopts6;
/*
* Check and convert scope zone ID into internal form.
@@ -430,8 +428,8 @@ rip6_output(struct mbuf *m, struct socket * const so,
/*
* Source address selection.
*/
- error = in6_selectsrc(dstsock, optp, in6p->in6p_moptions,
- &in6p->in6p_route, &in6p->in6p_laddr, &oifp, &psref, &ip6->ip6_src);
+ error = in6_selectsrc(dstsock, optp, inp->inp_moptions6,
+ &inp->inp_route, &inp->inp_laddr6, &oifp, &psref, &ip6->ip6_src);
if (error != 0)
goto bad;
@@ -451,18 +449,18 @@ rip6_output(struct mbuf *m, struct socket * const so,
ip6->ip6_dst = dstsock->sin6_addr;
/* fill in the rest of the IPv6 header fields */
- ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK;
+ ip6->ip6_flow = inp->inp_flowinfo & IPV6_FLOWINFO_MASK;
ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
ip6->ip6_vfc |= IPV6_VERSION;
/* ip6_plen will be filled in ip6_output, so not fill it here. */
- ip6->ip6_nxt = in6p->in6p_ip6.ip6_nxt;
- ip6->ip6_hlim = in6_selecthlim(in6p, oifp);
+ ip6->ip6_nxt = inp->inp_ip6.ip6_nxt;
+ ip6->ip6_hlim = in6_selecthlim(inp, oifp);
if_put(oifp, &psref);
oifp = NULL;
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
- in6p->in6p_cksum != -1) {
+ inp->inp_cksum6 != -1) {
const uint8_t nxt = ip6->ip6_nxt;
int off;
u_int16_t sum;
@@ -471,7 +469,7 @@ rip6_output(struct mbuf *m, struct socket * const so,
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
off = offsetof(struct icmp6_hdr, icmp6_cksum);
else
- off = in6p->in6p_cksum;
+ off = inp->inp_cksum6;
if (plen < off + 1) {
error = EINVAL;
goto bad;
@@ -497,8 +495,8 @@ rip6_output(struct mbuf *m, struct socket * const so,
{
struct ifnet *ret_oifp = NULL;
- error = ip6_output(m, optp, &in6p->in6p_route, 0,
- in6p->in6p_moptions, in6p, &ret_oifp);
+ error = ip6_output(m, optp, &inp->inp_route, 0,
+ inp->inp_moptions6, inp, &ret_oifp);
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
if (ret_oifp)
icmp6_ifoutstat_inc(ret_oifp, type, code);
@@ -580,10 +578,10 @@ extern u_long rip6_recvspace;
int
rip6_attach(struct socket *so, int proto)
{
- struct in6pcb *in6p;
+ struct inpcb *inp;
int s, error;
- KASSERT(sotoin6pcb(so) == NULL);
+ KASSERT(sotoinpcb(so) == NULL);
sosetlock(so);
error = kauth_authorize_network(kauth_cred_get(),
@@ -600,17 +598,17 @@ rip6_attach(struct socket *so, int proto)
splx(s);
return error;
}
- if ((error = in6_pcballoc(so, &raw6cbtable)) != 0) {
+ if ((error = in_pcballoc(so, &raw6cbtable)) != 0) {
splx(s);
return error;
}
splx(s);
- in6p = sotoin6pcb(so);
- in6p->in6p_ip6.ip6_nxt = proto;
- in6p->in6p_cksum = -1;
+ inp = sotoinpcb(so);
+ inp->inp_ip6.ip6_nxt = proto;
+ inp->inp_cksum6 = -1;
- in6p->in6p_icmp6filt = kmem_alloc(sizeof(struct icmp6_filter), KM_SLEEP);
- ICMP6_FILTER_SETPASSALL(in6p->in6p_icmp6filt);
+ inp->inp_icmp6filt = kmem_alloc(sizeof(struct icmp6_filter), KM_SLEEP);
+ ICMP6_FILTER_SETPASSALL(inp->inp_icmp6filt);
KASSERT(solocked(so));
return error;
}
@@ -618,20 +616,20 @@ rip6_attach(struct socket *so, int proto)
static void
rip6_detach(struct socket *so)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
if (so == ip6_mrouter) {
ip6_mrouter_done();
}
/* xxx: RSVP */
- if (in6p->in6p_icmp6filt != NULL) {
- kmem_free(in6p->in6p_icmp6filt, sizeof(struct icmp6_filter));
- in6p->in6p_icmp6filt = NULL;
+ if (inp->inp_icmp6filt != NULL) {
+ kmem_free(inp->inp_icmp6filt, sizeof(struct icmp6_filter));
+ inp->inp_icmp6filt = NULL;
}
- in6_pcbdetach(in6p);
+ in_pcbdetach(inp);
}
static int
@@ -645,14 +643,14 @@ rip6_accept(struct socket *so, struct sockaddr *nam)
static int
rip6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam;
struct ifaddr *ifa = NULL;
int error = 0;
int s;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
KASSERT(nam != NULL);
if (addr->sin6_len != sizeof(*addr))
@@ -681,7 +679,7 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
goto out;
}
- in6p->in6p_laddr = addr->sin6_addr;
+ inp->inp_laddr6 = addr->sin6_addr;
error = 0;
out:
pserialize_read_exit(s);
@@ -699,7 +697,7 @@ rip6_listen(struct socket *so, struct lwp *l)
static int
rip6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam;
struct in6_addr in6a;
struct ifnet *ifp = NULL;
@@ -709,7 +707,7 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
int bound;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
KASSERT(nam != NULL);
if (IFNET_READER_EMPTY())
@@ -734,9 +732,9 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
bound = curlwp_bind();
/* Source address selection. XXX: need pcblookup? */
- error = in6_selectsrc(addr, in6p->in6p_outputopts,
- in6p->in6p_moptions, &in6p->in6p_route,
- &in6p->in6p_laddr, &ifp, &psref, &in6a);
+ error = in6_selectsrc(addr, inp->inp_outputopts6,
+ inp->inp_moptions6, &inp->inp_route,
+ &inp->inp_laddr6, &ifp, &psref, &in6a);
if (error != 0)
goto out;
/* XXX: see above */
@@ -744,8 +742,8 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
(error = in6_setscope(&addr->sin6_addr, ifp, NULL)) != 0) {
goto out;
}
- in6p->in6p_laddr = in6a;
- in6p->in6p_faddr = addr->sin6_addr;
+ inp->inp_laddr6 = in6a;
+ inp->inp_faddr6 = addr->sin6_addr;
soisconnected(so);
out:
if_put(ifp, &psref);
@@ -764,15 +762,15 @@ rip6_connect2(struct socket *so, struct socket *so2)
static int
rip6_disconnect(struct socket *so)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
if ((so->so_state & SS_ISCONNECTED) == 0)
return ENOTCONN;
- in6p->in6p_faddr = in6addr_any;
+ inp->inp_faddr6 = in6addr_any;
so->so_state &= ~SS_ISCONNECTED; /* XXX */
return 0;
}
@@ -818,10 +816,10 @@ static int
rip6_peeraddr(struct socket *so, struct sockaddr *nam)
{
KASSERT(solocked(so));
- KASSERT(sotoin6pcb(so) != NULL);
+ KASSERT(sotoinpcb(so) != NULL);
KASSERT(nam != NULL);
- in6_setpeeraddr(sotoin6pcb(so), (struct sockaddr_in6 *)nam);
+ in6_setpeeraddr(sotoinpcb(so), (struct sockaddr_in6 *)nam);
return 0;
}
@@ -829,10 +827,10 @@ static int
rip6_sockaddr(struct socket *so, struct sockaddr *nam)
{
KASSERT(solocked(so));
- KASSERT(sotoin6pcb(so) != NULL);
+ KASSERT(sotoinpcb(so) != NULL);
KASSERT(nam != NULL);
- in6_setsockaddr(sotoin6pcb(so), (struct sockaddr_in6 *)nam);
+ in6_setsockaddr(sotoinpcb(so), (struct sockaddr_in6 *)nam);
return 0;
}
@@ -856,13 +854,13 @@ static int
rip6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
struct mbuf *control, struct lwp *l)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
struct sockaddr_in6 tmp;
struct sockaddr_in6 *dst;
int error = 0;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
KASSERT(m != NULL);
/*
@@ -877,7 +875,7 @@ rip6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
goto release;
}
/* XXX */
- sockaddr_in6_init(&tmp, &in6p->in6p_faddr, 0, 0, 0);
+ sockaddr_in6_init(&tmp, &inp->inp_faddr6, 0, 0, 0);
dst = &tmp;
} else {
if (nam == NULL) {
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
index 6bfa111ee6d..40c42b07124 100644
--- a/sys/netinet6/udp6_usrreq.c
+++ b/sys/netinet6/udp6_usrreq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: udp6_usrreq.c,v 1.150 2021/02/19 14:52:00 christos Exp $ */
+/* $NetBSD: udp6_usrreq.c,v 1.151 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */
/* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.150 2021/02/19 14:52:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.151 2022/10/28 05:18:39 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -134,7 +134,7 @@ static int udp6_sendspace = 9216; /* really max datagram size */
static int udp6_recvspace = 40 * (1024 + sizeof(struct sockaddr_in6));
/* 40 1K datagrams */
-static void udp6_notify(struct in6pcb *, int);
+static void udp6_notify(struct inpcb *, int);
static void sysctl_net_inet6_udp6_setup(struct sysctllog **);
#ifdef IPSEC
static int udp6_espinudp(struct mbuf **, int);
@@ -175,11 +175,11 @@ udp6_init(void)
* just wake up so that he can collect error status.
*/
static void
-udp6_notify(struct in6pcb *in6p, int errno)
+udp6_notify(struct inpcb *inp, int errno)
{
- in6p->in6p_socket->so_error = errno;
- sorwakeup(in6p->in6p_socket);
- sowwakeup(in6p->in6p_socket);
+ inp->inp_socket->so_error = errno;
+ sorwakeup(inp->inp_socket);
+ sowwakeup(inp->inp_socket);
}
void *
@@ -193,7 +193,7 @@ udp6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
void *cmdarg;
struct ip6ctlparam *ip6cp = NULL;
const struct sockaddr_in6 *sa6_src = NULL;
- void (*notify)(struct in6pcb *, int) = udp6_notify;
+ void (*notify)(struct inpcb *, int) = udp6_notify;
struct udp_portonly {
u_int16_t uh_sport;
u_int16_t uh_dport;
@@ -302,7 +302,7 @@ udp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
{
int s;
int error = 0;
- struct in6pcb *in6p;
+ struct inpcb *inp;
int family;
int optval;
@@ -333,7 +333,7 @@ udp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
switch (op) {
case PRCO_SETOPT:
- in6p = sotoin6pcb(so);
+ inp = sotoinpcb(so);
switch (sopt->sopt_name) {
case UDP_ENCAP:
@@ -343,11 +343,11 @@ udp6_ctloutput(int op, struct socket *so, struct sockopt *sopt)
switch(optval) {
case 0:
- in6p->in6p_flags &= ~IN6P_ESPINUDP;
+ inp->inp_flags &= ~IN6P_ESPINUDP;
break;
case UDP_ENCAP_ESPINUDP:
- in6p->in6p_flags |= IN6P_ESPINUDP;
+ inp->inp_flags |= IN6P_ESPINUDP;
break;
default:
@@ -378,15 +378,15 @@ udp6_sendup(struct mbuf *m, int off /* offset of data portion */,
{
struct mbuf *opts = NULL;
struct mbuf *n;
- struct in6pcb *in6p;
+ struct inpcb *inp;
KASSERT(so != NULL);
KASSERT(so->so_proto->pr_domain->dom_family == AF_INET6);
- in6p = sotoin6pcb(so);
- KASSERT(in6p != NULL);
+ inp = sotoinpcb(so);
+ KASSERT(inp != NULL);
#if defined(IPSEC)
- if (ipsec_used && ipsec_in_reject(m, in6p)) {
+ if (ipsec_used && ipsec_in_reject(m, inp)) {
if ((n = m_copypacket(m, M_DONTWAIT)) != NULL)
icmp6_error(n, ICMP6_DST_UNREACH,
ICMP6_DST_UNREACH_ADMIN, 0);
@@ -395,10 +395,10 @@ udp6_sendup(struct mbuf *m, int off /* offset of data portion */,
#endif
if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
- if (in6p->in6p_flags & IN6P_CONTROLOPTS ||
- SOOPT_TIMESTAMP(in6p->in6p_socket->so_options)) {
+ if (inp->inp_flags & IN6P_CONTROLOPTS ||
+ SOOPT_TIMESTAMP(inp->inp_socket->so_options)) {
struct ip6_hdr *ip6 = mtod(n, struct ip6_hdr *);
- ip6_savecontrol(in6p, &opts, ip6, n);
+ ip6_savecontrol(inp, &opts, ip6, n);
}
m_adj(n, off);
@@ -421,8 +421,7 @@ udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
int rcvcnt;
struct in6_addr src6, *dst6;
const struct in_addr *dst4;
- struct inpcb_hdr *inph;
- struct in6pcb *in6p;
+ struct inpcb *inp;
struct mbuf *m = *mp;
rcvcnt = 0;
@@ -469,33 +468,32 @@ udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
/*
* Locate pcb(s) for datagram.
*/
- TAILQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
- in6p = (struct in6pcb *)inph;
- if (in6p->in6p_af != AF_INET6)
+ TAILQ_FOREACH(inp, &udbtable.inpt_queue, inp_queue) {
+ if (inp->inp_af != AF_INET6)
continue;
- if (in6p->in6p_lport != dport)
+ if (inp->inp_lport != dport)
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) {
+ if (!IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6,
dst6))
continue;
} else {
if (IN6_IS_ADDR_V4MAPPED(dst6) &&
- (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
+ (inp->inp_flags & IN6P_IPV6_V6ONLY))
continue;
}
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr,
- &src6) || in6p->in6p_fport != sport)
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
+ if (!IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6,
+ &src6) || inp->inp_fport != sport)
continue;
} else {
if (IN6_IS_ADDR_V4MAPPED(&src6) &&
- (in6p->in6p_flags & IN6P_IPV6_V6ONLY))
+ (inp->inp_flags & IN6P_IPV6_V6ONLY))
continue;
}
- udp6_sendup(m, off, sin6tosa(src), in6p->in6p_socket);
+ udp6_sendup(m, off, sin6tosa(src), inp->inp_socket);
rcvcnt++;
/*
@@ -506,7 +504,7 @@ udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
* port. It assumes that an application will never
* clear these options after setting them.
*/
- if ((in6p->in6p_socket->so_options &
+ if ((inp->inp_socket->so_options &
(SO_REUSEPORT|SO_REUSEADDR)) == 0)
break;
}
@@ -514,18 +512,18 @@ udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
/*
* Locate pcb for datagram.
*/
- in6p = in6_pcblookup_connect(&udbtable, &src6, sport, dst6,
+ inp = in6_pcblookup_connect(&udbtable, &src6, sport, dst6,
dport, 0, 0);
- if (in6p == 0) {
+ if (inp == NULL) {
UDP_STATINC(UDP_STAT_PCBHASHMISS);
- in6p = in6_pcblookup_bind(&udbtable, dst6, dport, 0);
- if (in6p == 0)
+ inp = in6_pcblookup_bind(&udbtable, dst6, dport, 0);
+ if (inp == NULL)
return rcvcnt;
}
#ifdef IPSEC
/* Handle ESP over UDP */
- if (in6p->in6p_flags & IN6P_ESPINUDP) {
+ if (inp->inp_flags & IN6P_ESPINUDP) {
switch (udp6_espinudp(mp, off)) {
case -1: /* Error, m was freed */
rcvcnt = -1;
@@ -547,10 +545,10 @@ udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
}
#endif
- if (in6p->in6p_overudp_cb != NULL) {
+ if (inp->inp_overudp_cb != NULL) {
int ret;
- ret = in6p->in6p_overudp_cb(mp, off, in6p->in6p_socket,
- sin6tosa(src), in6p->in6p_overudp_arg);
+ ret = inp->inp_overudp_cb(mp, off, inp->inp_socket,
+ sin6tosa(src), inp->inp_overudp_arg);
switch (ret) {
case -1: /* Error, m was freed */
rcvcnt = -1;
@@ -571,7 +569,7 @@ udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
}
}
- udp6_sendup(m, off, sin6tosa(src), in6p->in6p_socket);
+ udp6_sendup(m, off, sin6tosa(src), inp->inp_socket);
rcvcnt++;
}
@@ -731,7 +729,7 @@ bad:
}
int
-udp6_output(struct in6pcb * const in6p, struct mbuf *m,
+udp6_output(struct inpcb * const inp, struct mbuf *m,
struct sockaddr_in6 * const addr6, struct mbuf * const control,
struct lwp * const l)
{
@@ -790,11 +788,11 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
panic("%s: control but no lwp", __func__);
}
if ((error = ip6_setpktopts(control, &opt,
- in6p->in6p_outputopts, l->l_cred, IPPROTO_UDP)) != 0)
+ inp->inp_outputopts6, l->l_cred, IPPROTO_UDP)) != 0)
goto release;
optp = &opt;
} else
- optp = in6p->in6p_outputopts;
+ optp = inp->inp_outputopts6;
if (sin6) {
@@ -802,7 +800,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
* Slightly different than v4 version in that we call
* in6_selectsrc and in6_pcbsetport to fill in the local
* address and port rather than in_pcbconnect. in_pcbconnect
- * sets in6p_faddr which causes EISCONN below to be hit on
+ * sets inp_faddr which causes EISCONN below to be hit on
* subsequent sendto.
*/
if (sin6->sin6_port == 0) {
@@ -810,7 +808,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
goto release;
}
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
/* how about ::ffff:0.0.0.0 case? */
error = EISCONN;
goto release;
@@ -820,7 +818,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
fport = sin6->sin6_port; /* allow 0 port */
if (IN6_IS_ADDR_V4MAPPED(faddr)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY)) {
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY)) {
/*
* I believe we should explicitly discard the
* packet when mapped addresses are disabled,
@@ -834,8 +832,8 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
error = EINVAL;
goto release;
}
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
- !IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr)) {
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) &&
+ !IN6_IS_ADDR_V4MAPPED(&inp->inp_laddr6)) {
/*
* when remote addr is an IPv4-mapped address,
* local addr should not be an IPv6 address,
@@ -854,9 +852,9 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
int bound = curlwp_bind();
error = in6_selectsrc(sin6, optp,
- in6p->in6p_moptions,
- &in6p->in6p_route,
- &in6p->in6p_laddr, &oifp, &psref, &_laddr);
+ inp->inp_moptions6,
+ &inp->inp_route,
+ &inp->inp_laddr6, &oifp, &psref, &_laddr);
if (error)
laddr = NULL;
else
@@ -877,7 +875,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
* udp_output() directly in this case, and thus we'll
* never see this path.
*/
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) {
struct sockaddr_in sin_dst;
struct in_addr ina;
struct in_ifaddr *ia4;
@@ -887,8 +885,8 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
memcpy(&ina, &faddr->s6_addr[12], sizeof(ina));
sockaddr_in_init(&sin_dst, &ina, 0);
bound = curlwp_bind();
- ia4 = in_selectsrc(&sin_dst, &in6p->in6p_route,
- in6p->in6p_socket->so_options, NULL,
+ ia4 = in_selectsrc(&sin_dst, &inp->inp_route,
+ inp->inp_socket->so_options, NULL,
&error, &_psref);
if (ia4 == NULL) {
curlwp_bindx(bound);
@@ -906,7 +904,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
laddr = &laddr_mapped;
} else
{
- laddr = &in6p->in6p_laddr; /* XXX */
+ laddr = &inp->inp_laddr6; /* XXX */
}
}
if (laddr == NULL) {
@@ -914,33 +912,33 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
error = EADDRNOTAVAIL;
goto release;
}
- if (in6p->in6p_lport == 0) {
+ if (inp->inp_lport == 0) {
/*
* Craft a sockaddr_in6 for the local endpoint. Use the
* "any" as a base, set the address, and recover the
* scope.
*/
struct sockaddr_in6 lsin6 =
- *((const struct sockaddr_in6 *)in6p->in6p_socket->so_proto->pr_domain->dom_sa_any);
+ *((const struct sockaddr_in6 *)inp->inp_socket->so_proto->pr_domain->dom_sa_any);
lsin6.sin6_addr = *laddr;
error = sa6_recoverscope(&lsin6);
if (error)
goto release;
- error = in6_pcbsetport(&lsin6, in6p, l);
+ error = in6_pcbsetport(&lsin6, inp, l);
if (error) {
- in6p->in6p_laddr = in6addr_any;
+ inp->inp_laddr6 = in6addr_any;
goto release;
}
}
} else {
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
error = ENOTCONN;
goto release;
}
- if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
- if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY))
+ if (IN6_IS_ADDR_V4MAPPED(&inp->inp_faddr6)) {
+ if ((inp->inp_flags & IN6P_IPV6_V6ONLY))
{
/*
* XXX: this case would happen when the
@@ -956,9 +954,9 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
} else
af = AF_INET;
}
- laddr = &in6p->in6p_laddr;
- faddr = &in6p->in6p_faddr;
- fport = in6p->in6p_fport;
+ laddr = &inp->inp_laddr6;
+ faddr = &inp->inp_faddr6;
+ fport = inp->inp_fport;
}
if (af == AF_INET)
@@ -978,7 +976,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
* Stuff checksum and output datagram.
*/
udp6 = (struct udphdr *)(mtod(m, char *) + hlen);
- udp6->uh_sport = in6p->in6p_lport; /* lport is always set in the PCB */
+ udp6->uh_sport = inp->inp_lport; /* lport is always set in the PCB */
udp6->uh_dport = fport;
if (plen <= 0xffff)
udp6->uh_ulen = htons((u_int16_t)plen);
@@ -989,14 +987,14 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
switch (af) {
case AF_INET6:
ip6 = mtod(m, struct ip6_hdr *);
- ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK;
+ ip6->ip6_flow = inp->inp_flowinfo & IPV6_FLOWINFO_MASK;
ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
ip6->ip6_vfc |= IPV6_VERSION;
#if 0 /* ip6_plen will be filled in ip6_output. */
ip6->ip6_plen = htons((u_int16_t)plen);
#endif
ip6->ip6_nxt = IPPROTO_UDP;
- ip6->ip6_hlim = in6_selecthlim_rt(in6p);
+ ip6->ip6_hlim = in6_selecthlim_rt(inp);
ip6->ip6_src = *laddr;
ip6->ip6_dst = *faddr;
@@ -1006,8 +1004,8 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
UDP6_STATINC(UDP6_STAT_OPACKETS);
- error = ip6_output(m, optp, &in6p->in6p_route, 0,
- in6p->in6p_moptions, in6p, NULL);
+ error = ip6_output(m, optp, &inp->inp_route, 0,
+ inp->inp_moptions6, inp, NULL);
break;
case AF_INET:
#ifdef INET
@@ -1025,7 +1023,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
memcpy(&ui->ui_src, &laddr->s6_addr[12], sizeof(ui->ui_src));
ui->ui_ulen = ui->ui_len;
- flags = (in6p->in6p_socket->so_options &
+ flags = (inp->inp_socket->so_options &
(SO_DONTROUTE | SO_BROADCAST));
memcpy(&ui->ui_dst, &faddr->s6_addr[12], sizeof(ui->ui_dst));
@@ -1034,12 +1032,12 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
udp6->uh_sum = 0xffff;
ip->ip_len = htons(hlen + plen);
- ip->ip_ttl = in6_selecthlim(in6p, NULL); /* XXX */
+ ip->ip_ttl = in6_selecthlim(inp, NULL); /* XXX */
ip->ip_tos = 0; /* XXX */
UDP_STATINC(UDP_STAT_OPACKETS);
- error = ip_output(m, NULL, &in6p->in6p_route, flags /* XXX */,
- in6p->in6p_v4moptions, NULL);
+ error = ip_output(m, NULL, &inp->inp_route, flags /* XXX */,
+ inp->inp_moptions, NULL);
break;
#else
error = EAFNOSUPPORT;
@@ -1063,10 +1061,10 @@ releaseopt:
static int
udp6_attach(struct socket *so, int proto)
{
- struct in6pcb *in6p;
+ struct inpcb *inp;
int s, error;
- KASSERT(sotoin6pcb(so) == NULL);
+ KASSERT(sotoinpcb(so) == NULL);
sosetlock(so);
error = soreserve(so, udp6_sendspace, udp6_recvspace);
@@ -1079,14 +1077,14 @@ udp6_attach(struct socket *so, int proto)
* Always attach for IPv6, and only when necessary for IPv4.
*/
s = splsoftnet();
- error = in6_pcballoc(so, &udbtable);
+ error = in_pcballoc(so, &udbtable);
splx(s);
if (error) {
return error;
}
- in6p = sotoin6pcb(so);
- in6p->in6p_cksum = -1; /* just to be sure */
+ inp = sotoinpcb(so);
+ inp->inp_cksum6 = -1; /* just to be sure */
KASSERT(solocked(so));
return 0;
@@ -1095,14 +1093,14 @@ udp6_attach(struct socket *so, int proto)
static void
udp6_detach(struct socket *so)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int s;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
s = splsoftnet();
- in6_pcbdetach(in6p);
+ in_pcbdetach(inp);
splx(s);
}
@@ -1117,16 +1115,16 @@ udp6_accept(struct socket *so, struct sockaddr *nam)
static int
udp6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
int error = 0;
int s;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
s = splsoftnet();
- error = in6_pcbbind(in6p, sin6, l);
+ error = in6_pcbbind(inp, sin6, l);
splx(s);
return error;
}
@@ -1142,17 +1140,17 @@ udp6_listen(struct socket *so, struct lwp *l)
static int
udp6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int error = 0;
int s;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
return EISCONN;
s = splsoftnet();
- error = in6_pcbconnect(in6p, (struct sockaddr_in6 *)nam, l);
+ error = in6_pcbconnect(inp, (struct sockaddr_in6 *)nam, l);
splx(s);
if (error == 0)
soisconnected(so);
@@ -1171,22 +1169,22 @@ udp6_connect2(struct socket *so, struct socket *so2)
static int
udp6_disconnect(struct socket *so)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int s;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
return ENOTCONN;
s = splsoftnet();
- in6_pcbdisconnect(in6p);
- memset((void *)&in6p->in6p_laddr, 0, sizeof(in6p->in6p_laddr));
+ in6_pcbdisconnect(inp);
+ memset((void *)&inp->inp_laddr6, 0, sizeof(inp->inp_laddr6));
splx(s);
so->so_state &= ~SS_ISCONNECTED; /* XXX */
- in6_pcbstate(in6p, IN6P_BOUND); /* XXX */
+ in6_pcbstate(inp, INP_BOUND); /* XXX */
return 0;
}
@@ -1208,11 +1206,11 @@ udp6_abort(struct socket *so)
int s;
KASSERT(solocked(so));
- KASSERT(sotoin6pcb(so) != NULL);
+ KASSERT(sotoinpcb(so) != NULL);
s = splsoftnet();
soisdisconnected(so);
- in6_pcbdetach(sotoin6pcb(so));
+ in_pcbdetach(sotoinpcb(so));
splx(s);
return 0;
@@ -1247,10 +1245,10 @@ static int
udp6_peeraddr(struct socket *so, struct sockaddr *nam)
{
KASSERT(solocked(so));
- KASSERT(sotoin6pcb(so) != NULL);
+ KASSERT(sotoinpcb(so) != NULL);
KASSERT(nam != NULL);
- in6_setpeeraddr(sotoin6pcb(so), (struct sockaddr_in6 *)nam);
+ in6_setpeeraddr(sotoinpcb(so), (struct sockaddr_in6 *)nam);
return 0;
}
@@ -1258,10 +1256,10 @@ static int
udp6_sockaddr(struct socket *so, struct sockaddr *nam)
{
KASSERT(solocked(so));
- KASSERT(sotoin6pcb(so) != NULL);
+ KASSERT(sotoinpcb(so) != NULL);
KASSERT(nam != NULL);
- in6_setsockaddr(sotoin6pcb(so), (struct sockaddr_in6 *)nam);
+ in6_setsockaddr(sotoinpcb(so), (struct sockaddr_in6 *)nam);
return 0;
}
@@ -1285,16 +1283,16 @@ static int
udp6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
struct mbuf *control, struct lwp *l)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int error = 0;
int s;
KASSERT(solocked(so));
- KASSERT(in6p != NULL);
+ KASSERT(inp != NULL);
KASSERT(m != NULL);
s = splsoftnet();
- error = udp6_output(in6p, m, (struct sockaddr_in6 *)nam, control, l);
+ error = udp6_output(inp, m, (struct sockaddr_in6 *)nam, control, l);
splx(s);
return error;
diff --git a/sys/netinet6/udp6_var.h b/sys/netinet6/udp6_var.h
index c0e7864f7ae..34419adc9e5 100644
--- a/sys/netinet6/udp6_var.h
+++ b/sys/netinet6/udp6_var.h
@@ -1,4 +1,4 @@
-/* $NetBSD: udp6_var.h,v 1.30 2018/11/22 04:48:34 knakahara Exp $ */
+/* $NetBSD: udp6_var.h,v 1.31 2022/10/28 05:18:39 ozaki-r Exp $ */
/* $KAME: udp6_var.h,v 1.11 2000/06/05 00:14:31 itojun Exp $ */
/*
@@ -97,7 +97,7 @@ void *udp6_ctlinput(int, const struct sockaddr *, void *);
int udp6_ctloutput(int, struct socket *, struct sockopt *);
void udp6_init(void);
int udp6_input(struct mbuf **, int *, int);
-int udp6_output(struct in6pcb *, struct mbuf *, struct sockaddr_in6 *,
+int udp6_output(struct inpcb *, struct mbuf *, struct sockaddr_in6 *,
struct mbuf *, struct lwp *);
int udp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int udp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,