IPv6 cleanup: kernel
Finish what was started a few years ago and harmonize IPv6 and IPv4 kernel names. We are down to very few places now that it is feasible to do the change for everything remaining with causing too much disturbance. Remove "aliases" for IPv6 names which confusingly could indicate that we are talking about a different data structure or field or have two fields, one for each address family. Try to follow common conventions used in FreeBSD. * Rename sin6p to sin6 as that is how it is spelt in most places. * Remove "aliases" (#defines) for: - in6pcb which really is an inpcb and nothing separate - sotoin6pcb which is sotoinpcb (as per above) - in6p_sp which is inp_sp - in6p_flowinfo which is inp_flow * Try to use ia6 for in6_addr rather than in6p. * With all these gone also rename the in6p variables to inp as that is what we call it in most of the network stack including parts of netinet6. The reasons behind this cleanup are that we try to further unify netinet and netinet6 code where possible and that people will less ignore one or the other protocol family when doing code changes as they may not have spotted places due to different names for the same thing. No functional changes. Discussed with: tuexen (SCTP changes) MFC after: 3 months Sponsored by: Netflix
This commit is contained in:
parent
5d3e50865d
commit
f66d5bcdd2
@ -964,7 +964,7 @@ ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
|
||||
i6addr_t *inp, *inpmask;
|
||||
{
|
||||
#ifdef USE_INET6
|
||||
struct in6_addr *inp6 = NULL;
|
||||
struct in6_addr *ia6 = NULL;
|
||||
#endif
|
||||
struct sockaddr *sock, *mask;
|
||||
struct sockaddr_in *sin;
|
||||
@ -992,9 +992,9 @@ ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
|
||||
break;
|
||||
#ifdef USE_INET6
|
||||
if ((v == 6) && (sin->sin_family == AF_INET6)) {
|
||||
inp6 = &((struct sockaddr_in6 *)sin)->sin6_addr;
|
||||
if (!IN6_IS_ADDR_LINKLOCAL(inp6) &&
|
||||
!IN6_IS_ADDR_LOOPBACK(inp6))
|
||||
ia6 = &((struct sockaddr_in6 *)sin)->sin6_addr;
|
||||
if (!IN6_IS_ADDR_LINKLOCAL(ia6) &&
|
||||
!IN6_IS_ADDR_LOOPBACK(ia6))
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -57,9 +57,6 @@
|
||||
#endif
|
||||
#include <sys/ck.h>
|
||||
|
||||
#define in6pcb inpcb /* for KAME src sync over BSD*'s */
|
||||
#define in6p_sp inp_sp /* for KAME src sync over BSD*'s */
|
||||
|
||||
/*
|
||||
* struct inpcb is the common protocol control block structure used in most
|
||||
* IP transport protocols.
|
||||
@ -342,7 +339,6 @@ struct inpcb {
|
||||
#define in6p_faddr inp_inc.inc6_faddr
|
||||
#define in6p_laddr inp_inc.inc6_laddr
|
||||
#define in6p_zoneid inp_inc.inc6_zoneid
|
||||
#define in6p_flowinfo inp_flow
|
||||
|
||||
#define inp_vnet inp_pcbinfo->ipi_vnet
|
||||
|
||||
@ -773,7 +769,6 @@ int inp_so_options(const struct inpcb *inp);
|
||||
INPLOOKUP_WLOCKPCB)
|
||||
|
||||
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
|
||||
#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
|
||||
|
||||
#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
|
||||
|
||||
|
@ -1954,12 +1954,10 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *sin;
|
||||
struct in6pcb *inp6;
|
||||
|
||||
inp6 = (struct in6pcb *)&inp->ip_inp.inp;
|
||||
/* invalid if we are a v6 only endpoint */
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
|
||||
SCTP_IPV6_V6ONLY(inp6))
|
||||
SCTP_IPV6_V6ONLY(&inp->ip_inp.inp))
|
||||
return;
|
||||
|
||||
sin = &ifa->address.sin;
|
||||
@ -2032,11 +2030,9 @@ sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, uint32_t val SCTP_UNU
|
||||
case AF_INET:
|
||||
{
|
||||
/* invalid if we are a v6 only endpoint */
|
||||
struct in6pcb *inp6;
|
||||
|
||||
inp6 = (struct in6pcb *)&inp->ip_inp.inp;
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
|
||||
SCTP_IPV6_V6ONLY(inp6)) {
|
||||
SCTP_IPV6_V6ONLY(&inp->ip_inp.inp)) {
|
||||
cnt_invalid++;
|
||||
if (asc->cnt == cnt_invalid)
|
||||
return (1);
|
||||
@ -2147,13 +2143,11 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
case AF_INET:
|
||||
{
|
||||
/* invalid if we are a v6 only endpoint */
|
||||
struct in6pcb *inp6;
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
inp6 = (struct in6pcb *)&inp->ip_inp.inp;
|
||||
/* invalid if we are a v6 only endpoint */
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
|
||||
SCTP_IPV6_V6ONLY(inp6))
|
||||
SCTP_IPV6_V6ONLY(&inp->ip_inp.inp))
|
||||
continue;
|
||||
|
||||
sin = &ifa->address.sin;
|
||||
@ -2170,7 +2164,7 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
continue;
|
||||
}
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
|
||||
SCTP_IPV6_V6ONLY(inp6)) {
|
||||
SCTP_IPV6_V6ONLY(&inp->ip_inp.inp)) {
|
||||
cnt_invalid++;
|
||||
if (asc->cnt == cnt_invalid)
|
||||
return;
|
||||
|
@ -97,9 +97,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <crypto/sha1.h>
|
||||
#include <crypto/sha2/sha256.h>
|
||||
|
||||
#ifndef in6pcb
|
||||
#define in6pcb inpcb
|
||||
#endif
|
||||
/* Declare all the malloc names for all the various mallocs */
|
||||
MALLOC_DECLARE(SCTP_M_MAP);
|
||||
MALLOC_DECLARE(SCTP_M_STRMI);
|
||||
@ -368,7 +365,7 @@ typedef struct callout sctp_os_timer_t;
|
||||
*/
|
||||
|
||||
/* get the v6 hop limit */
|
||||
#define SCTP_GET_HLIM(inp, ro) in6_selecthlim((struct in6pcb *)&inp->ip_inp.inp, (ro ? (ro->ro_rt ? (ro->ro_rt->rt_ifp) : (NULL)) : (NULL)));
|
||||
#define SCTP_GET_HLIM(inp, ro) in6_selecthlim((struct inpcb *)&inp->ip_inp.inp, (ro ? (ro->ro_rt ? (ro->ro_rt->rt_ifp) : (NULL)) : (NULL)));
|
||||
|
||||
/* is the endpoint v6only? */
|
||||
#define SCTP_IPV6_V6ONLY(inp) (((struct inpcb *)inp)->inp_flags & IN6P_IPV6_V6ONLY)
|
||||
@ -431,7 +428,7 @@ typedef struct rtentry sctp_rtentry_t;
|
||||
m_clrprotoflags(o_pak); \
|
||||
if (local_stcb && local_stcb->sctp_ep) \
|
||||
result = ip6_output(o_pak, \
|
||||
((struct in6pcb *)(local_stcb->sctp_ep))->in6p_outputopts, \
|
||||
((struct inpcb *)(local_stcb->sctp_ep))->in6p_outputopts, \
|
||||
(ro), 0, 0, ifp, NULL); \
|
||||
else \
|
||||
result = ip6_output(o_pak, NULL, (ro), 0, 0, ifp, NULL); \
|
||||
|
@ -4336,7 +4336,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
|
||||
* at the SCTP layer. So use the value from
|
||||
* the IP layer.
|
||||
*/
|
||||
flowlabel = ntohl(((struct in6pcb *)inp)->in6p_flowinfo);
|
||||
flowlabel = ntohl(((struct inpcb *)inp)->inp_flow);
|
||||
}
|
||||
flowlabel &= 0x000fffff;
|
||||
len = SCTP_MIN_OVERHEAD;
|
||||
@ -4391,7 +4391,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
|
||||
* at the SCTP layer. So use the value from
|
||||
* the IP layer.
|
||||
*/
|
||||
tos_value = (ntohl(((struct in6pcb *)inp)->in6p_flowinfo) >> 20) & 0xff;
|
||||
tos_value = (ntohl(((struct inpcb *)inp)->inp_flow) >> 20) & 0xff;
|
||||
}
|
||||
tos_value &= 0xfc;
|
||||
if (ecn_ok) {
|
||||
|
@ -3643,12 +3643,8 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
|
||||
|
||||
|
||||
#ifdef INET6
|
||||
if (ip_pcb->inp_vflag & INP_IPV6) {
|
||||
struct in6pcb *in6p;
|
||||
|
||||
in6p = (struct in6pcb *)inp;
|
||||
ip6_freepcbopts(in6p->in6p_outputopts);
|
||||
}
|
||||
if (ip_pcb->inp_vflag & INP_IPV6)
|
||||
ip6_freepcbopts(((struct inpcb *)inp)->in6p_outputopts);
|
||||
#endif /* INET6 */
|
||||
ip_pcb->inp_vflag = 0;
|
||||
/* free up authentication fields */
|
||||
|
@ -362,7 +362,7 @@ struct sctp_inpcb {
|
||||
*/
|
||||
union {
|
||||
struct inpcb inp;
|
||||
char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
|
||||
char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
|
||||
~SCTP_ALIGNM1];
|
||||
} ip_inp;
|
||||
|
||||
|
@ -1412,10 +1412,8 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
|
||||
}
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
|
||||
(num_v4 > 0)) {
|
||||
struct in6pcb *inp6;
|
||||
|
||||
inp6 = (struct in6pcb *)inp;
|
||||
if (SCTP_IPV6_V6ONLY(inp6)) {
|
||||
if (SCTP_IPV6_V6ONLY(inp)) {
|
||||
/*
|
||||
* if IPV6_V6ONLY flag, ignore connections destined
|
||||
* to a v4 addr or v4-mapped addr
|
||||
@ -6916,14 +6914,14 @@ sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *sin6p;
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
if (addr->sa_len != sizeof(struct sockaddr_in6)) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
|
||||
return (EINVAL);
|
||||
}
|
||||
sin6p = (struct sockaddr_in6 *)addr;
|
||||
if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6p->sin6_addr)) != 0) {
|
||||
sin6 = (struct sockaddr_in6 *)addr;
|
||||
if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6->sin6_addr)) != 0) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
|
||||
return (error);
|
||||
}
|
||||
|
@ -344,17 +344,17 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
int error = 0;
|
||||
struct inpcb *inp;
|
||||
struct tcpcb *tp = NULL;
|
||||
struct sockaddr_in6 *sin6p;
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
sin6p = (struct sockaddr_in6 *)nam;
|
||||
if (nam->sa_len != sizeof (*sin6p))
|
||||
sin6 = (struct sockaddr_in6 *)nam;
|
||||
if (nam->sa_len != sizeof (*sin6))
|
||||
return (EINVAL);
|
||||
/*
|
||||
* Must check for multicast addresses and disallow binding
|
||||
* to them.
|
||||
*/
|
||||
if (sin6p->sin6_family == AF_INET6 &&
|
||||
IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr))
|
||||
if (sin6->sin6_family == AF_INET6 &&
|
||||
IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
|
||||
return (EAFNOSUPPORT);
|
||||
|
||||
TCPDEBUG0;
|
||||
@ -372,12 +372,12 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
inp->inp_vflag |= INP_IPV6;
|
||||
#ifdef INET
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&sin6p->sin6_addr))
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
|
||||
inp->inp_vflag |= INP_IPV4;
|
||||
else if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
|
||||
else if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
|
||||
struct sockaddr_in sin;
|
||||
|
||||
in6_sin6_2_sin(&sin, sin6p);
|
||||
in6_sin6_2_sin(&sin, sin6);
|
||||
if (IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
|
||||
error = EAFNOSUPPORT;
|
||||
INP_HASH_WUNLOCK(&V_tcbinfo);
|
||||
@ -566,18 +566,18 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
int error = 0;
|
||||
struct inpcb *inp;
|
||||
struct tcpcb *tp = NULL;
|
||||
struct sockaddr_in6 *sin6p;
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
TCPDEBUG0;
|
||||
|
||||
sin6p = (struct sockaddr_in6 *)nam;
|
||||
if (nam->sa_len != sizeof (*sin6p))
|
||||
sin6 = (struct sockaddr_in6 *)nam;
|
||||
if (nam->sa_len != sizeof (*sin6))
|
||||
return (EINVAL);
|
||||
/*
|
||||
* Must disallow TCP ``connections'' to multicast addresses.
|
||||
*/
|
||||
if (sin6p->sin6_family == AF_INET6
|
||||
&& IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr))
|
||||
if (sin6->sin6_family == AF_INET6
|
||||
&& IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
|
||||
return (EAFNOSUPPORT);
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
@ -599,7 +599,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
* therefore probably require the hash lock, which isn't held here.
|
||||
* Is this a significant problem?
|
||||
*/
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
|
||||
struct sockaddr_in sin;
|
||||
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
|
||||
@ -611,7 +611,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
goto out;
|
||||
}
|
||||
|
||||
in6_sin6_2_sin(&sin, sin6p);
|
||||
in6_sin6_2_sin(&sin, sin6);
|
||||
if (IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
|
||||
error = EAFNOSUPPORT;
|
||||
goto out;
|
||||
@ -641,7 +641,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
inp->inp_vflag &= ~INP_IPV4;
|
||||
inp->inp_vflag |= INP_IPV6;
|
||||
inp->inp_inc.inc_flags |= INC_ISIPV6;
|
||||
if ((error = prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr)) != 0)
|
||||
if ((error = prison_remote_ip6(td->td_ucred, &sin6->sin6_addr)) != 0)
|
||||
goto out;
|
||||
if ((error = tcp6_connect(tp, nam, td)) != 0)
|
||||
goto out;
|
||||
@ -972,22 +972,22 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *sin6p;
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
sin6p = (struct sockaddr_in6 *)nam;
|
||||
if (sin6p->sin6_len != sizeof(struct sockaddr_in6)) {
|
||||
sin6 = (struct sockaddr_in6 *)nam;
|
||||
if (sin6->sin6_len != sizeof(*sin6)) {
|
||||
if (m)
|
||||
m_freem(m);
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr)) {
|
||||
if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
|
||||
if (m)
|
||||
m_freem(m);
|
||||
error = EAFNOSUPPORT;
|
||||
goto out;
|
||||
}
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
|
||||
#ifdef INET
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
|
||||
error = EINVAL;
|
||||
@ -1003,7 +1003,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
}
|
||||
inp->inp_vflag &= ~INP_IPV6;
|
||||
sinp = &sin;
|
||||
in6_sin6_2_sin(sinp, sin6p);
|
||||
in6_sin6_2_sin(sinp, sin6);
|
||||
if (IN_MULTICAST(
|
||||
ntohl(sinp->sin_addr.s_addr))) {
|
||||
error = EAFNOSUPPORT;
|
||||
@ -1034,7 +1034,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
inp->inp_vflag &= ~INP_IPV4;
|
||||
inp->inp_inc.inc_flags |= INC_ISIPV6;
|
||||
if ((error = prison_remote_ip6(td->td_ucred,
|
||||
&sin6p->sin6_addr))) {
|
||||
&sin6->sin6_addr))) {
|
||||
if (m)
|
||||
m_freem(m);
|
||||
goto out;
|
||||
|
@ -1894,7 +1894,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
|
||||
{
|
||||
struct mbuf *m = *mp;
|
||||
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
|
||||
struct inpcb *in6p;
|
||||
struct inpcb *inp;
|
||||
struct inpcb *last = NULL;
|
||||
struct sockaddr_in6 fromsa;
|
||||
struct icmp6_hdr *icmp6;
|
||||
@ -1926,25 +1926,25 @@ icmp6_rip6_input(struct mbuf **mp, int off)
|
||||
}
|
||||
|
||||
INP_INFO_RLOCK_ET(&V_ripcbinfo, et);
|
||||
CK_LIST_FOREACH(in6p, &V_ripcb, inp_list) {
|
||||
if ((in6p->inp_vflag & INP_IPV6) == 0)
|
||||
CK_LIST_FOREACH(inp, &V_ripcb, inp_list) {
|
||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||
continue;
|
||||
if (in6p->inp_ip_p != IPPROTO_ICMPV6)
|
||||
if (inp->inp_ip_p != 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->in6p_laddr) &&
|
||||
!IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, &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->in6p_faddr) &&
|
||||
!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, &ip6->ip6_src))
|
||||
continue;
|
||||
INP_RLOCK(in6p);
|
||||
if (__predict_false(in6p->inp_flags2 & INP_FREED)) {
|
||||
INP_RUNLOCK(in6p);
|
||||
INP_RLOCK(inp);
|
||||
if (__predict_false(inp->inp_flags2 & INP_FREED)) {
|
||||
INP_RUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
if (ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
|
||||
in6p->in6p_icmp6filt)) {
|
||||
INP_RUNLOCK(in6p);
|
||||
inp->in6p_icmp6filt)) {
|
||||
INP_RUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
if (last != NULL) {
|
||||
@ -2005,7 +2005,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
|
||||
}
|
||||
INP_RUNLOCK(last);
|
||||
}
|
||||
last = in6p;
|
||||
last = inp;
|
||||
}
|
||||
INP_INFO_RUNLOCK_ET(&V_ripcbinfo, et);
|
||||
if (last != NULL) {
|
||||
|
@ -1828,7 +1828,7 @@ ip6_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
* Returns NULL if no ifp could be found.
|
||||
*/
|
||||
static struct ifnet *
|
||||
in6p_lookup_mcast_ifp(const struct inpcb *in6p,
|
||||
in6p_lookup_mcast_ifp(const struct inpcb *inp,
|
||||
const struct sockaddr_in6 *gsin6)
|
||||
{
|
||||
struct nhop6_basic nh6;
|
||||
@ -1836,13 +1836,13 @@ in6p_lookup_mcast_ifp(const struct inpcb *in6p,
|
||||
uint32_t scopeid;
|
||||
uint32_t fibnum;
|
||||
|
||||
KASSERT(in6p->inp_vflag & INP_IPV6,
|
||||
KASSERT(inp->inp_vflag & INP_IPV6,
|
||||
("%s: not INP_IPV6 inpcb", __func__));
|
||||
KASSERT(gsin6->sin6_family == AF_INET6,
|
||||
("%s: not AF_INET6 group", __func__));
|
||||
|
||||
in6_splitscope(&gsin6->sin6_addr, &dst, &scopeid);
|
||||
fibnum = in6p ? in6p->inp_inc.inc_fibnum : RT_DEFAULT_FIB;
|
||||
fibnum = inp ? inp->inp_inc.inc_fibnum : RT_DEFAULT_FIB;
|
||||
if (fib6_lookup_nh_basic(fibnum, &dst, scopeid, 0, 0, &nh6) != 0)
|
||||
return (NULL);
|
||||
|
||||
|
@ -801,20 +801,20 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr,
|
||||
void
|
||||
in6_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp)
|
||||
{
|
||||
struct inpcb *in6p;
|
||||
struct inpcb *inp;
|
||||
struct in6_multi *inm;
|
||||
struct in6_mfilter *imf;
|
||||
struct ip6_moptions *im6o;
|
||||
|
||||
INP_INFO_WLOCK(pcbinfo);
|
||||
CK_LIST_FOREACH(in6p, pcbinfo->ipi_listhead, inp_list) {
|
||||
INP_WLOCK(in6p);
|
||||
if (__predict_false(in6p->inp_flags2 & INP_FREED)) {
|
||||
INP_WUNLOCK(in6p);
|
||||
CK_LIST_FOREACH(inp, pcbinfo->ipi_listhead, inp_list) {
|
||||
INP_WLOCK(inp);
|
||||
if (__predict_false(inp->inp_flags2 & INP_FREED)) {
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
im6o = in6p->in6p_moptions;
|
||||
if ((in6p->inp_vflag & INP_IPV6) && im6o != NULL) {
|
||||
im6o = inp->in6p_moptions;
|
||||
if ((inp->inp_vflag & INP_IPV6) && im6o != NULL) {
|
||||
/*
|
||||
* Unselect the outgoing ifp for multicast if it
|
||||
* is being detached.
|
||||
@ -838,7 +838,7 @@ in6_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp)
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_WUNLOCK(pcbinfo);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ int in6_getpeeraddr(struct socket *so, struct sockaddr **nam);
|
||||
int in6_getsockaddr(struct socket *so, struct sockaddr **nam);
|
||||
int in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam);
|
||||
int in6_mapped_peeraddr(struct socket *so, struct sockaddr **nam);
|
||||
int in6_selecthlim(struct in6pcb *, struct ifnet *);
|
||||
int in6_selecthlim(struct inpcb *, struct ifnet *);
|
||||
int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *);
|
||||
void init_sin6(struct sockaddr_in6 *sin6, struct mbuf *m, int);
|
||||
#endif /* _KERNEL */
|
||||
|
@ -931,21 +931,21 @@ in6_selectroute_fib(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
|
||||
* 3. The system default hoplimit.
|
||||
*/
|
||||
int
|
||||
in6_selecthlim(struct inpcb *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->in6p_hops >= 0)
|
||||
return (inp->in6p_hops);
|
||||
else if (ifp)
|
||||
return (ND_IFINFO(ifp)->chlim);
|
||||
else if (in6p && !IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
|
||||
else if (inp && !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
||||
struct nhop6_basic nh6;
|
||||
struct in6_addr dst;
|
||||
uint32_t fibnum, scopeid;
|
||||
int hlim;
|
||||
|
||||
fibnum = in6p->inp_inc.inc_fibnum;
|
||||
in6_splitscope(&in6p->in6p_faddr, &dst, &scopeid);
|
||||
fibnum = inp->inp_inc.inc_fibnum;
|
||||
in6_splitscope(&inp->in6p_faddr, &dst, &scopeid);
|
||||
if (fib6_lookup_nh_basic(fibnum, &dst, scopeid, 0, 0, &nh6)==0){
|
||||
hlim = ND_IFINFO(nh6.nh_ifp)->chlim;
|
||||
return (hlim);
|
||||
|
@ -1404,12 +1404,12 @@ ip6_savecontrol_v4(struct inpcb *inp, struct mbuf *m, struct mbuf **mp,
|
||||
}
|
||||
|
||||
void
|
||||
ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
ip6_savecontrol(struct inpcb *inp, struct mbuf *m, struct mbuf **mp)
|
||||
{
|
||||
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
|
||||
int v4only = 0;
|
||||
|
||||
mp = ip6_savecontrol_v4(in6p, m, mp, &v4only);
|
||||
mp = ip6_savecontrol_v4(inp, m, mp, &v4only);
|
||||
if (v4only)
|
||||
return;
|
||||
|
||||
@ -1420,7 +1420,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
* returned to normal user.
|
||||
* See also RFC 2292 section 6 (or RFC 3542 section 8).
|
||||
*/
|
||||
if ((in6p->inp_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
|
||||
@ -1462,7 +1462,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
* Note: this constraint is removed in RFC3542
|
||||
*/
|
||||
*mp = sbcreatecontrol((caddr_t)hbh, hbhlen,
|
||||
IS2292(in6p, IPV6_2292HOPOPTS, IPV6_HOPOPTS),
|
||||
IS2292(inp, IPV6_2292HOPOPTS, IPV6_HOPOPTS),
|
||||
IPPROTO_IPV6);
|
||||
if (*mp)
|
||||
mp = &(*mp)->m_next;
|
||||
@ -1472,7 +1472,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
}
|
||||
}
|
||||
|
||||
if ((in6p->inp_flags & (IN6P_RTHDR | IN6P_DSTOPTS)) != 0) {
|
||||
if ((inp->inp_flags & (IN6P_RTHDR | IN6P_DSTOPTS)) != 0) {
|
||||
int nxt = ip6->ip6_nxt, off = sizeof(struct ip6_hdr);
|
||||
|
||||
/*
|
||||
@ -1533,22 +1533,22 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
|
||||
switch (nxt) {
|
||||
case IPPROTO_DSTOPTS:
|
||||
if (!(in6p->inp_flags & IN6P_DSTOPTS))
|
||||
if (!(inp->inp_flags & IN6P_DSTOPTS))
|
||||
break;
|
||||
|
||||
*mp = sbcreatecontrol((caddr_t)ip6e, elen,
|
||||
IS2292(in6p,
|
||||
IS2292(inp,
|
||||
IPV6_2292DSTOPTS, IPV6_DSTOPTS),
|
||||
IPPROTO_IPV6);
|
||||
if (*mp)
|
||||
mp = &(*mp)->m_next;
|
||||
break;
|
||||
case IPPROTO_ROUTING:
|
||||
if (!(in6p->inp_flags & IN6P_RTHDR))
|
||||
if (!(inp->inp_flags & IN6P_RTHDR))
|
||||
break;
|
||||
|
||||
*mp = sbcreatecontrol((caddr_t)ip6e, elen,
|
||||
IS2292(in6p, IPV6_2292RTHDR, IPV6_RTHDR),
|
||||
IS2292(inp, IPV6_2292RTHDR, IPV6_RTHDR),
|
||||
IPPROTO_IPV6);
|
||||
if (*mp)
|
||||
mp = &(*mp)->m_next;
|
||||
@ -1584,7 +1584,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
;
|
||||
}
|
||||
|
||||
if (in6p->inp_flags2 & INP_RECVFLOWID) {
|
||||
if (inp->inp_flags2 & INP_RECVFLOWID) {
|
||||
uint32_t flowid, flow_type;
|
||||
|
||||
flowid = m->m_pkthdr.flowid;
|
||||
@ -1605,7 +1605,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
|
||||
}
|
||||
|
||||
#ifdef RSS
|
||||
if (in6p->inp_flags2 & INP_RECVRSSBUCKETID) {
|
||||
if (inp->inp_flags2 & INP_RECVRSSBUCKETID) {
|
||||
uint32_t flowid, flow_type;
|
||||
uint32_t rss_bucketid;
|
||||
|
||||
|
@ -1471,7 +1471,7 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
{
|
||||
int optdatalen, uproto;
|
||||
void *optdata;
|
||||
struct inpcb *in6p = sotoinpcb(so);
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
int error, optval;
|
||||
int level, op, optname;
|
||||
int optlen;
|
||||
@ -1506,43 +1506,43 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
sopt->sopt_dir == SOPT_SET) {
|
||||
switch (sopt->sopt_name) {
|
||||
case SO_REUSEADDR:
|
||||
INP_WLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
if ((so->so_options & SO_REUSEADDR) != 0)
|
||||
in6p->inp_flags2 |= INP_REUSEADDR;
|
||||
inp->inp_flags2 |= INP_REUSEADDR;
|
||||
else
|
||||
in6p->inp_flags2 &= ~INP_REUSEADDR;
|
||||
INP_WUNLOCK(in6p);
|
||||
inp->inp_flags2 &= ~INP_REUSEADDR;
|
||||
INP_WUNLOCK(inp);
|
||||
error = 0;
|
||||
break;
|
||||
case SO_REUSEPORT:
|
||||
INP_WLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
if ((so->so_options & SO_REUSEPORT) != 0)
|
||||
in6p->inp_flags2 |= INP_REUSEPORT;
|
||||
inp->inp_flags2 |= INP_REUSEPORT;
|
||||
else
|
||||
in6p->inp_flags2 &= ~INP_REUSEPORT;
|
||||
INP_WUNLOCK(in6p);
|
||||
inp->inp_flags2 &= ~INP_REUSEPORT;
|
||||
INP_WUNLOCK(inp);
|
||||
error = 0;
|
||||
break;
|
||||
case SO_REUSEPORT_LB:
|
||||
INP_WLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
if ((so->so_options & SO_REUSEPORT_LB) != 0)
|
||||
in6p->inp_flags2 |= INP_REUSEPORT_LB;
|
||||
inp->inp_flags2 |= INP_REUSEPORT_LB;
|
||||
else
|
||||
in6p->inp_flags2 &= ~INP_REUSEPORT_LB;
|
||||
INP_WUNLOCK(in6p);
|
||||
inp->inp_flags2 &= ~INP_REUSEPORT_LB;
|
||||
INP_WUNLOCK(inp);
|
||||
error = 0;
|
||||
break;
|
||||
case SO_SETFIB:
|
||||
INP_WLOCK(in6p);
|
||||
in6p->inp_inc.inc_fibnum = so->so_fibnum;
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_inc.inc_fibnum = so->so_fibnum;
|
||||
INP_WUNLOCK(inp);
|
||||
error = 0;
|
||||
break;
|
||||
case SO_MAX_PACING_RATE:
|
||||
#ifdef RATELIMIT
|
||||
INP_WLOCK(in6p);
|
||||
in6p->inp_flags2 |= INP_RATE_LIMIT_CHANGED;
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_flags2 |= INP_RATE_LIMIT_CHANGED;
|
||||
INP_WUNLOCK(inp);
|
||||
error = 0;
|
||||
#else
|
||||
error = EOPNOTSUPP;
|
||||
@ -1576,7 +1576,7 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
error = soopt_mcopyin(sopt, m); /* XXX */
|
||||
if (error != 0)
|
||||
break;
|
||||
error = ip6_pcbopts(&in6p->in6p_outputopts,
|
||||
error = ip6_pcbopts(&inp->in6p_outputopts,
|
||||
m, so, sopt);
|
||||
m_freem(m); /* XXX */
|
||||
break;
|
||||
@ -1647,57 +1647,57 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
error = EINVAL;
|
||||
else {
|
||||
/* -1 = kernel default */
|
||||
in6p->in6p_hops = optval;
|
||||
if ((in6p->inp_vflag &
|
||||
inp->in6p_hops = optval;
|
||||
if ((inp->inp_vflag &
|
||||
INP_IPV4) != 0)
|
||||
in6p->inp_ip_ttl = optval;
|
||||
inp->inp_ip_ttl = optval;
|
||||
}
|
||||
break;
|
||||
#define OPTSET(bit) \
|
||||
do { \
|
||||
INP_WLOCK(in6p); \
|
||||
INP_WLOCK(inp); \
|
||||
if (optval) \
|
||||
in6p->inp_flags |= (bit); \
|
||||
inp->inp_flags |= (bit); \
|
||||
else \
|
||||
in6p->inp_flags &= ~(bit); \
|
||||
INP_WUNLOCK(in6p); \
|
||||
inp->inp_flags &= ~(bit); \
|
||||
INP_WUNLOCK(inp); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
#define OPTSET2292(bit) \
|
||||
do { \
|
||||
INP_WLOCK(in6p); \
|
||||
in6p->inp_flags |= IN6P_RFC2292; \
|
||||
INP_WLOCK(inp); \
|
||||
inp->inp_flags |= IN6P_RFC2292; \
|
||||
if (optval) \
|
||||
in6p->inp_flags |= (bit); \
|
||||
inp->inp_flags |= (bit); \
|
||||
else \
|
||||
in6p->inp_flags &= ~(bit); \
|
||||
INP_WUNLOCK(in6p); \
|
||||
inp->inp_flags &= ~(bit); \
|
||||
INP_WUNLOCK(inp); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
#define OPTBIT(bit) (in6p->inp_flags & (bit) ? 1 : 0)
|
||||
#define OPTBIT(bit) (inp->inp_flags & (bit) ? 1 : 0)
|
||||
|
||||
#define OPTSET2_N(bit, val) do { \
|
||||
if (val) \
|
||||
in6p->inp_flags2 |= bit; \
|
||||
inp->inp_flags2 |= bit; \
|
||||
else \
|
||||
in6p->inp_flags2 &= ~bit; \
|
||||
inp->inp_flags2 &= ~bit; \
|
||||
} while (0)
|
||||
#define OPTSET2(bit, val) do { \
|
||||
INP_WLOCK(in6p); \
|
||||
INP_WLOCK(inp); \
|
||||
OPTSET2_N(bit, val); \
|
||||
INP_WUNLOCK(in6p); \
|
||||
INP_WUNLOCK(inp); \
|
||||
} while (0)
|
||||
#define OPTBIT2(bit) (in6p->inp_flags2 & (bit) ? 1 : 0)
|
||||
#define OPTBIT2(bit) (inp->inp_flags2 & (bit) ? 1 : 0)
|
||||
#define OPTSET2292_EXCLUSIVE(bit) \
|
||||
do { \
|
||||
INP_WLOCK(in6p); \
|
||||
INP_WLOCK(inp); \
|
||||
if (OPTBIT(IN6P_RFC2292)) { \
|
||||
error = EINVAL; \
|
||||
} else { \
|
||||
if (optval) \
|
||||
in6p->inp_flags |= (bit); \
|
||||
inp->inp_flags |= (bit); \
|
||||
else \
|
||||
in6p->inp_flags &= ~(bit); \
|
||||
inp->inp_flags &= ~(bit); \
|
||||
} \
|
||||
INP_WUNLOCK(in6p); \
|
||||
INP_WUNLOCK(inp); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
case IPV6_RECVPKTINFO:
|
||||
@ -1713,17 +1713,17 @@ do { \
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
INP_WLOCK(in6p);
|
||||
if (in6p->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_WUNLOCK(inp);
|
||||
return (ECONNRESET);
|
||||
}
|
||||
optp = &in6p->in6p_outputopts;
|
||||
optp = &inp->in6p_outputopts;
|
||||
error = ip6_pcbopt(IPV6_HOPLIMIT,
|
||||
(u_char *)&optval, sizeof(optval),
|
||||
optp, (td != NULL) ? td->td_ucred :
|
||||
NULL, uproto);
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1774,16 +1774,16 @@ do { \
|
||||
* available only prior to bind(2).
|
||||
* see ipng mailing list, Jun 22 2001.
|
||||
*/
|
||||
if (in6p->inp_lport ||
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {
|
||||
if (inp->inp_lport ||
|
||||
!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
OPTSET(IN6P_IPV6_V6ONLY);
|
||||
if (optval)
|
||||
in6p->inp_vflag &= ~INP_IPV4;
|
||||
inp->inp_vflag &= ~INP_IPV4;
|
||||
else
|
||||
in6p->inp_vflag |= INP_IPV4;
|
||||
inp->inp_vflag |= INP_IPV4;
|
||||
break;
|
||||
case IPV6_RECVTCLASS:
|
||||
/* cannot mix with RFC2292 XXX */
|
||||
@ -1807,10 +1807,10 @@ do { \
|
||||
case IPV6_RSS_LISTEN_BUCKET:
|
||||
if ((optval >= 0) &&
|
||||
(optval < rss_getnumbuckets())) {
|
||||
INP_WLOCK(in6p);
|
||||
in6p->inp_rss_listen_bucket = optval;
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_rss_listen_bucket = optval;
|
||||
OPTSET2_N(INP_RSS_BUCKET_SET, 1);
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
} else {
|
||||
error = EINVAL;
|
||||
}
|
||||
@ -1833,17 +1833,17 @@ do { \
|
||||
break;
|
||||
{
|
||||
struct ip6_pktopts **optp;
|
||||
INP_WLOCK(in6p);
|
||||
if (in6p->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_WUNLOCK(inp);
|
||||
return (ECONNRESET);
|
||||
}
|
||||
optp = &in6p->in6p_outputopts;
|
||||
optp = &inp->in6p_outputopts;
|
||||
error = ip6_pcbopt(optname,
|
||||
(u_char *)&optval, sizeof(optval),
|
||||
optp, (td != NULL) ? td->td_ucred :
|
||||
NULL, uproto);
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1925,16 +1925,16 @@ do { \
|
||||
break;
|
||||
optlen = sopt->sopt_valsize;
|
||||
optbuf = optbuf_storage;
|
||||
INP_WLOCK(in6p);
|
||||
if (in6p->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_WUNLOCK(inp);
|
||||
return (ECONNRESET);
|
||||
}
|
||||
optp = &in6p->in6p_outputopts;
|
||||
optp = &inp->in6p_outputopts;
|
||||
error = ip6_pcbopt(optname, optbuf, optlen,
|
||||
optp, (td != NULL) ? td->td_ucred : NULL,
|
||||
uproto);
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
#undef OPTSET
|
||||
@ -1951,7 +1951,7 @@ do { \
|
||||
case MCAST_LEAVE_GROUP:
|
||||
case MCAST_JOIN_SOURCE_GROUP:
|
||||
case MCAST_LEAVE_SOURCE_GROUP:
|
||||
error = ip6_setmoptions(in6p, sopt);
|
||||
error = ip6_setmoptions(inp, sopt);
|
||||
break;
|
||||
|
||||
case IPV6_PORTRANGE:
|
||||
@ -1960,34 +1960,34 @@ do { \
|
||||
if (error)
|
||||
break;
|
||||
|
||||
INP_WLOCK(in6p);
|
||||
INP_WLOCK(inp);
|
||||
switch (optval) {
|
||||
case IPV6_PORTRANGE_DEFAULT:
|
||||
in6p->inp_flags &= ~(INP_LOWPORT);
|
||||
in6p->inp_flags &= ~(INP_HIGHPORT);
|
||||
inp->inp_flags &= ~(INP_LOWPORT);
|
||||
inp->inp_flags &= ~(INP_HIGHPORT);
|
||||
break;
|
||||
|
||||
case IPV6_PORTRANGE_HIGH:
|
||||
in6p->inp_flags &= ~(INP_LOWPORT);
|
||||
in6p->inp_flags |= INP_HIGHPORT;
|
||||
inp->inp_flags &= ~(INP_LOWPORT);
|
||||
inp->inp_flags |= INP_HIGHPORT;
|
||||
break;
|
||||
|
||||
case IPV6_PORTRANGE_LOW:
|
||||
in6p->inp_flags &= ~(INP_HIGHPORT);
|
||||
in6p->inp_flags |= INP_LOWPORT;
|
||||
inp->inp_flags &= ~(INP_HIGHPORT);
|
||||
inp->inp_flags |= INP_LOWPORT;
|
||||
break;
|
||||
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
|
||||
#if defined(IPSEC) || defined(IPSEC_SUPPORT)
|
||||
case IPV6_IPSEC_POLICY:
|
||||
if (IPSEC_ENABLED(ipv6)) {
|
||||
error = IPSEC_PCBCTL(ipv6, in6p, sopt);
|
||||
error = IPSEC_PCBCTL(ipv6, inp, sopt);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
@ -2055,7 +2055,7 @@ do { \
|
||||
break;
|
||||
|
||||
case IPV6_UNICAST_HOPS:
|
||||
optval = in6p->in6p_hops;
|
||||
optval = inp->in6p_hops;
|
||||
break;
|
||||
|
||||
case IPV6_RECVPKTINFO:
|
||||
@ -2081,7 +2081,7 @@ do { \
|
||||
case IPV6_PORTRANGE:
|
||||
{
|
||||
int flags;
|
||||
flags = in6p->inp_flags;
|
||||
flags = inp->inp_flags;
|
||||
if (flags & INP_HIGHPORT)
|
||||
optval = IPV6_PORTRANGE_HIGH;
|
||||
else if (flags & INP_LOWPORT)
|
||||
@ -2107,11 +2107,11 @@ do { \
|
||||
break;
|
||||
|
||||
case IPV6_FLOWID:
|
||||
optval = in6p->inp_flowid;
|
||||
optval = inp->inp_flowid;
|
||||
break;
|
||||
|
||||
case IPV6_FLOWTYPE:
|
||||
optval = in6p->inp_flowtype;
|
||||
optval = inp->inp_flowtype;
|
||||
break;
|
||||
|
||||
case IPV6_RECVFLOWID:
|
||||
@ -2120,8 +2120,8 @@ do { \
|
||||
#ifdef RSS
|
||||
case IPV6_RSSBUCKETID:
|
||||
retval =
|
||||
rss_hash2bucket(in6p->inp_flowid,
|
||||
in6p->inp_flowtype,
|
||||
rss_hash2bucket(inp->inp_flowid,
|
||||
inp->inp_flowtype,
|
||||
&rss_bucket);
|
||||
if (retval == 0)
|
||||
optval = rss_bucket;
|
||||
@ -2157,12 +2157,12 @@ do { \
|
||||
* XXX: we dot not consider the case of source
|
||||
* routing, or optional information to specify
|
||||
* the outgoing interface.
|
||||
* Copy faddr out of in6p to avoid holding lock
|
||||
* Copy faddr out of inp to avoid holding lock
|
||||
* on inp during route lookup.
|
||||
*/
|
||||
INP_RLOCK(in6p);
|
||||
bcopy(&in6p->in6p_faddr, &addr, sizeof(addr));
|
||||
INP_RUNLOCK(in6p);
|
||||
INP_RLOCK(inp);
|
||||
bcopy(&inp->in6p_faddr, &addr, sizeof(addr));
|
||||
INP_RUNLOCK(inp);
|
||||
error = ip6_getpmtu_ctl(so->so_fibnum,
|
||||
&addr, &pmtu);
|
||||
if (error)
|
||||
@ -2214,20 +2214,20 @@ do { \
|
||||
case IPV6_DONTFRAG:
|
||||
case IPV6_USE_MIN_MTU:
|
||||
case IPV6_PREFER_TEMPADDR:
|
||||
error = ip6_getpcbopt(in6p, optname, sopt);
|
||||
error = ip6_getpcbopt(inp, optname, sopt);
|
||||
break;
|
||||
|
||||
case IPV6_MULTICAST_IF:
|
||||
case IPV6_MULTICAST_HOPS:
|
||||
case IPV6_MULTICAST_LOOP:
|
||||
case IPV6_MSFILTER:
|
||||
error = ip6_getmoptions(in6p, sopt);
|
||||
error = ip6_getmoptions(inp, sopt);
|
||||
break;
|
||||
|
||||
#if defined(IPSEC) || defined(IPSEC_SUPPORT)
|
||||
case IPV6_IPSEC_POLICY:
|
||||
if (IPSEC_ENABLED(ipv6)) {
|
||||
error = IPSEC_PCBCTL(ipv6, in6p, sopt);
|
||||
error = IPSEC_PCBCTL(ipv6, inp, sopt);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
@ -2247,7 +2247,7 @@ ip6_raw_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
{
|
||||
int error = 0, optval, optlen;
|
||||
const int icmp6off = offsetof(struct icmp6_hdr, icmp6_cksum);
|
||||
struct inpcb *in6p = sotoinpcb(so);
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
int level, op, optname;
|
||||
|
||||
level = sopt->sopt_level;
|
||||
@ -2290,14 +2290,14 @@ ip6_raw_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
if (optval != icmp6off)
|
||||
error = EINVAL;
|
||||
} else
|
||||
in6p->in6p_cksum = optval;
|
||||
inp->in6p_cksum = optval;
|
||||
break;
|
||||
|
||||
case SOPT_GET:
|
||||
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
|
||||
optval = icmp6off;
|
||||
else
|
||||
optval = in6p->in6p_cksum;
|
||||
optval = inp->in6p_cksum;
|
||||
|
||||
error = sooptcopyout(sopt, &optval, sizeof(optval));
|
||||
break;
|
||||
@ -2396,16 +2396,16 @@ ip6_pcbopt(int optname, u_char *buf, int len, struct ip6_pktopts **pktopt,
|
||||
|
||||
#define GET_PKTOPT_VAR(field, lenexpr) do { \
|
||||
if (pktopt && pktopt->field) { \
|
||||
INP_RUNLOCK(in6p); \
|
||||
INP_RUNLOCK(inp); \
|
||||
optdata = malloc(sopt->sopt_valsize, M_TEMP, M_WAITOK); \
|
||||
malloc_optdata = true; \
|
||||
INP_RLOCK(in6p); \
|
||||
if (in6p->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \
|
||||
INP_RUNLOCK(in6p); \
|
||||
INP_RLOCK(inp); \
|
||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \
|
||||
INP_RUNLOCK(inp); \
|
||||
free(optdata, M_TEMP); \
|
||||
return (ECONNRESET); \
|
||||
} \
|
||||
pktopt = in6p->in6p_outputopts; \
|
||||
pktopt = inp->in6p_outputopts; \
|
||||
if (pktopt && pktopt->field) { \
|
||||
optdatalen = min(lenexpr, sopt->sopt_valsize); \
|
||||
bcopy(&pktopt->field, optdata, optdatalen); \
|
||||
@ -2424,7 +2424,7 @@ ip6_pcbopt(int optname, u_char *buf, int len, struct ip6_pktopts **pktopt,
|
||||
pktopt->field->sa_len)
|
||||
|
||||
static int
|
||||
ip6_getpcbopt(struct inpcb *in6p, int optname, struct sockopt *sopt)
|
||||
ip6_getpcbopt(struct inpcb *inp, int optname, struct sockopt *sopt)
|
||||
{
|
||||
void *optdata = NULL;
|
||||
bool malloc_optdata = false;
|
||||
@ -2436,8 +2436,8 @@ ip6_getpcbopt(struct inpcb *in6p, int optname, struct sockopt *sopt)
|
||||
int defpreftemp = IP6PO_TEMPADDR_SYSTEM;
|
||||
struct ip6_pktopts *pktopt;
|
||||
|
||||
INP_RLOCK(in6p);
|
||||
pktopt = in6p->in6p_outputopts;
|
||||
INP_RLOCK(inp);
|
||||
pktopt = inp->in6p_outputopts;
|
||||
|
||||
switch (optname) {
|
||||
case IPV6_PKTINFO:
|
||||
@ -2497,10 +2497,10 @@ ip6_getpcbopt(struct inpcb *in6p, int optname, struct sockopt *sopt)
|
||||
#ifdef DIAGNOSTIC
|
||||
panic("ip6_getpcbopt: unexpected option\n");
|
||||
#endif
|
||||
INP_RUNLOCK(in6p);
|
||||
INP_RUNLOCK(inp);
|
||||
return (ENOPROTOOPT);
|
||||
}
|
||||
INP_RUNLOCK(in6p);
|
||||
INP_RUNLOCK(inp);
|
||||
|
||||
error = sooptcopyout(sopt, optdata, optdatalen);
|
||||
if (malloc_optdata)
|
||||
@ -3182,23 +3182,23 @@ ip6_splithdr(struct mbuf *m, struct ip6_exthdrs *exthdrs)
|
||||
* Compute IPv6 extension header length.
|
||||
*/
|
||||
int
|
||||
ip6_optlen(struct inpcb *in6p)
|
||||
ip6_optlen(struct inpcb *inp)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (!in6p->in6p_outputopts)
|
||||
if (!inp->in6p_outputopts)
|
||||
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);
|
||||
if (in6p->in6p_outputopts->ip6po_rthdr)
|
||||
len += elen(inp->in6p_outputopts->ip6po_hbh);
|
||||
if (inp->in6p_outputopts->ip6po_rthdr)
|
||||
/* dest1 is valid with rthdr only */
|
||||
len += elen(in6p->in6p_outputopts->ip6po_dest1);
|
||||
len += elen(in6p->in6p_outputopts->ip6po_rthdr);
|
||||
len += elen(in6p->in6p_outputopts->ip6po_dest2);
|
||||
len += elen(inp->in6p_outputopts->ip6po_dest1);
|
||||
len += elen(inp->in6p_outputopts->ip6po_rthdr);
|
||||
len += elen(inp->in6p_outputopts->ip6po_dest2);
|
||||
return len;
|
||||
#undef elen
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
struct ifnet *ifp;
|
||||
struct mbuf *m = *mp;
|
||||
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
|
||||
struct inpcb *in6p;
|
||||
struct inpcb *inp;
|
||||
struct inpcb *last = NULL;
|
||||
struct mbuf *opts = NULL;
|
||||
struct sockaddr_in6 fromsa;
|
||||
@ -174,18 +174,18 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
ifp = m->m_pkthdr.rcvif;
|
||||
|
||||
INP_INFO_RLOCK_ET(&V_ripcbinfo, et);
|
||||
CK_LIST_FOREACH(in6p, &V_ripcb, inp_list) {
|
||||
CK_LIST_FOREACH(inp, &V_ripcb, inp_list) {
|
||||
/* XXX inp locking */
|
||||
if ((in6p->inp_vflag & INP_IPV6) == 0)
|
||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||
continue;
|
||||
if (in6p->inp_ip_p &&
|
||||
in6p->inp_ip_p != proto)
|
||||
if (inp->inp_ip_p &&
|
||||
inp->inp_ip_p != 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->in6p_laddr) &&
|
||||
!IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, &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->in6p_faddr) &&
|
||||
!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, &ip6->ip6_src))
|
||||
continue;
|
||||
if (last != NULL) {
|
||||
struct mbuf *n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
|
||||
@ -223,23 +223,23 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
INP_RUNLOCK(last);
|
||||
last = NULL;
|
||||
}
|
||||
INP_RLOCK(in6p);
|
||||
if (__predict_false(in6p->inp_flags2 & INP_FREED))
|
||||
INP_RLOCK(inp);
|
||||
if (__predict_false(inp->inp_flags2 & INP_FREED))
|
||||
goto skip_2;
|
||||
if (jailed_without_vnet(in6p->inp_cred)) {
|
||||
if (jailed_without_vnet(inp->inp_cred)) {
|
||||
/*
|
||||
* Allow raw socket in jail to receive multicast;
|
||||
* assume process had PRIV_NETINET_RAW at attach,
|
||||
* and fall through into normal filter path if so.
|
||||
*/
|
||||
if (!IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) &&
|
||||
prison_check_ip6(in6p->inp_cred,
|
||||
prison_check_ip6(inp->inp_cred,
|
||||
&ip6->ip6_dst) != 0)
|
||||
goto skip_2;
|
||||
}
|
||||
if (in6p->in6p_cksum != -1) {
|
||||
if (inp->in6p_cksum != -1) {
|
||||
RIP6STAT_INC(rip6s_isum);
|
||||
if (m->m_pkthdr.len - (*offp + in6p->in6p_cksum) < 2 ||
|
||||
if (m->m_pkthdr.len - (*offp + inp->in6p_cksum) < 2 ||
|
||||
in6_cksum(m, proto, *offp,
|
||||
m->m_pkthdr.len - *offp)) {
|
||||
RIP6STAT_INC(rip6s_badsum);
|
||||
@ -258,7 +258,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
* should receive it, as multicast filtering is now
|
||||
* the responsibility of the transport layer.
|
||||
*/
|
||||
if (in6p->in6p_moptions &&
|
||||
if (inp->in6p_moptions &&
|
||||
IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
|
||||
/*
|
||||
* If the incoming datagram is for MLD, allow it
|
||||
@ -288,7 +288,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
mcaddr.sin6_family = AF_INET6;
|
||||
mcaddr.sin6_addr = ip6->ip6_dst;
|
||||
|
||||
blocked = im6o_mc_filter(in6p->in6p_moptions,
|
||||
blocked = im6o_mc_filter(inp->in6p_moptions,
|
||||
ifp,
|
||||
(struct sockaddr *)&mcaddr,
|
||||
(struct sockaddr *)&fromsa);
|
||||
@ -298,10 +298,10 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
goto skip_2;
|
||||
}
|
||||
}
|
||||
last = in6p;
|
||||
last = inp;
|
||||
continue;
|
||||
skip_2:
|
||||
INP_RUNLOCK(in6p);
|
||||
INP_RUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK_ET(&V_ripcbinfo, et);
|
||||
#if defined(IPSEC) || defined(IPSEC_SUPPORT)
|
||||
@ -394,7 +394,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
struct m_tag *mtag;
|
||||
struct sockaddr_in6 *dstsock;
|
||||
struct ip6_hdr *ip6;
|
||||
struct inpcb *in6p;
|
||||
struct inpcb *inp;
|
||||
u_int plen = m->m_pkthdr.len;
|
||||
int error = 0;
|
||||
struct ip6_pktopts opt, *optp;
|
||||
@ -411,18 +411,18 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
control = va_arg(ap, struct mbuf *);
|
||||
va_end(ap);
|
||||
|
||||
in6p = sotoinpcb(so);
|
||||
INP_WLOCK(in6p);
|
||||
inp = sotoinpcb(so);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
if (control != NULL) {
|
||||
if ((error = ip6_setpktopts(control, &opt,
|
||||
in6p->in6p_outputopts, so->so_cred,
|
||||
inp->in6p_outputopts, so->so_cred,
|
||||
so->so_proto->pr_protocol)) != 0) {
|
||||
goto bad;
|
||||
}
|
||||
optp = &opt;
|
||||
} else
|
||||
optp = in6p->in6p_outputopts;
|
||||
optp = inp->in6p_outputopts;
|
||||
|
||||
/*
|
||||
* Check and convert scope zone ID into internal form.
|
||||
@ -465,12 +465,12 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
/*
|
||||
* Source address selection.
|
||||
*/
|
||||
error = in6_selectsrc_socket(dstsock, optp, in6p, so->so_cred,
|
||||
error = in6_selectsrc_socket(dstsock, optp, inp, so->so_cred,
|
||||
scope_ambiguous, &in6a, &hlim);
|
||||
|
||||
if (error)
|
||||
goto bad;
|
||||
error = prison_check_ip6(in6p->inp_cred, &in6a);
|
||||
error = prison_check_ip6(inp->inp_cred, &in6a);
|
||||
if (error != 0)
|
||||
goto bad;
|
||||
ip6->ip6_src = in6a;
|
||||
@ -481,18 +481,18 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
* Fill in the rest of the IPv6 header fields.
|
||||
*/
|
||||
ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) |
|
||||
(in6p->inp_flow & IPV6_FLOWINFO_MASK);
|
||||
(inp->inp_flow & IPV6_FLOWINFO_MASK);
|
||||
ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) |
|
||||
(IPV6_VERSION & IPV6_VERSION_MASK);
|
||||
|
||||
/*
|
||||
* ip6_plen will be filled in ip6_output, so not fill it here.
|
||||
*/
|
||||
ip6->ip6_nxt = in6p->inp_ip_p;
|
||||
ip6->ip6_nxt = inp->inp_ip_p;
|
||||
ip6->ip6_hlim = hlim;
|
||||
|
||||
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
|
||||
in6p->in6p_cksum != -1) {
|
||||
inp->in6p_cksum != -1) {
|
||||
struct mbuf *n;
|
||||
int off;
|
||||
u_int16_t *p;
|
||||
@ -501,7 +501,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
|
||||
off = offsetof(struct icmp6_hdr, icmp6_cksum);
|
||||
else
|
||||
off = in6p->in6p_cksum;
|
||||
off = inp->in6p_cksum;
|
||||
if (plen < off + 2) {
|
||||
error = EINVAL;
|
||||
goto bad;
|
||||
@ -537,7 +537,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
}
|
||||
}
|
||||
|
||||
error = ip6_output(m, optp, NULL, 0, in6p->in6p_moptions, &oifp, in6p);
|
||||
error = ip6_output(m, optp, NULL, 0, inp->in6p_moptions, &oifp, inp);
|
||||
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
|
||||
if (oifp)
|
||||
icmp6_ifoutstat_inc(oifp, type, code);
|
||||
@ -556,7 +556,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
|
||||
ip6_clearpktopts(&opt, -1);
|
||||
m_freem(control);
|
||||
}
|
||||
INP_WUNLOCK(in6p);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,6 @@ sctp6_abort(struct socket *so)
|
||||
static int
|
||||
sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUSED)
|
||||
{
|
||||
struct in6pcb *inp6;
|
||||
int error;
|
||||
struct sctp_inpcb *inp;
|
||||
uint32_t vrf_id = SCTP_DEFAULT_VRFID;
|
||||
@ -540,18 +539,17 @@ sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNU
|
||||
inp = (struct sctp_inpcb *)so->so_pcb;
|
||||
SCTP_INP_WLOCK(inp);
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6; /* I'm v6! */
|
||||
inp6 = (struct in6pcb *)inp;
|
||||
|
||||
inp6->inp_vflag |= INP_IPV6;
|
||||
inp6->in6p_hops = -1; /* use kernel default */
|
||||
inp6->in6p_cksum = -1; /* just to be sure */
|
||||
inp->ip_inp.inp.inp_vflag |= INP_IPV6;
|
||||
inp->ip_inp.inp.in6p_hops = -1; /* use kernel default */
|
||||
inp->ip_inp.inp.in6p_cksum = -1; /* just to be sure */
|
||||
#ifdef INET
|
||||
/*
|
||||
* XXX: ugly!! IPv4 TTL initialization is necessary for an IPv6
|
||||
* socket as well, because the socket may be bound to an IPv6
|
||||
* wildcard address, which may match an IPv4-mapped IPv6 address.
|
||||
*/
|
||||
inp6->inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
|
||||
inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
|
||||
#endif
|
||||
SCTP_INP_WUNLOCK(inp);
|
||||
return (0);
|
||||
@ -561,7 +559,6 @@ static int
|
||||
sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
|
||||
{
|
||||
struct sctp_inpcb *inp;
|
||||
struct in6pcb *inp6;
|
||||
int error;
|
||||
|
||||
inp = (struct sctp_inpcb *)so->so_pcb;
|
||||
@ -593,16 +590,15 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
|
||||
return (EINVAL);
|
||||
}
|
||||
}
|
||||
inp6 = (struct in6pcb *)inp;
|
||||
inp6->inp_vflag &= ~INP_IPV4;
|
||||
inp6->inp_vflag |= INP_IPV6;
|
||||
if ((addr != NULL) && (SCTP_IPV6_V6ONLY(inp6) == 0)) {
|
||||
inp->ip_inp.inp.inp_vflag &= ~INP_IPV4;
|
||||
inp->ip_inp.inp.inp_vflag |= INP_IPV6;
|
||||
if ((addr != NULL) && (SCTP_IPV6_V6ONLY(&inp->ip_inp.inp) == 0)) {
|
||||
switch (addr->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
/* binding v4 addr to v6 socket, so reset flags */
|
||||
inp6->inp_vflag |= INP_IPV4;
|
||||
inp6->inp_vflag &= ~INP_IPV6;
|
||||
inp->ip_inp.inp.inp_vflag |= INP_IPV4;
|
||||
inp->ip_inp.inp.inp_vflag &= ~INP_IPV6;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
@ -613,15 +609,15 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
|
||||
sin6_p = (struct sockaddr_in6 *)addr;
|
||||
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&sin6_p->sin6_addr)) {
|
||||
inp6->inp_vflag |= INP_IPV4;
|
||||
inp->ip_inp.inp.inp_vflag |= INP_IPV4;
|
||||
}
|
||||
#ifdef INET
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) {
|
||||
struct sockaddr_in sin;
|
||||
|
||||
in6_sin6_2_sin(&sin, sin6_p);
|
||||
inp6->inp_vflag |= INP_IPV4;
|
||||
inp6->inp_vflag &= ~INP_IPV6;
|
||||
inp->ip_inp.inp.inp_vflag |= INP_IPV4;
|
||||
inp->ip_inp.inp.inp_vflag &= ~INP_IPV6;
|
||||
error = sctp_inpcb_bind(so, (struct sockaddr *)&sin, NULL, p);
|
||||
return (error);
|
||||
}
|
||||
@ -683,7 +679,6 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
struct mbuf *control, struct thread *p)
|
||||
{
|
||||
struct sctp_inpcb *inp;
|
||||
struct in6pcb *inp6;
|
||||
|
||||
#ifdef INET
|
||||
struct sockaddr_in6 *sin6;
|
||||
@ -700,7 +695,6 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
|
||||
return (EINVAL);
|
||||
}
|
||||
inp6 = (struct in6pcb *)inp;
|
||||
/*
|
||||
* For the TCP model we may get a NULL addr, if we are a connected
|
||||
* socket thats ok.
|
||||
@ -720,7 +714,7 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
}
|
||||
#ifdef INET
|
||||
sin6 = (struct sockaddr_in6 *)addr;
|
||||
if (SCTP_IPV6_V6ONLY(inp6)) {
|
||||
if (SCTP_IPV6_V6ONLY(inp)) {
|
||||
/*
|
||||
* if IPV6_V6ONLY flag, we discard datagrams destined to a
|
||||
* v4 addr or v4-mapped addr
|
||||
@ -789,14 +783,10 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
|
||||
struct sctp_inpcb *inp;
|
||||
struct sctp_tcb *stcb;
|
||||
#ifdef INET
|
||||
struct in6pcb *inp6;
|
||||
struct sockaddr_in6 *sin6;
|
||||
union sctp_sockstore store;
|
||||
#endif
|
||||
|
||||
#ifdef INET
|
||||
inp6 = (struct in6pcb *)so->so_pcb;
|
||||
#endif
|
||||
inp = (struct sctp_inpcb *)so->so_pcb;
|
||||
if (inp == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ECONNRESET);
|
||||
@ -854,7 +844,7 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
|
||||
}
|
||||
#ifdef INET
|
||||
sin6 = (struct sockaddr_in6 *)addr;
|
||||
if (SCTP_IPV6_V6ONLY(inp6)) {
|
||||
if (SCTP_IPV6_V6ONLY(inp)) {
|
||||
/*
|
||||
* if IPV6_V6ONLY flag, ignore connections destined to a v4
|
||||
* addr or v4-mapped addr
|
||||
@ -1096,10 +1086,10 @@ sctp6_peeraddr(struct socket *so, struct sockaddr **addr)
|
||||
static int
|
||||
sctp6_in6getaddr(struct socket *so, struct sockaddr **nam)
|
||||
{
|
||||
struct in6pcb *inp6 = sotoin6pcb(so);
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
int error;
|
||||
|
||||
if (inp6 == NULL) {
|
||||
if (inp == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
|
||||
return (EINVAL);
|
||||
}
|
||||
@ -1132,10 +1122,10 @@ sctp6_in6getaddr(struct socket *so, struct sockaddr **nam)
|
||||
static int
|
||||
sctp6_getpeeraddr(struct socket *so, struct sockaddr **nam)
|
||||
{
|
||||
struct in6pcb *inp6 = sotoin6pcb(so);
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
int error;
|
||||
|
||||
if (inp6 == NULL) {
|
||||
if (inp == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user