]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mptcp: factor-out cgroup data inherit helper
authorPaolo Abeni <pabeni@redhat.com>
Fri, 21 Nov 2025 17:02:01 +0000 (18:02 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 25 Nov 2025 03:49:41 +0000 (19:49 -0800)
MPTCP will soon need the same functionality for passive sockets,
factor them out in a common helper. No functional change intended.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Geliang Tang <geliang@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20251121-net-next-mptcp-memcg-backlog-imp-v1-2-1f34b6c1e0b1@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mptcp/protocol.h
net/mptcp/subflow.c

index a23780ff670fb2a098bf1b8ef83efa38d69beff5..6d9de13c1f9cd75b7e6f20829bb6880e0280da43 100644 (file)
@@ -707,6 +707,8 @@ mptcp_subflow_delegated_next(struct mptcp_delegated_action *delegated)
        return ret;
 }
 
+void __mptcp_inherit_cgrp_data(struct sock *sk, struct sock *ssk);
+
 int mptcp_is_enabled(const struct net *net);
 unsigned int mptcp_get_add_addr_timeout(const struct net *net);
 int mptcp_is_checksum_enabled(const struct net *net);
index ddd0fc6fcf453a98727f55e77ec7b46d0cbbd67a..d98d151392d2da7e1f12afd9062f5e04e9e73318 100644 (file)
@@ -1712,21 +1712,25 @@ err_out:
        return err;
 }
 
-static void mptcp_attach_cgroup(struct sock *parent, struct sock *child)
+void __mptcp_inherit_cgrp_data(struct sock *sk, struct sock *ssk)
 {
 #ifdef CONFIG_SOCK_CGROUP_DATA
-       struct sock_cgroup_data *parent_skcd = &parent->sk_cgrp_data,
-                               *child_skcd = &child->sk_cgrp_data;
+       struct sock_cgroup_data *sk_cd = &sk->sk_cgrp_data,
+                               *ssk_cd = &ssk->sk_cgrp_data;
 
        /* only the additional subflows created by kworkers have to be modified */
-       if (cgroup_id(sock_cgroup_ptr(parent_skcd)) !=
-           cgroup_id(sock_cgroup_ptr(child_skcd))) {
-               cgroup_sk_free(child_skcd);
-               *child_skcd = *parent_skcd;
-               cgroup_sk_clone(child_skcd);
+       if (cgroup_id(sock_cgroup_ptr(sk_cd)) !=
+           cgroup_id(sock_cgroup_ptr(ssk_cd))) {
+               cgroup_sk_free(ssk_cd);
+               *ssk_cd = *sk_cd;
+               cgroup_sk_clone(sk_cd);
        }
 #endif /* CONFIG_SOCK_CGROUP_DATA */
+}
 
+static void mptcp_attach_cgroup(struct sock *parent, struct sock *child)
+{
+       __mptcp_inherit_cgrp_data(parent, child);
        if (mem_cgroup_sockets_enabled)
                mem_cgroup_sk_inherit(parent, child);
 }