inpcb/in6pcb: in_pcbinsporthash() never fails
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 16 Mar 2014 11:34:18 +0000 (19:34 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 16 Mar 2014 11:34:18 +0000 (19:34 +0800)
sys/netinet/in_pcb.c
sys/netinet/in_pcb.h
sys/netinet/tcp_syncache.c
sys/netinet6/in6_pcb.c
sys/netinet6/in6_src.c

index 1bd6076..6297fcc 100644 (file)
@@ -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 *
index 807b483..f83982b 100644 (file)
@@ -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 *,
index 5e7816e..1c99135 100644 (file)
@@ -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 */
index 0b73889..3780331 100644 (file)
@@ -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:
index e93e226..95d29a0 100644 (file)
@@ -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)