ipv4: Don't add TCP-code in inet_sock_destruct
authorChristoph Paasch <christoph.paasch@uclouvain.be>
Tue, 18 Sep 2012 14:19:23 +0000 (14:19 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Sep 2012 21:12:27 +0000 (17:12 -0400)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Acked-by: H.K. Jerry Chu <hkchu@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/tcp.h
net/ipv4/af_inet.c
net/ipv4/tcp.c

index ae46df590629075b8d334735de95408ffca5d593..67c789ae719c7f6216870db74df3afc0223de66b 100644 (file)
@@ -574,6 +574,8 @@ static inline bool fastopen_cookie_present(struct tcp_fastopen_cookie *foc)
        return foc->len != -1;
 }
 
+extern void tcp_sock_destruct(struct sock *sk);
+
 static inline int fastopen_init_queue(struct sock *sk, int backlog)
 {
        struct request_sock_queue *queue =
@@ -585,6 +587,8 @@ static inline int fastopen_init_queue(struct sock *sk, int backlog)
                    sk->sk_allocation);
                if (queue->fastopenq == NULL)
                        return -ENOMEM;
+
+               sk->sk_destruct = tcp_sock_destruct;
                spin_lock_init(&queue->fastopenq->lock);
        }
        queue->fastopenq->max_qlen = backlog;
index 845372b025f6819298bf9ffbef86d2fd3a7e0d1e..766c596585631e1001bdd64c80639554c6ab7831 100644 (file)
@@ -149,8 +149,6 @@ void inet_sock_destruct(struct sock *sk)
                pr_err("Attempt to release alive inet socket %p\n", sk);
                return;
        }
-       if (sk->sk_protocol == IPPROTO_TCP)
-               kfree(inet_csk(sk)->icsk_accept_queue.fastopenq);
 
        WARN_ON(atomic_read(&sk->sk_rmem_alloc));
        WARN_ON(atomic_read(&sk->sk_wmem_alloc));
index df83d744e380f6d72dafe25bff7fe6e4382641e8..7b1e940393cf51aca7baacb5e3ec36d8e6428d67 100644 (file)
@@ -2325,6 +2325,13 @@ int tcp_disconnect(struct sock *sk, int flags)
 }
 EXPORT_SYMBOL(tcp_disconnect);
 
+void tcp_sock_destruct(struct sock *sk)
+{
+       inet_sock_destruct(sk);
+
+       kfree(inet_csk(sk)->icsk_accept_queue.fastopenq);
+}
+
 static inline bool tcp_can_repair_sock(const struct sock *sk)
 {
        return capable(CAP_NET_ADMIN) &&