Remove redundant calls of prison_local_ip4 in in_pcbbind_setup, and of
prison_local_ip6 in in6_pcbbind. Approved by: bz (mentor)
This commit is contained in:
parent
c3328b2ab8
commit
7c2f3cb964
@ -313,7 +313,10 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
|
||||
return (EINVAL);
|
||||
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0)
|
||||
wild = INPLOOKUP_WILDCARD;
|
||||
if (nam) {
|
||||
if (nam == NULL) {
|
||||
if ((error = prison_local_ip4(cred, &laddr)) != 0)
|
||||
return (error);
|
||||
} else {
|
||||
sin = (struct sockaddr_in *)nam;
|
||||
if (nam->sa_len != sizeof (*sin))
|
||||
return (EINVAL);
|
||||
@ -392,9 +395,6 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
|
||||
t->inp_cred->cr_uid))
|
||||
return (EADDRINUSE);
|
||||
}
|
||||
error = prison_local_ip4(cred, &sin->sin_addr);
|
||||
if (error)
|
||||
return (error);
|
||||
t = in_pcblookup_local(pcbinfo, sin->sin_addr,
|
||||
lport, wild, cred);
|
||||
if (t && (t->inp_vflag & INP_TIMEWAIT)) {
|
||||
@ -428,10 +428,6 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
|
||||
u_short first, last, aux;
|
||||
int count;
|
||||
|
||||
error = prison_local_ip4(cred, &laddr);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
if (inp->inp_flags & INP_HIGHPORT) {
|
||||
first = V_ipport_hifirstauto; /* sysctl */
|
||||
last = V_ipport_hilastauto;
|
||||
@ -496,9 +492,6 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
|
||||
} while (in_pcblookup_local(pcbinfo, laddr,
|
||||
lport, wild, cred));
|
||||
}
|
||||
error = prison_local_ip4(cred, &laddr);
|
||||
if (error)
|
||||
return (error);
|
||||
*laddrp = laddr.s_addr;
|
||||
*lportp = lport;
|
||||
return (0);
|
||||
|
@ -130,7 +130,11 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
|
||||
return (EINVAL);
|
||||
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0)
|
||||
wild = INPLOOKUP_WILDCARD;
|
||||
if (nam) {
|
||||
if (nam == NULL) {
|
||||
if ((error = prison_local_ip6(cred, &inp->in6p_laddr,
|
||||
((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
|
||||
return (error);
|
||||
} else {
|
||||
sin6 = (struct sockaddr_in6 *)nam;
|
||||
if (nam->sa_len != sizeof(*sin6))
|
||||
return (EINVAL);
|
||||
@ -221,9 +225,6 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
|
||||
return (EADDRINUSE);
|
||||
}
|
||||
}
|
||||
if ((error = prison_local_ip6(cred, &sin6->sin6_addr,
|
||||
((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
|
||||
return (error);
|
||||
t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr,
|
||||
lport, wild, cred);
|
||||
if (t && (reuseport & ((t->inp_vflag & INP_TIMEWAIT) ?
|
||||
@ -256,9 +257,6 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
|
||||
}
|
||||
inp->in6p_laddr = sin6->sin6_addr;
|
||||
}
|
||||
if ((error = prison_local_ip6(cred, &inp->in6p_laddr,
|
||||
((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
|
||||
return (error);
|
||||
if (lport == 0) {
|
||||
if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0)
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user