From: Sepherosa Ziehau Date: Sun, 16 Mar 2014 11:34:18 +0000 (+0800) Subject: inpcb/in6pcb: in_pcbinsporthash() never fails X-Git-Tag: v3.9.0~306 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/05e43c265737203ef2e666d2f8488933d6d94584 inpcb/in6pcb: in_pcbinsporthash() never fails --- diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 1bd6076807..6297fcc019 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -498,13 +498,7 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td) } } inp->inp_lport = lport; - - if (in_pcbinsporthash(inp) != 0) { - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_lport = 0; - error = EAGAIN; - goto done; - } + in_pcbinsporthash(inp); error = 0; done: if (pcbinfo->porttoken) @@ -689,13 +683,7 @@ again: goto again; } inp->inp_lport = lport; - - if (in_pcbinsporthash(inp) != 0) { - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_lport = 0; - error = EAGAIN; - goto done; - } + in_pcbinsporthash(inp); error = 0; done: if (pcbinfo->porttoken) @@ -1510,7 +1498,7 @@ in_pcbremconnhash(struct inpcb *inp) /* * Insert PCB into port hash table. */ -int +void in_pcbinsporthash(struct inpcb *inp) { struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; @@ -1555,7 +1543,6 @@ in_pcbinsporthash(struct inpcb *inp) pcbinfo->portsave = kmalloc(sizeof(*pcbinfo->portsave), M_PCB, M_INTWAIT | M_ZERO); } - return (0); } static struct inp_localgroup * diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 807b48359b..f83982b370 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -436,7 +436,7 @@ void in_pcbdisconnect (struct inpcb *); void in_pcbinswildcardhash(struct inpcb *inp); void in_pcbinswildcardhash_oncpu(struct inpcb *, struct inpcbinfo *); void in_pcbinsconnhash(struct inpcb *inp); -int in_pcbinsporthash (struct inpcb *); +void in_pcbinsporthash (struct inpcb *); int in_pcbladdr (struct inpcb *, struct sockaddr *, struct sockaddr_in **, struct thread *); int in_pcbladdr_find (struct inpcb *, struct sockaddr *, diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 5e7816e683..1c991350a4 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -765,18 +765,8 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) inp->inp_laddr = sc->sc_inc.inc_laddr; } inp->inp_lport = sc->sc_inc.inc_lport; - if (in_pcbinsporthash(inp) != 0) { - /* - * Undo the assignments above if we failed to - * put the PCB on the hash lists. - */ - if (isipv6) - inp->in6p_laddr = kin6addr_any; - else - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_lport = 0; - goto abort; - } + in_pcbinsporthash(inp); + linp = lso->so_pcb; #ifdef IPSEC /* copy old policy into new socket's */ diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 0b73889b8f..37803316ca 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -311,12 +311,7 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct thread *td) } else { inp->inp_lport = lport; - if (in_pcbinsporthash(inp) != 0) { - inp->in6p_laddr = kin6addr_any; - inp->inp_lport = 0; - error = EAGAIN; - goto done; - } + in_pcbinsporthash(inp); } error = 0; done: diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index e93e226e4f..95d29a0796 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -487,12 +487,7 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct thread *td) } inp->inp_lport = lport; - if (in_pcbinsporthash(inp) != 0) { - inp->in6p_laddr = kin6addr_any; - inp->inp_lport = 0; - error = EAGAIN; - goto done; - } + in_pcbinsporthash(inp); error = 0; done: if (pcbinfo->porttoken)