From: Aditi Ghag <aditi.ghag@isovalent.com>
To: bpf@vger.kernel.org
Cc: kafai@fb.com, sdf@google.com, edumazet@google.com,
aditi.ghag@isovalent.com
Subject: [PATCH v5 bpf-next 0/7] bpf: Add socket destroy capability
Date: Thu, 30 Mar 2023 15:17:51 +0000 [thread overview]
Message-ID: <20230330151758.531170-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.
v4 patch series -
https://lore.kernel.org/bpf/20230323200633.3175753-1-aditi.ghag@isovalent.com/T/#t
v5 highlights:
Address review comments:
Martin:
- Fixed bugs in the resume operation for UDP iterator.
- Added clean-up preparatory commits prior to the batching commit.
Stan:
- Programmatically retrieve and share server port in the selftests.
- Acquire slow sock lock in UDP iterator to be consistent with TCP.
- Addressed formatting nits.
(Below notes are same as v2 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 (7):
bpf: tcp: Avoid taking fast sock lock in iterator
udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state
udp: seq_file: Helper function to match socket attributes
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
include/net/udp.h | 1 -
net/core/filter.c | 54 ++++
net/ipv4/tcp.c | 10 +-
net/ipv4/tcp_ipv4.c | 5 +-
net/ipv4/udp.c | 286 +++++++++++++++---
tools/testing/selftests/bpf/network_helpers.c | 14 +
tools/testing/selftests/bpf/network_helpers.h | 1 +
.../selftests/bpf/prog_tests/sock_destroy.c | 203 +++++++++++++
.../selftests/bpf/progs/sock_destroy_prog.c | 147 +++++++++
9 files changed, 676 insertions(+), 45 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
--
2.34.1
next reply other threads:[~2023-03-30 15:19 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 15:17 Aditi Ghag [this message]
2023-03-30 15:17 ` [PATCH v5 bpf-next 1/7] bpf: tcp: Avoid taking fast sock lock in iterator Aditi Ghag
2023-03-30 15:17 ` [PATCH v5 bpf-next 2/7] udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state Aditi Ghag
2023-03-30 17:35 ` Martin KaFai Lau
2023-03-30 15:17 ` [PATCH v5 bpf-next 3/7] udp: seq_file: Helper function to match socket attributes Aditi Ghag
2023-03-30 18:40 ` kernel test robot
2023-03-30 18:51 ` kernel test robot
2023-03-31 2:52 ` kernel test robot
2023-03-31 20:09 ` Martin KaFai Lau
2023-04-03 15:27 ` Aditi Ghag
2023-04-02 6:18 ` kernel test robot
2023-03-30 15:17 ` [PATCH v5 bpf-next 4/7] bpf: udp: Implement batching for sockets iterator Aditi Ghag
2023-03-31 21:08 ` Martin KaFai Lau
2023-04-03 15:54 ` Aditi Ghag
2023-04-03 19:20 ` Martin KaFai Lau
2023-03-30 15:17 ` [PATCH v5 bpf-next 5/7] bpf: Add bpf_sock_destroy kfunc Aditi Ghag
2023-03-31 22:24 ` Martin KaFai Lau
2023-04-04 6:09 ` [RFC PATCH bpf-next] bpf: Add a kfunc filter function to 'struct btf_kfunc_id_set' Martin KaFai Lau
2023-04-05 15:05 ` Aditi Ghag
2023-04-05 17:26 ` Martin KaFai Lau
2023-04-10 23:05 ` Aditi Ghag
2023-04-12 15:21 ` Aditi Ghag
2023-03-30 15:17 ` [PATCH v5 bpf-next 6/7] selftests/bpf: Add helper to get port using getsockname Aditi Ghag
2023-03-30 18:41 ` Stanislav Fomichev
2023-03-31 21:37 ` Martin KaFai Lau
2023-03-30 15:17 ` [PATCH v5 bpf-next 7/7] selftests/bpf: Test bpf_sock_destroy Aditi Ghag
2023-03-30 18:46 ` Stanislav Fomichev
2023-03-31 22:32 ` Martin KaFai Lau
2023-04-03 15:55 ` Aditi Ghag
2023-04-03 17:35 ` Martin KaFai Lau
2023-04-04 0:15 ` Aditi Ghag
2023-04-04 1:41 ` Martin KaFai Lau
2023-04-04 14: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=20230330151758.531170-1-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;
as well as URLs for NNTP newsgroup(s).