inpcb: Exclusive the usage of wildcard hash and connect hash
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 21 Feb 2011 02:52:20 +0000 (10:52 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 21 Feb 2011 02:52:20 +0000 (10:52 +0800)
DragonFly-bug: http://bugs.dragonflybsd.org/issue1993

sys/netinet/in_pcb.c
sys/netinet/tcp_usrreq.c

index e82671b..7d4d269 100644 (file)
@@ -1171,7 +1171,10 @@ in_pcbinsconnhash(struct inpcb *inp)
        }
 #endif
 
-       KASSERT(!(inp->inp_flags & INP_CONNECTED), ("already on hash list"));
+       KASSERT(!(inp->inp_flags & INP_WILDCARD),
+               ("already on wildcardhash\n"));
+       KASSERT(!(inp->inp_flags & INP_CONNECTED),
+               ("already on connhash\n"));
        inp->inp_flags |= INP_CONNECTED;
 
        /*
@@ -1265,11 +1268,14 @@ void
 in_pcbinswildcardhash(struct inpcb *inp)
 {
        struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
-       
-       KKASSERT(pcbinfo != NULL);
 
-       in_pcbinswildcardhash_oncpu(inp, pcbinfo);
+       KASSERT(!(inp->inp_flags & INP_CONNECTED),
+               ("already on connhash\n"));
+       KASSERT(!(inp->inp_flags & INP_WILDCARD),
+               ("already on wildcardhash\n"));
        inp->inp_flags |= INP_WILDCARD;
+
+       in_pcbinswildcardhash_oncpu(inp, pcbinfo);
 }
 
 void
index 386096b..504fb81 100644 (file)
@@ -395,6 +395,12 @@ tcp_usr_listen(netmsg_t msg)
                 * We have to set the flag because we can't have other cpus
                 * messing with our inp's flags.
                 */
+               KASSERT(!(inp->inp_flags & INP_CONNECTED),
+                       ("already on connhash\n"));
+               KASSERT(!(inp->inp_flags & INP_WILDCARD),
+                       ("already on wildcardhash\n"));
+               KASSERT(!(inp->inp_flags & INP_WILDCARD_MP),
+                       ("already on MP wildcardhash\n"));
                inp->inp_flags |= INP_WILDCARD_MP;
 
                KKASSERT(so->so_port == cpu_portfn(0));
@@ -446,6 +452,12 @@ tcp6_usr_listen(netmsg_t msg)
                 * We have to set the flag because we can't have other cpus
                 * messing with our inp's flags.
                 */
+               KASSERT(!(inp->inp_flags & INP_CONNECTED),
+                       ("already on connhash\n"));
+               KASSERT(!(inp->inp_flags & INP_WILDCARD),
+                       ("already on wildcardhash\n"));
+               KASSERT(!(inp->inp_flags & INP_WILDCARD_MP),
+                       ("already on MP wildcardhash\n"));
                inp->inp_flags |= INP_WILDCARD_MP;
 
                KKASSERT(so->so_port == cpu_portfn(0));