]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mptcp: add eat_recv_skb helper
authorGeliang Tang <tanggeliang@kylinos.cn>
Fri, 30 Jan 2026 19:24:24 +0000 (20:24 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 3 Feb 2026 02:15:31 +0000 (18:15 -0800)
This patch extracts the free skb related code in __mptcp_recvmsg_mskq()
into a new helper mptcp_eat_recv_skb().

This new helper will be used in the next patch.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260130-net-next-mptcp-splice-v2-1-31332ba70d7f@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mptcp/protocol.c

index 8d323366741810c0d472b433bc9be8457cd7279e..5eb2a6182d4bcf7689d06fb1074e4cb4bc76d50b 100644 (file)
@@ -1995,6 +1995,17 @@ do_error:
 
 static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied);
 
+static void mptcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)
+{
+       /* avoid the indirect call, we know the destructor is sock_rfree */
+       skb->destructor = NULL;
+       skb->sk = NULL;
+       atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
+       sk_mem_uncharge(sk, skb->truesize);
+       __skb_unlink(skb, &sk->sk_receive_queue);
+       skb_attempt_defer_free(skb);
+}
+
 static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
                                size_t len, int flags, int copied_total,
                                struct scm_timestamping_internal *tss,
@@ -2049,13 +2060,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
                                break;
                        }
 
-                       /* avoid the indirect call, we know the destructor is sock_rfree */
-                       skb->destructor = NULL;
-                       skb->sk = NULL;
-                       atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
-                       sk_mem_uncharge(sk, skb->truesize);
-                       __skb_unlink(skb, &sk->sk_receive_queue);
-                       skb_attempt_defer_free(skb);
+                       mptcp_eat_recv_skb(sk, skb);
                }
 
                if (copied >= len)