]> git.baikalelectronics.ru Git - kernel.git/commit
inet_diag: add cgroup id attribute
authorDmitry Yakunin <zeil@yandex-team.ru>
Thu, 30 Apr 2020 15:51:14 +0000 (18:51 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Apr 2020 19:54:01 +0000 (12:54 -0700)
commited94a533126ccea15014e351500a12bbe1fcb7ef
tree6b3c057c6caecbb64eee8852ff65a4689d612ad1
parent082f355dd1d884e088922383b1f772426bad69ae
inet_diag: add cgroup id attribute

This patch adds cgroup v2 ID to common inet diag message attributes.
Cgroup v2 ID is kernfs ID (ino or ino+gen). This attribute allows filter
inet diag output by cgroup ID obtained by name_to_handle_at() syscall.
When net_cls or net_prio cgroup is activated this ID is equal to 1 (root
cgroup ID) for newly created sockets.

Some notes about this ID:

1) gets initialized in socket() syscall
2) incoming socket gets ID from listening socket
   (not during accept() syscall)
3) not changed when process get moved to another cgroup
4) can point to deleted cgroup (refcounting)

v2:
  - use CONFIG_SOCK_CGROUP_DATA instead if CONFIG_CGROUPS

v3:
  - fix attr size by using nla_total_size_64bit() (Eric Dumazet)
  - more detailed commit message (Konstantin Khlebnikov)

Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru>
Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-By: Tejun Heo <tj@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/inet_diag.h
include/uapi/linux/inet_diag.h
net/ipv4/inet_diag.c