netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Override default socket policy per cgroup
@ 2022-02-09 17:03 sdf
  2022-02-09 21:02 ` Martin KaFai Lau
  0 siblings, 1 reply; 6+ messages in thread
From: sdf @ 2022-02-09 17:03 UTC (permalink / raw)
  To: ast, daniel, kafai; +Cc: netdev, bpf

Let's say I want to set some default sk_priority for all sockets in a
specific cgroup. I can do it right now using cgroup/sock_create, but it
applies only to AF_INET{,6} sockets. I'd like to do the same for raw
(AF_PACKET) sockets and cgroup/sock_create doesn't trigger for them :-(

(1) My naive approach would be to add another cgroup/sock_post_create
which runs late from __sock_create and triggers on everything.

(2) Another approach might be to move BPF_CGROUP_RUN_PROG_INET_SOCK and
make it work with AF_PACKET. This might be not 100% backwards compatible
but I'd assume that most users should look at the socket family before
doing anything. (in this case it feels like we can extend
sock_bind/release for af_packets as well, just for accounting purposes,
without any way to override the target ifindex).

(3) I've also tried to play with fentry/security_socket_post_create, but
it doesn't look like I can change kernel data from the tracing context.
fentry is also global and I'd like to get to cgroup-local-storage.

(I don't want to get involved in per-packet processing here, so I'm
looking at something I can do once at socket creation).

Any suggestions? Anything I'm missing? I'm leaning towards (2), maybe we
can extend existing socket create/bind/release for af_packet? Having
another set (1) doesn't make sense.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-10  2:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-09 17:03 Override default socket policy per cgroup sdf
2022-02-09 21:02 ` Martin KaFai Lau
2022-02-09 21:51   ` sdf
2022-02-09 22:25     ` Alexei Starovoitov
2022-02-09 22:38       ` sdf
2022-02-09 23:40     ` Martin KaFai Lau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).