[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241207173803.90744-1-kerneljasonxing@gmail.com>
Date: Sun, 8 Dec 2024 01:37:52 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
dsahern@...nel.org,
willemdebruijn.kernel@...il.com,
willemb@...gle.com,
ast@...nel.org,
daniel@...earbox.net,
andrii@...nel.org,
martin.lau@...ux.dev,
eddyz87@...il.com,
song@...nel.org,
yonghong.song@...ux.dev,
john.fastabend@...il.com,
kpsingh@...nel.org,
sdf@...ichev.me,
haoluo@...gle.com,
jolsa@...nel.org
Cc: bpf@...r.kernel.org,
netdev@...r.kernel.org,
Jason Xing <kernelxing@...cent.com>
Subject: [PATCH net-next v4 00/11] net-timestamp: bpf extension to equip applications transparently
From: Jason Xing <kernelxing@...cent.com>
In August, I planned to extend SO_TIMESTMAMPING feature by using
tracepoint to print information (say, tstamp) so that we can
transparently equip applications with this feature and require no
modification in user side.
Later, we discussed at netconf and agreed that we can use bpf for better
extension, which is mainly suggested by John Fastabend and Willem de
Bruijn. After sending the a few series in recent days, Martin KaFai Lau
provided many valuable advices. Many thanks here!
I post this series to see if we have a better solution to extend. My
feeling is BPF is a good place to provide a way to add timestamping by
administrators, without having to rebuild applications. After this
series, we could step by step implement more advanced functions/flags
already in SO_TIMESTAMPING feature for bpf extension.
This approach mostly relies on existing SO_TIMESTAMPING feature, users
only needs to pass certain flags through bpf_setsocktop() to a separate
tsflags. For TX timestamps, they will be printed during generation
phases.
In this series, I support foundamental codes for TCP.
---
v4
// Sorry for delaying almost one month :(
Link: https://lore.kernel.org/all/20241028110535.82999-1-kerneljasonxing@gmail.com/
1. introduce sk->sk_bpf_cb_flags to let user use bpf_setsockopt() (Martin)
2. introduce SKBTX_BPF to enable the bpf SO_TIMESTAMPING feature (Martin)
3. introduce bpf map in tests (Martin)
4. I choose to make this series as simple as possible, so I only support
most cases in the tx path for TCP protocol.
v3
Link: https://lore.kernel.org/all/20241012040651.95616-1-kerneljasonxing@gmail.com/
1. support UDP proto by introducing a new generation point.
2. for OPT_ID, introducing sk_tskey_bpf_offset to compute the delta
between the current socket key and bpf socket key. It is desiged for
UDP, which also applies to TCP.
3. support bpf_getsockopt()
4. use cgroup static key instead.
5. add one simple bpf selftest to show how it can be used.
6. remove the rx support from v2 because the number of patches could
exceed the limit of one series.
V2
Link: https://lore.kernel.org/all/20241008095109.99918-1-kerneljasonxing@gmail.com/
1. Introduce tsflag requestors so that we are able to extend more in the
future. Besides, it enables TX flags for bpf extension feature separately
without breaking users. It is suggested by Vadim Fedorenko.
2. introduce a static key to control the whole feature. (Willem)
3. Open the gate of bpf_setsockopt for the SO_TIMESTAMPING feature in
some TX/RX cases, not all the cases.
Jason Xing (11):
net-timestamp: add support for bpf_setsockopt()
net-timestamp: prepare for bpf prog use
net-timestamp: reorganize in skb_tstamp_tx_output()
net-timestamp: support SCM_TSTAMP_SCHED for bpf extension
net-timestamp: support SCM_TSTAMP_SND for bpf extension
net-timestamp: support SCM_TSTAMP_ACK for bpf extension
net-timestamp: support hwtstamp print for bpf extension
net-timestamp: make TCP tx timestamp bpf extension work
net-timestamp: introduce cgroup lock to avoid affecting non-bpf cases
net-timestamp: export the tskey for TCP bpf extension
bpf: add simple bpf tests in the tx path for so_timstamping feature
include/linux/skbuff.h | 10 +-
include/net/sock.h | 16 +++
include/net/tcp.h | 3 +-
include/uapi/linux/bpf.h | 23 +++
net/core/dev.c | 3 +-
net/core/filter.c | 22 +++
net/core/skbuff.c | 88 +++++++++++-
net/core/sock.c | 17 +++
net/ipv4/tcp.c | 10 ++
net/ipv4/tcp_input.c | 3 +-
net/ipv4/tcp_output.c | 5 +
tools/include/uapi/linux/bpf.h | 16 +++
.../bpf/prog_tests/so_timestamping.c | 97 +++++++++++++
.../selftests/bpf/progs/so_timestamping.c | 135 ++++++++++++++++++
14 files changed, 435 insertions(+), 13 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/so_timestamping.c
create mode 100644 tools/testing/selftests/bpf/progs/so_timestamping.c
--
2.37.3
Powered by blists - more mailing lists