]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[REQSK]: Move the syn_table destroy from tcp_listen_stop to reqsk_queue_destroy
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>
Wed, 10 Aug 2005 02:33:31 +0000 (19:33 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 29 Aug 2005 22:32:11 +0000 (15:32 -0700)
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/request_sock.h
net/core/request_sock.c
net/ipv4/tcp.c

index 72fd6f5e86b19bbb1fc2444620d4764456469403..334717bf9ef691dde632bd437567705a24959ad2 100644 (file)
@@ -89,6 +89,7 @@ struct listen_sock {
        int                     qlen_young;
        int                     clock_hand;
        u32                     hash_rnd;
+       u32                     nr_table_entries;
        struct request_sock     *syn_table[0];
 };
 
@@ -129,11 +130,13 @@ static inline struct listen_sock *reqsk_queue_yank_listen_sk(struct request_sock
        return lopt;
 }
 
-static inline void reqsk_queue_destroy(struct request_sock_queue *queue)
+static inline void __reqsk_queue_destroy(struct request_sock_queue *queue)
 {
        kfree(reqsk_queue_yank_listen_sk(queue));
 }
 
+extern void reqsk_queue_destroy(struct request_sock_queue *queue);
+
 static inline struct request_sock *
        reqsk_queue_yank_acceptq(struct request_sock_queue *queue)
 {
index bb55675f0685e1a52accb47c734d1b2f8eb6368d..4e99ce5c08f2c5fe44fbcf94c236a5c35ef51418 100644 (file)
@@ -53,6 +53,7 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
        get_random_bytes(&lopt->hash_rnd, sizeof(lopt->hash_rnd));
        rwlock_init(&queue->syn_wait_lock);
        queue->rskq_accept_head = queue->rskq_accept_head = NULL;
+       lopt->nr_table_entries = nr_table_entries;
 
        write_lock_bh(&queue->syn_wait_lock);
        queue->listen_opt = lopt;
@@ -62,3 +63,28 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
 }
 
 EXPORT_SYMBOL(reqsk_queue_alloc);
+
+void reqsk_queue_destroy(struct request_sock_queue *queue)
+{
+       /* make all the listen_opt local to us */
+       struct listen_sock *lopt = reqsk_queue_yank_listen_sk(queue);
+
+       if (lopt->qlen != 0) {
+               int i;
+
+               for (i = 0; i < lopt->nr_table_entries; i++) {
+                       struct request_sock *req;
+
+                       while ((req = lopt->syn_table[i]) != NULL) {
+                               lopt->syn_table[i] = req->dl_next;
+                               lopt->qlen--;
+                               reqsk_free(req);
+                       }
+               }
+       }
+
+       BUG_TRAP(lopt->qlen == 0);
+       kfree(lopt);
+}
+
+EXPORT_SYMBOL(reqsk_queue_destroy);
index d2696af46c70edfe27bd1fba4868921b74b05c51..42a2e2ccd4303852e27eb6ef8a582e37294765f6 100644 (file)
@@ -487,7 +487,7 @@ int tcp_listen_start(struct sock *sk)
        }
 
        sk->sk_state = TCP_CLOSE;
-       reqsk_queue_destroy(&tp->accept_queue);
+       __reqsk_queue_destroy(&tp->accept_queue);
        return -EADDRINUSE;
 }
 
@@ -499,38 +499,23 @@ int tcp_listen_start(struct sock *sk)
 static void tcp_listen_stop (struct sock *sk)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       struct listen_sock *lopt;
        struct request_sock *acc_req;
        struct request_sock *req;
-       int i;
 
        tcp_delete_keepalive_timer(sk);
 
        /* make all the listen_opt local to us */
-       lopt = reqsk_queue_yank_listen_sk(&tp->accept_queue);
        acc_req = reqsk_queue_yank_acceptq(&tp->accept_queue);
 
-       if (lopt->qlen) {
-               for (i = 0; i < TCP_SYNQ_HSIZE; i++) {
-                       while ((req = lopt->syn_table[i]) != NULL) {
-                               lopt->syn_table[i] = req->dl_next;
-                               lopt->qlen--;
-                               reqsk_free(req);
-
-               /* Following specs, it would be better either to send FIN
-                * (and enter FIN-WAIT-1, it is normal close)
-                * or to send active reset (abort).
-                * Certainly, it is pretty dangerous while synflood, but it is
-                * bad justification for our negligence 8)
-                * To be honest, we are not able to make either
-                * of the variants now.                 --ANK
-                */
-                       }
-               }
-       }
-       BUG_TRAP(!lopt->qlen);
-
-       kfree(lopt);
+       /* Following specs, it would be better either to send FIN
+        * (and enter FIN-WAIT-1, it is normal close)
+        * or to send active reset (abort).
+        * Certainly, it is pretty dangerous while synflood, but it is
+        * bad justification for our negligence 8)
+        * To be honest, we are not able to make either
+        * of the variants now.                 --ANK
+        */
+       reqsk_queue_destroy(&tp->accept_queue);
 
        while ((req = acc_req) != NULL) {
                struct sock *child = req->sk;