From: Tejun Heo <tj@kernel.org>
Cc: kuniyu@amazon.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, cgroups@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"Leon Romanovsky" <leon@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Christian Brauner" <brauner@kernel.org>,
"Lennart Poettering" <mzxreary@0pointer.de>,
"Luca Boccassi" <bluca@debian.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shuah Khan" <shuah@kernel.org>
Subject: Re: [PATCH net-next 0/4] Add getsockopt(SO_PEERCGROUPID) and fdinfo API to retreive socket's peer cgroup id
Date: Sun, 9 Mar 2025 04:36:42 -1000 [thread overview]
Message-ID: <Z82neltmT_hbEpYy@slm.duckdns.org> (raw)
In-Reply-To: <20250309132821.103046-1-aleksandr.mikhalitsyn@canonical.com>
On Sun, Mar 09, 2025 at 02:28:11PM +0100, Alexander Mikhalitsyn wrote:
> 1. Add socket cgroup id and socket's peer cgroup id in socket's fdinfo
> 2. Add SO_PEERCGROUPID which allows to retrieve socket's peer cgroup id
> 3. Add SO_PEERCGROUPID kselftest
>
> Generally speaking, this API allows race-free resolution of socket's peer cgroup id.
> Currently, to do that SCM_CREDENTIALS/SCM_PIDFD -> pid -> /proc/<pid>/cgroup sequence
> is used which is racy.
>
> As we don't add any new state to the socket itself there is no potential locking issues
> or performance problems. We use already existing sk->sk_cgrp_data.
>
> We already have analogical interfaces to retrieve this
> information:
> - inet_diag: INET_DIAG_CGROUP_ID
> - eBPF: bpf_sk_cgroup_id
>
> Having getsockopt() interface makes sense for many applications, because using eBPF is
> not always an option, while inet_diag has obvious complexety and performance drawbacks
> if we only want to get this specific info for one specific socket.
>
> Idea comes from UAPI kernel group:
> https://uapi-group.org/kernel-features/
>
> Huge thanks to Christian Brauner, Lennart Poettering and Luca Boccassi for proposing
> and exchanging ideas about this.
>
> Git tree:
> https://github.com/mihalicyn/linux/tree/so_peercgroupid
From cgroup POV:
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
next prev parent reply other threads:[~2025-03-09 14:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 13:28 Alexander Mikhalitsyn
2025-03-09 13:28 ` [PATCH net-next 1/4] net: unix: print cgroup_id and peer_cgroup_id in fdinfo Alexander Mikhalitsyn
2025-03-11 7:41 ` Kuniyuki Iwashima
2025-03-09 13:28 ` [PATCH net-next 2/4] net: core: add getsockopt SO_PEERCGROUPID Alexander Mikhalitsyn
2025-03-10 14:00 ` Willem de Bruijn
2025-03-11 7:52 ` Kuniyuki Iwashima
2025-03-09 13:28 ` [PATCH net-next 3/4] tools/testing/selftests/cgroup/cgroup_util: add cg_get_id helper Alexander Mikhalitsyn
2025-03-09 13:28 ` [PATCH net-next 4/4] tools/testing/selftests/cgroup: add test for SO_PEERCGROUPID Alexander Mikhalitsyn
2025-03-10 13:59 ` Willem de Bruijn
2025-03-11 8:02 ` Kuniyuki Iwashima
2025-03-09 14:36 ` Tejun Heo [this message]
2025-03-10 8:52 ` [PATCH net-next 0/4] Add getsockopt(SO_PEERCGROUPID) and fdinfo API to retreive socket's peer cgroup id Christian Brauner
2025-03-10 11:27 ` Christian Brauner
2025-03-11 7:33 ` Kuniyuki Iwashima
2025-03-11 12:02 ` Christian Brauner
2025-03-13 10:31 ` Michal Koutný
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z82neltmT_hbEpYy@slm.duckdns.org \
--to=tj@kernel.org \
--cc=arnd@arndb.de \
--cc=bluca@debian.org \
--cc=brauner@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hannes@cmpxchg.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=mzxreary@0pointer.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®