BPF List
 help / color / mirror / Atom feed
From: Aditi Ghag <aditi.ghag@isovalent.com>
To: bpf@vger.kernel.org
Cc: kafai@fb.com, sdf@google.com, edumazet@google.com,
	Aditi Ghag <aditi.ghag@isovalent.com>
Subject: [PATCH 0/2] bpf-next: Add socket destroy capability
Date: Sat, 17 Dec 2022 01:57:16 +0000	[thread overview]
Message-ID: <cover.1671242108.git.aditi.ghag@isovalent.com> (raw)

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


             reply	other threads:[~2022-12-17  1:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17  1:57 Aditi Ghag [this message]
2022-12-17  1:57 ` [PATCH 1/2] bpf: Add socket destroy capability 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

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=cover.1671242108.git.aditi.ghag@isovalent.com \
    --to=aditi.ghag@isovalent.com \
    --cc=bpf@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=kafai@fb.com \
    --cc=sdf@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