Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/udp6_usrreq.c
Show First 20 Lines • Show All 1,042 Lines • ▼ Show 20 Lines | if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { | ||||
soisdisconnected(so); | soisdisconnected(so); | ||||
} | } | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
} | } | ||||
static int | static int | ||||
udp6_attach(struct socket *so, int proto, struct thread *td) | udp6_attach(struct socket *so, int proto, struct thread *td) | ||||
{ | { | ||||
static uint32_t udp_flowid; | |||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct inpcbinfo *pcbinfo; | struct inpcbinfo *pcbinfo; | ||||
int error; | int error; | ||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); | pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); | ||||
inp = sotoinpcb(so); | inp = sotoinpcb(so); | ||||
KASSERT(inp == NULL, ("udp6_attach: inp != NULL")); | KASSERT(inp == NULL, ("udp6_attach: inp != NULL")); | ||||
if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { | if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { | ||||
error = soreserve(so, udp_sendspace, udp_recvspace); | error = soreserve(so, udp_sendspace, udp_recvspace); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
INP_INFO_WLOCK(pcbinfo); | INP_INFO_WLOCK(pcbinfo); | ||||
error = in_pcballoc(so, pcbinfo); | error = in_pcballoc(so, pcbinfo); | ||||
if (error) { | if (error) { | ||||
INP_INFO_WUNLOCK(pcbinfo); | INP_INFO_WUNLOCK(pcbinfo); | ||||
return (error); | return (error); | ||||
} | } | ||||
inp = (struct inpcb *)so->so_pcb; | inp = (struct inpcb *)so->so_pcb; | ||||
inp->inp_vflag |= INP_IPV6; | inp->inp_vflag |= INP_IPV6; | ||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) | if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) | ||||
inp->inp_vflag |= INP_IPV4; | inp->inp_vflag |= INP_IPV4; | ||||
inp->inp_flowid = atomic_fetchadd_int(&udp_flowid, 1); | |||||
inp->inp_flowtype = M_HASHTYPE_OPAQUE; | |||||
inp->in6p_hops = -1; /* use kernel default */ | inp->in6p_hops = -1; /* use kernel default */ | ||||
inp->in6p_cksum = -1; /* just to be sure */ | inp->in6p_cksum = -1; /* just to be sure */ | ||||
/* | /* | ||||
* XXX: ugly!! | * XXX: ugly!! | ||||
* IPv4 TTL initialization is necessary for an IPv6 socket as well, | * IPv4 TTL initialization is necessary for an IPv6 socket as well, | ||||
* because the socket may be bound to an IPv6 wildcard address, | * because the socket may be bound to an IPv6 wildcard address, | ||||
* which may match an IPv4-mapped IPv6 address. | * which may match an IPv4-mapped IPv6 address. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 298 Lines • Show Last 20 Lines |