l2tp: use skb_queue_purge in l2tp_ip_destroy_sock
authorJames Chapman <jchapman@katalix.com>
Mon, 19 Aug 2024 14:33:33 +0000 (15:33 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 20 Aug 2024 23:52:28 +0000 (16:52 -0700)
Recent commit ed8ebee6def7 ("l2tp: have l2tp_ip_destroy_sock use
ip_flush_pending_frames") was incorrect in that l2tp_ip does not use
socket cork and ip_flush_pending_frames is for sockets that do. Use
__skb_queue_purge instead and remove the unnecessary lock.

Also unexport ip_flush_pending_frames since it was originally exported
in commit 4ff8863419cd ("ipv4: export ip_flush_pending_frames") for
l2tp and is not used by other modules.

Suggested-by: xiyou.wangcong@gmail.com
Signed-off-by: James Chapman <jchapman@katalix.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240819143333.3204957-1-jchapman@katalix.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/ip_output.c
net/l2tp/l2tp_ip.c

index 8a10a7c67834fe870d01ce850ebeacc72120f180..b90d0f78ac8080f6e5aba2382b11075253f85d61 100644 (file)
@@ -1534,7 +1534,6 @@ void ip_flush_pending_frames(struct sock *sk)
 {
        __ip_flush_pending_frames(sk, &sk->sk_write_queue, &inet_sk(sk)->cork.base);
 }
-EXPORT_SYMBOL_GPL(ip_flush_pending_frames);
 
 struct sk_buff *ip_make_skb(struct sock *sk,
                            struct flowi4 *fl4,
index 39f3f1334c4aa87653c1d0265cec2f5f3eee840f..4bc24fddfd52424b08cb78bc0125a3e698021e8c 100644 (file)
@@ -258,9 +258,7 @@ static void l2tp_ip_destroy_sock(struct sock *sk)
 {
        struct l2tp_tunnel *tunnel;
 
-       lock_sock(sk);
-       ip_flush_pending_frames(sk);
-       release_sock(sk);
+       __skb_queue_purge(&sk->sk_write_queue);
 
        tunnel = l2tp_sk_to_tunnel(sk);
        if (tunnel) {