Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/in6_pcb.c
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
return (EADDRNOTAVAIL); | return (EADDRNOTAVAIL); | ||||
} | } | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
} | } | ||||
if (lport) { | if (lport) { | ||||
struct inpcb *t; | struct inpcb *t; | ||||
/* GROSS */ | |||||
if (ntohs(lport) <= V_ipport_reservedhigh && | if (ntohs(lport) <= V_ipport_reservedhigh && | ||||
ntohs(lport) >= V_ipport_reservedlow && | ntohs(lport) >= V_ipport_reservedlow && | ||||
priv_check_cred(cred, PRIV_NETINET_RESERVEDPORT)) | priv_check_cred(cred, PRIV_NETINET_RESERVEDPORT)) | ||||
return (EACCES); | return (EACCES); | ||||
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) && | if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) && | ||||
priv_check_cred(inp->inp_cred, PRIV_NETINET_REUSEPORT) != 0) { | priv_check_cred(inp->inp_cred, PRIV_NETINET_REUSEPORT) != 0) { | ||||
t = in6_pcblookup_local(pcbinfo, | t = in6_pcblookup_local(pcbinfo, | ||||
&sin6->sin6_addr, lport, | &sin6->sin6_addr, lport, | ||||
INPLOOKUP_WILDCARD, cred); | INPLOOKUP_WILDCARD, cred); | ||||
if (t != NULL && | if (t != NULL && | ||||
(so->so_type != SOCK_STREAM || | (so->so_type != SOCK_STREAM || | ||||
IN6_IS_ADDR_UNSPECIFIED(&t->in6p_faddr)) && | IN6_IS_ADDR_UNSPECIFIED(&t->in6p_faddr)) && | ||||
Show All 11 Lines | #ifdef INET | ||||
struct sockaddr_in sin; | struct sockaddr_in sin; | ||||
in6_sin6_2_sin(&sin, sin6); | in6_sin6_2_sin(&sin, sin6); | ||||
t = in_pcblookup_local(pcbinfo, | t = in_pcblookup_local(pcbinfo, | ||||
sin.sin_addr, lport, | sin.sin_addr, lport, | ||||
INPLOOKUP_WILDCARD, cred); | INPLOOKUP_WILDCARD, cred); | ||||
if (t != NULL && | if (t != NULL && | ||||
(so->so_type != SOCK_STREAM || | (so->so_type != SOCK_STREAM || | ||||
ntohl(t->inp_faddr.s_addr) == | in_nullhost(t->inp_faddr)) && | ||||
INADDR_ANY) && | |||||
(inp->inp_cred->cr_uid != | (inp->inp_cred->cr_uid != | ||||
t->inp_cred->cr_uid)) | t->inp_cred->cr_uid)) | ||||
return (EADDRINUSE); | return (EADDRINUSE); | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, | t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, | ||||
lport, lookupflags, cred); | lport, lookupflags, cred); | ||||
if (t && (reuseport & t->inp_socket->so_options) == 0 && | if (t != NULL && ((reuseport | reuseport_lb) & | ||||
(reuseport_lb & t->inp_socket->so_options) == 0) { | t->inp_socket->so_options) == 0) | ||||
return (EADDRINUSE); | return (EADDRINUSE); | ||||
} | |||||
#ifdef INET | #ifdef INET | ||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 && | if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 && | ||||
IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { | IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { | ||||
struct sockaddr_in sin; | struct sockaddr_in sin; | ||||
in6_sin6_2_sin(&sin, sin6); | in6_sin6_2_sin(&sin, sin6); | ||||
t = in_pcblookup_local(pcbinfo, sin.sin_addr, | t = in_pcblookup_local(pcbinfo, sin.sin_addr, | ||||
lport, lookupflags, cred); | lport, lookupflags, cred); | ||||
if (t && | if (t != NULL && ((reuseport | reuseport_lb) & | ||||
(reuseport & t->inp_socket->so_options) == 0 && | t->inp_socket->so_options) == 0 && | ||||
(reuseport_lb & t->inp_socket->so_options) == 0 && | (!in_nullhost(t->inp_laddr) || | ||||
(ntohl(t->inp_laddr.s_addr) != INADDR_ANY || | |||||
(t->inp_vflag & INP_IPV6PROTO) != 0)) { | (t->inp_vflag & INP_IPV6PROTO) != 0)) { | ||||
return (EADDRINUSE); | return (EADDRINUSE); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
inp->in6p_laddr = sin6->sin6_addr; | inp->in6p_laddr = sin6->sin6_addr; | ||||
} | } | ||||
if (lport == 0) { | if (lport == 0) { | ||||
▲ Show 20 Lines • Show All 931 Lines • Show Last 20 Lines |