Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in_pcb.c
Show First 20 Lines • Show All 648 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
#ifdef INET | #ifdef INET | ||||
int | int | ||||
in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) | in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) | ||||
{ | { | ||||
int anonport, error; | int anonport, error; | ||||
KASSERT(nam == NULL || nam->sa_family == AF_INET, | |||||
Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||
("%s: invalid address family for %p", __func__, nam)); | |||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||
KASSERT(nam == NULL || nam->sa_len == sizeof(struct sockaddr_in), | |||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||
("%s: invalid address length for %p", __func__, nam)); | |||||
Lint: Possible Spelling Mistake Possible spelling error. You wrote 'nam', but did you mean 'name'? Lint: Possible Spelling Mistake: Possible spelling error. You wrote 'nam', but did you mean 'name'? | |||||
INP_WLOCK_ASSERT(inp); | INP_WLOCK_ASSERT(inp); | ||||
INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); | INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); | ||||
if (inp->inp_lport != 0 || inp->inp_laddr.s_addr != INADDR_ANY) | if (inp->inp_lport != 0 || inp->inp_laddr.s_addr != INADDR_ANY) | ||||
return (EINVAL); | return (EINVAL); | ||||
anonport = nam == NULL || ((struct sockaddr_in *)nam)->sin_port == 0; | anonport = nam == NULL || ((struct sockaddr_in *)nam)->sin_port == 0; | ||||
error = in_pcbbind_setup(inp, nam, &inp->inp_laddr.s_addr, | error = in_pcbbind_setup(inp, nam, &inp->inp_laddr.s_addr, | ||||
&inp->inp_lport, cred); | &inp->inp_lport, cred); | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | if (nam != NULL && laddr.s_addr != INADDR_ANY) | ||||
return (EINVAL); | return (EINVAL); | ||||
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT|SO_REUSEPORT_LB)) == 0) | if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT|SO_REUSEPORT_LB)) == 0) | ||||
lookupflags = INPLOOKUP_WILDCARD; | lookupflags = INPLOOKUP_WILDCARD; | ||||
if (nam == NULL) { | if (nam == NULL) { | ||||
if ((error = prison_local_ip4(cred, &laddr)) != 0) | if ((error = prison_local_ip4(cred, &laddr)) != 0) | ||||
return (error); | return (error); | ||||
} else { | } else { | ||||
sin = (struct sockaddr_in *)nam; | sin = (struct sockaddr_in *)nam; | ||||
if (nam->sa_len != sizeof (*sin)) | KASSERT(sin->sin_family == AF_INET, | ||||
return (EINVAL); | ("%s: invalid family for address %p", __func__, sin)); | ||||
#ifdef notdef | KASSERT(sin->sin_len == sizeof(*sin), | ||||
/* | ("%s: invalid length for address %p", __func__, sin)); | ||||
* We should check the family, but old programs | |||||
* incorrectly fail to initialize it. | |||||
*/ | |||||
if (sin->sin_family != AF_INET) | |||||
return (EAFNOSUPPORT); | |||||
#endif | |||||
error = prison_local_ip4(cred, &sin->sin_addr); | error = prison_local_ip4(cred, &sin->sin_addr); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
if (sin->sin_port != *lportp) { | if (sin->sin_port != *lportp) { | ||||
/* Don't allow the port to change. */ | /* Don't allow the port to change. */ | ||||
if (*lportp != 0) | if (*lportp != 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
lport = sin->sin_port; | lport = sin->sin_port; | ||||
▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam, | ||||
struct rm_priotracker in_ifa_tracker; | struct rm_priotracker in_ifa_tracker; | ||||
struct sockaddr_in *sin = (struct sockaddr_in *)nam; | struct sockaddr_in *sin = (struct sockaddr_in *)nam; | ||||
struct in_ifaddr *ia; | struct in_ifaddr *ia; | ||||
struct inpcb *oinp; | struct inpcb *oinp; | ||||
struct in_addr laddr, faddr; | struct in_addr laddr, faddr; | ||||
u_short lport, fport; | u_short lport, fport; | ||||
int error; | int error; | ||||
KASSERT(sin->sin_family == AF_INET, | |||||
("%s: invalid address family for %p", __func__, sin)); | |||||
KASSERT(sin->sin_len == sizeof(*sin), | |||||
("%s: invalid address length for %p", __func__, sin)); | |||||
/* | /* | ||||
* Because a global state change doesn't actually occur here, a read | * Because a global state change doesn't actually occur here, a read | ||||
* lock is sufficient. | * lock is sufficient. | ||||
*/ | */ | ||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
INP_LOCK_ASSERT(inp); | INP_LOCK_ASSERT(inp); | ||||
INP_HASH_LOCK_ASSERT(inp->inp_pcbinfo); | INP_HASH_LOCK_ASSERT(inp->inp_pcbinfo); | ||||
if (oinpp != NULL) | if (oinpp != NULL) | ||||
*oinpp = NULL; | *oinpp = NULL; | ||||
if (nam->sa_len != sizeof (*sin)) | |||||
return (EINVAL); | |||||
if (sin->sin_family != AF_INET) | |||||
return (EAFNOSUPPORT); | |||||
if (sin->sin_port == 0) | if (sin->sin_port == 0) | ||||
return (EADDRNOTAVAIL); | return (EADDRNOTAVAIL); | ||||
laddr.s_addr = *laddrp; | laddr.s_addr = *laddrp; | ||||
lport = *lportp; | lport = *lportp; | ||||
faddr = sin->sin_addr; | faddr = sin->sin_addr; | ||||
fport = sin->sin_port; | fport = sin->sin_port; | ||||
#ifdef ROUTE_MPATH | #ifdef ROUTE_MPATH | ||||
if (CALC_FLOWID_OUTBOUND) { | if (CALC_FLOWID_OUTBOUND) { | ||||
▲ Show 20 Lines • Show All 2,201 Lines • Show Last 20 Lines |
Possible spelling error. You wrote 'nam', but did you mean 'name'?