BPF List
 help / color / mirror / Atom feed
* [PATCH 0/2] bpf-next: Add socket destroy capability
@ 2022-12-17  1:57 Aditi Ghag
  2022-12-17  1:57 ` [PATCH 1/2] bpf: " Aditi Ghag
  2022-12-17  1:57 ` [PATCH 2/2] selftests/bpf: Add tests for bpf_sock_destroy Aditi Ghag
  0 siblings, 2 replies; 14+ messages in thread
From: Aditi Ghag @ 2022-12-17  1:57 UTC (permalink / raw)
  To: bpf; +Cc: kafai, sdf, edumazet, Aditi Ghag

This patch adds the capability to destroy sockets in BPF.
We plan to use the capability in Cilium to force
client sockets to reconnect when their remote
load-balancing backends are deleted. The other use case
is on-the-fly policy enforcement where existing socket
connections prevented by policies need to
be terminated.
The use cases, and more details around the selected
approach was presented at LPC 2022 -
https://lpc.events/event/16/contributions/1358/.
RFC discussion -
https://lore.kernel.org/netdev/CABG=zsBEh-P4NXk23eBJw7eajB5YJeRS7oPXnTAzs=yob4EMoQ@mail.gmail.com/T/#u.

Notes to the reviewers:
- We evaluated different approaches to allow the
  `diag_destroy` handlers to acquire/skip locks from
  the BPF iterator programs. The commit description
  has all the details. The selected work queue approach
  was discussed with Daniel Borkmann. 
- We previously discussed the possibility of using
  sockmap to store sockets to be destroyed as an
  optimization, so that users may not need to iterate
  over all the host-wide sockets. This approach needs
  more discussion on the TCP side, as we may need to
  extend the logic that checks for certain TCP states
  while inserting sockets in a sockmap. So I've skipped
  those self test cases involving sockmap from the patch.

Aditi Ghag (2):
  bpf: Add socket destroy capability
  selftests/bpf: Add tests for bpf_sock_destroy

 include/linux/bpf.h                           |   1 +
 include/uapi/linux/bpf.h                      |  17 +++
 kernel/bpf/core.c                             |   1 +
 kernel/trace/bpf_trace.c                      |   2 +
 net/core/filter.c                             |  70 ++++++++++
 tools/include/uapi/linux/bpf.h                |  17 +++
 .../selftests/bpf/prog_tests/sock_destroy.c   | 131 ++++++++++++++++++
 .../selftests/bpf/progs/sock_destroy_prog.c   |  96 +++++++++++++
 8 files changed, 335 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_destroy.c
 create mode 100644 tools/testing/selftests/bpf/progs/sock_destroy_prog.c


base-commit: 0e43662e61f2569500ab83b8188c065603530785
-- 
2.34.1


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

end of thread, other threads:[~2023-02-23 22:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-17  1:57 [PATCH 0/2] bpf-next: Add socket destroy capability Aditi Ghag
2022-12-17  1:57 ` [PATCH 1/2] bpf: " Aditi Ghag
2022-12-19 18:22   ` sdf
2023-02-23 22:02     ` Aditi Ghag
2022-12-20 10:26   ` Alan Maguire
2023-02-23 22:12     ` Aditi Ghag
2022-12-22  5:08   ` Martin KaFai Lau
2022-12-22 10:10     ` Daniel Borkmann
2023-01-02 19:30     ` Aditi Ghag
     [not found]     ` <CACkfWH-qS3vaRA2uSoKUwGcwZZJe=Misaa0wsLw3R4JSYGUx3A@mail.gmail.com>
2023-01-04  2:37       ` Martin KaFai Lau
2023-02-23 22:05     ` Aditi Ghag
2022-12-17  1:57 ` [PATCH 2/2] selftests/bpf: Add tests for bpf_sock_destroy Aditi Ghag
2022-12-19 18:25   ` sdf
2023-02-23 22:24     ` Aditi Ghag

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox