Skip to content

Commit

Permalink
Remove redundant calls of prison_local_ip4 in in_pcbbind_setup, and of
Browse files Browse the repository at this point in the history
prison_local_ip6 in in6_pcbbind.

Approved by:	bz (mentor)
  • Loading branch information
jamie authored and jamie committed Feb 5, 2009
1 parent e085cfc commit bbcda54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
15 changes: 4 additions & 11 deletions sys/netinet/in_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions sys/netinet6/in6_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) ?
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bbcda54

Please sign in to comment.