| From: |
| Kuniyuki Iwashima <kuniyu-AT-google.com> |
| To: |
| Alexei Starovoitov <ast-AT-kernel.org>, Daniel Borkmann <daniel-AT-iogearbox.net>, Martin KaFai Lau <martin.lau-AT-linux.dev>, Stanislav Fomichev <sdf-AT-fomichev.me>, Andrii Nakryiko <andrii-AT-kernel.org>, John Fastabend <john.fastabend-AT-gmail.com>, Kumar Kartikeya Dwivedi <memxor-AT-gmail.com>, Eduard Zingerman <eddyz87-AT-gmail.com> |
| Subject: |
| [PATCH v1 bpf-next/net 0/5] bpf: Support RX/TX HW timestamp proxy. |
| Date: |
| Fri, 12 Jun 2026 00:17:31 +0000 |
| Message-ID: |
| <20260612001803.23341-1-kuniyu@google.com> |
| Cc: |
| Song Liu <song-AT-kernel.org>, Yonghong Song <yonghong.song-AT-linux.dev>, Jiri Olsa <jolsa-AT-kernel.org>, Andrew Lunn <andrew-AT-lunn.ch>, "David S . Miller" <davem-AT-davemloft.net>, Eric Dumazet <edumazet-AT-google.com>, Jakub Kicinski <kuba-AT-kernel.org>, Paolo Abeni <pabeni-AT-redhat.com>, Simon Horman <horms-AT-kernel.org>, Willem de Bruijn <willemb-AT-google.com>, Kuniyuki Iwashima <kuniyu-AT-google.com>, Kuniyuki Iwashima <kuni1840-AT-gmail.com>, bpf-AT-vger.kernel.org, netdev-AT-vger.kernel.org |
| Archive-link: |
| Article |
We have some hosts where packets come from special hardware
and are provided directly to userspace, bypassing the kernel
networking stack.
When standard socket applications are run on these hosts,
a userspace proxy is required to mediate traffic between the
hardware and the applications.
+---------+ +----------------------+
| proxy | | socket application |
+---------+ +----------------------+
^ ^ ^
userspace | | |
-----------| |-----------------------------------------------
| | | +---------------------+ | skb
| | `--->| virtual interface |<---'
kernel | | skb +---------------------+
-----------| |-----------------------------------------------
|
v
+------------+
| hardware |
+------------+
However, even though the hardware fully supports timestamping,
the HW timestamps are not directly accessible to the socket
applications because the skb is consumed/injected by the proxy.
This series extends ethtool and adds BPF kfuncs to transparently
support HW timestamp on such a setup.
Patch 1 is pure net-next patch to advertise fake timestamping
capability on virtual interfaces (e.g. ipvlan, geneve, etc).
Patch 2 is misc cleanup.
Patch 3 & 4 add kfunc to proxy RX/TX hwtstamp.
Patch 5 is selftest to demonstrate how it works.
Note the test requires this iproute2 commit:
https://git.kernel.org/pub/scm/network/iproute2/iproute2-...
Kuniyuki Iwashima (5):
ethtool: Introduce ETHTOOL_MSG_TSINFO_SET for virtual interfaces.
bpf: Rename bpf_kfunc_set_tcp_reqsk to bpf_kfunc_set_sched_cls.
bpf: Add bpf_skb_set_hwtstamp().
bpf: Add kfunc to proxy TX HW Timestamp.
selftest: bpf: Add test for hwtstamp proxy.
Documentation/netlink/specs/ethtool.yaml | 13 +
include/linux/filter.h | 2 +
include/linux/netdevice.h | 11 +
include/linux/skbuff.h | 13 +
include/net/tcx.h | 1 +
include/uapi/linux/bpf.h | 1 +
.../uapi/linux/ethtool_netlink_generated.h | 1 +
include/uapi/linux/pkt_cls.h | 3 +-
kernel/bpf/verifier.c | 13 +-
net/core/dev.c | 39 ++
net/core/dev_ioctl.c | 31 +-
net/core/filter.c | 91 ++-
net/ethtool/common.c | 4 +
net/ethtool/netlink.c | 8 +
net/ethtool/netlink.h | 1 +
net/ethtool/tsconfig.c | 7 +-
net/ethtool/tsinfo.c | 123 +++-
tools/testing/selftests/bpf/bpf_kfuncs.h | 10 +
.../selftests/bpf/prog_tests/proxy_hwtstamp.c | 580 ++++++++++++++++++
.../selftests/bpf/progs/bpf_tracing_net.h | 1 +
.../selftests/bpf/progs/proxy_hwtstamp.c | 234 +++++++
21 files changed, 1169 insertions(+), 18 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/proxy_hwtstamp.c
create mode 100644 tools/testing/selftests/bpf/progs/proxy_hwtstamp.c
--
2.54.0.1136.gdb2ca164c4-goog