Revert r313527

Heh svn is not git
This commit is contained in:
Ermal Luçi 2017-02-10 05:58:16 +00:00
parent c0fadfdbbf
commit 4616026faf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313528
8 changed files with 28 additions and 59 deletions

View File

@ -371,8 +371,8 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred)
*/
#if defined(INET) || defined(INET6)
int
in_pcb_lport(struct inpcb *inp, struct sockaddr *nam, struct in_addr *laddrp,
u_short *lportp, struct ucred *cred, int lookupflags)
in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp,
struct ucred *cred, int lookupflags)
{
struct inpcbinfo *pcbinfo;
struct inpcb *tmpinp;
@ -381,7 +381,6 @@ in_pcb_lport(struct inpcb *inp, struct sockaddr *nam, struct in_addr *laddrp,
u_short aux, first, last, lport;
#ifdef INET
struct in_addr laddr;
struct sockaddr_in *sin = NULL;
#endif
pcbinfo = inp->inp_pcbinfo;
@ -448,7 +447,6 @@ in_pcb_lport(struct inpcb *inp, struct sockaddr *nam, struct in_addr *laddrp,
KASSERT(laddrp != NULL, ("%s: laddrp NULL for v4 inp %p",
__func__, inp));
laddr = *laddrp;
sin = (struct sockaddr_in *)nam;
}
#endif
tmpinp = NULL; /* Make compiler happy. */
@ -468,29 +466,16 @@ in_pcb_lport(struct inpcb *inp, struct sockaddr *nam, struct in_addr *laddrp,
lport = htons(*lastport);
#ifdef INET6
if ((inp->inp_vflag & INP_IPV6) != 0) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
if (sin6 != NULL && (inp->inp_flags & INP_ANONPORT)) {
tmpinp = in6_pcblookup_hash_locked(pcbinfo,
&sin6->sin6_addr, sin6->sin6_port,
&inp->in6p_laddr, lport,
lookupflags & (~INPLOOKUP_WILDCARD),
NULL);
} else
tmpinp = in6_pcblookup_local(pcbinfo,
&inp->in6p_laddr, lport, lookupflags, cred);
}
if ((inp->inp_vflag & INP_IPV6) != 0)
tmpinp = in6_pcblookup_local(pcbinfo,
&inp->in6p_laddr, lport, lookupflags, cred);
#endif
#if defined(INET) && defined(INET6)
else
#endif
#ifdef INET
if (sin != NULL && (inp->inp_flags & INP_ANONPORT))
tmpinp = in_pcblookup_hash_locked(pcbinfo, sin->sin_addr, sin->sin_port, laddr,
lport, lookupflags & (~INPLOOKUP_WILDCARD), NULL);
else
tmpinp = in_pcblookup_local(pcbinfo, laddr,
lport, lookupflags, cred);
tmpinp = in_pcblookup_local(pcbinfo, laddr,
lport, lookupflags, cred);
#endif
} while (tmpinp != NULL);
@ -586,7 +571,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
return (EINVAL);
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0)
lookupflags = INPLOOKUP_WILDCARD;
if (nam == NULL || ((*lportp) == 0 && (inp->inp_flags & INP_ANONPORT))) {
if (nam == NULL) {
if ((error = prison_local_ip4(cred, &laddr)) != 0)
return (error);
} else {
@ -707,7 +692,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
if (*lportp != 0)
lport = *lportp;
if (lport == 0) {
error = in_pcb_lport(inp, nam, &laddr, &lport, cred, lookupflags);
error = in_pcb_lport(inp, &laddr, &lport, cred, lookupflags);
if (error != 0)
return (error);

View File

@ -697,8 +697,8 @@ void in_pcbgroup_update_mbuf(struct inpcb *, struct mbuf *);
void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
int in_pcballoc(struct socket *, struct inpcbinfo *);
int in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *);
int in_pcb_lport(struct inpcb *, struct sockaddr *, struct in_addr *,
u_short *, struct ucred *, int);
int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,
struct ucred *, int);
int in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *,
u_short *, struct ucred *);
int in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *);

View File

@ -1238,12 +1238,9 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
INP_HASH_WLOCK(&V_tcbinfo);
if (inp->inp_lport == 0) {
inp->inp_flags |= INP_ANONPORT;
error = in_pcbbind(inp, nam, td->td_ucred);
if (error) {
inp->inp_flags &= ~INP_ANONPORT;
error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
if (error)
goto out;
}
}
/*
@ -1299,12 +1296,9 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
INP_HASH_WLOCK(&V_tcbinfo);
if (inp->inp_lport == 0) {
inp->inp_flags |= INP_ANONPORT;
error = in6_pcbbind(inp, nam, td->td_ucred);
if (error) {
inp->inp_flags &= ~INP_ANONPORT;
error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
if (error)
goto out;
}
}
error = in6_pcbconnect(inp, nam, td->td_ucred);
if (error != 0)

View File

@ -636,7 +636,7 @@ udp_input(struct mbuf **mp, int *offp, int proto)
goto badunlocked;
}
UDP_PROBE(receive, NULL, last, ip, last, uh);
if (udp_append(last, ip, m, iphlen, udpin) == 0)
if (udp_append(last, ip, m, iphlen, udp_in) == 0)
INP_RUNLOCK(last);
inp_lost:
INP_INFO_RUNLOCK(pcbinfo);

View File

@ -132,7 +132,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
return (EINVAL);
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0)
lookupflags = INPLOOKUP_WILDCARD;
if (nam == NULL || (inp->inp_flags & INP_ANONPORT)) {
if (nam == NULL) {
if ((error = prison_local_ip6(cred, &inp->in6p_laddr,
((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0)
return (error);
@ -296,7 +296,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
inp->in6p_laddr = sin6->sin6_addr;
}
if (lport == 0) {
if ((error = in6_pcbsetport(nam, &inp->in6p_laddr, inp, cred)) != 0) {
if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) {
/* Undo an address bind that may have occurred. */
inp->in6p_laddr = in6addr_any;
return (error);
@ -416,12 +416,9 @@ in6_pcbconnect_mbuf(register struct inpcb *inp, struct sockaddr *nam,
}
if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {
if (inp->inp_lport == 0) {
inp->inp_flags |= INP_ANONPORT;
error = in6_pcbbind(inp, nam, cred);
if (error) {
inp->inp_flags &= ~INP_ANONPORT;
error = in6_pcbbind(inp, (struct sockaddr *)0, cred);
if (error)
return (error);
}
}
inp->in6p_laddr = addr6;
}

View File

@ -112,8 +112,7 @@ int in6_getsockaddr(struct socket *so, struct sockaddr **nam);
int in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam);
int in6_mapped_peeraddr(struct socket *so, struct sockaddr **nam);
int in6_selecthlim(struct in6pcb *, struct ifnet *);
int in6_pcbsetport(struct sockaddr *, struct in6_addr *, struct inpcb *,
struct ucred *);
int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *);
void init_sin6(struct sockaddr_in6 *sin6, struct mbuf *m, int);
#endif /* _KERNEL */

View File

@ -956,8 +956,7 @@ in6_selecthlim(struct inpcb *in6p, struct ifnet *ifp)
* share this function by all *bsd*...
*/
int
in6_pcbsetport(struct sockaddr *nam6, struct in6_addr *laddr, struct inpcb *inp,
struct ucred *cred)
in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred)
{
struct socket *so = inp->inp_socket;
u_int16_t lport = 0;
@ -980,7 +979,7 @@ in6_pcbsetport(struct sockaddr *nam6, struct in6_addr *laddr, struct inpcb *inp,
inp->inp_flags |= INP_ANONPORT;
error = in_pcb_lport(inp, nam6, NULL, &lport, cred, lookupflags);
error = in_pcb_lport(inp, NULL, &lport, cred, lookupflags);
if (error != 0)
return (error);

View File

@ -778,16 +778,11 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6,
error = EADDRNOTAVAIL;
goto release;
}
if (inp->inp_lport == 0) {
inp->inp_flags |= INP_ANONPORT;
error = in6_pcbsetport((struct sockaddr *)addr6, laddr,
inp, td->td_ucred);
if (error) {
inp->inp_flags &= ~INP_ANONPORT;
/* Undo an address bind that may have occurred. */
inp->in6p_laddr = in6addr_any;
goto release;
}
if (inp->inp_lport == 0 &&
(error = in6_pcbsetport(laddr, inp, td->td_ucred)) != 0) {
/* Undo an address bind that may have occurred. */
inp->in6p_laddr = in6addr_any;
goto release;
}
} else {
if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {