From: Aditi Ghag <aditi.ghag@isovalent.com>
To: bpf@vger.kernel.org
Cc: kafai@fb.com, sdf@google.com, aditi.ghag@isovalent.com
Subject: [PATCH v7 bpf-next 00/10] bpf: Add socket destroy capability
Date: Wed, 3 May 2023 22:53:41 +0000 [thread overview]
Message-ID: <20230503225351.3700208-1-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 were 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.
v6 patch series -
https://lore.kernel.org/bpf/20230418153148.2231644-1-aditi.ghag@isovalent.com/
v7 highlights:
Address review comments:
Martin:
- Refactored logic to get udp table to a separate commit.
- Addressed nits in the batching and test commits.
- Applied patch to filter and restrict the kfunc, and added a test.
Stan:
- Addressed nits in the network helper commit.
Paolo/Yonghong:
- Extended the first commit that revises locking in BPF TCP iterator
with more details.
- Fixed comment formatting.
(Below notes are same as v6 patch series that are still relevant. Refer to
earlier patch series for other notes.)
- I hit a snag while writing the kfunc where verifier complained about the
`sock_common` type passed from TCP iterator. With kfuncs, there don't
seem to be any options available to pass BTF type hints to the verifier
(equivalent of `ARG_PTR_TO_BTF_ID_SOCK_COMMON`, as was the case with the
helper). As a result, I changed the argument type of the sock_destory
kfunc to `sock_common`.
Aditi Ghag (10):
bpf: tcp: Avoid taking fast sock lock in iterator
udp: seq_file: Helper function to match socket attributes
bpf: udp: Encapsulate logic to get udp table
udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state
bpf: udp: Implement batching for sockets iterator
bpf: Add bpf_sock_destroy kfunc
selftests/bpf: Add helper to get port using getsockname
selftests/bpf: Test bpf_sock_destroy
bpf: Add a kfunc filter function to 'struct btf_kfunc_id_set'
selftests/bpf: Extend bpf_sock_destroy tests
include/linux/btf.h | 18 +-
include/net/udp.h | 1 -
kernel/bpf/btf.c | 59 +++-
kernel/bpf/verifier.c | 7 +-
net/core/filter.c | 66 ++++
net/ipv4/tcp.c | 10 +-
net/ipv4/tcp_ipv4.c | 5 +-
net/ipv4/udp.c | 287 +++++++++++++++---
tools/testing/selftests/bpf/network_helpers.c | 23 ++
tools/testing/selftests/bpf/network_helpers.h | 1 +
.../selftests/bpf/prog_tests/sock_destroy.c | 217 +++++++++++++
.../selftests/bpf/progs/sock_destroy_prog.c | 145 +++++++++
.../bpf/progs/sock_destroy_prog_fail.c | 22 ++
13 files changed, 785 insertions(+), 76 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_destroy.c
create mode 100644 tools/testing/selftests/bpf/progs/sock_destroy_prog.c
create mode 100644 tools/testing/selftests/bpf/progs/sock_destroy_prog_fail.c
--
2.34.1
next reply other threads:[~2023-05-03 22:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 22:53 Aditi Ghag [this message]
2023-05-03 22:53 ` [PATCH v7 bpf-next 01/10] bpf: tcp: Avoid taking fast sock lock in iterator Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 02/10] udp: seq_file: Helper function to match socket attributes Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 03/10] bpf: udp: Encapsulate logic to get udp table Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 04/10] udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state Aditi Ghag
2023-05-04 1:25 ` Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 05/10] bpf: udp: Implement batching for sockets iterator Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 06/10] bpf: Add bpf_sock_destroy kfunc Aditi Ghag
2023-05-05 0:13 ` Martin KaFai Lau
2023-05-05 18:49 ` Martin KaFai Lau
2023-05-05 20:05 ` Alexei Starovoitov
2023-05-03 22:53 ` [PATCH v7 bpf-next 07/10] selftests/bpf: Add helper to get port using getsockname Aditi Ghag
2023-05-04 17:33 ` Stanislav Fomichev
2023-05-03 22:53 ` [PATCH v7 bpf-next 08/10] selftests/bpf: Test bpf_sock_destroy Aditi Ghag
2023-05-05 0:24 ` Martin KaFai Lau
2023-05-03 22:53 ` [PATCH v7 bpf-next 09/10] bpf: Add a kfunc filter function to 'struct btf_kfunc_id_set' Aditi Ghag
2023-05-05 0:28 ` Martin KaFai Lau
2023-05-03 22:53 ` [PATCH v7 bpf-next 10/10] selftests/bpf: Extend bpf_sock_destroy tests 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=20230503225351.3700208-1-aditi.ghag@isovalent.com \
--to=aditi.ghag@isovalent.com \
--cc=bpf@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).