netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: add csum/ip_summed fields to __sk_buff
@ 2023-12-29  8:14 Menglong Dong
  2023-12-29  8:14 ` [PATCH bpf-next 1/2] " Menglong Dong
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Menglong Dong @ 2023-12-29  8:14 UTC (permalink / raw)
  To: andrii
  Cc: ast, daniel, martin.lau, song, yonghong.song, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, davem, edumazet, kuba, pabeni,
	mykolal, shuah, horms, dhowells, linyunsheng, aleksander.lobakin,
	joannelkoong, laoar.shao, kuifeng, menglong8.dong, bjorn,
	linux-kernel, bpf, netdev, linux-kselftest

For now, we have to call some helpers when we need to update the csum,
such as bpf_l4_csum_replace, bpf_l3_csum_replace, etc. These helpers are
not inlined, which causes poor performance.

In fact, we can define our own csum update functions in BPF program
instead of bpf_l3_csum_replace, which is totally inlined and efficient.
However, we can't do this for bpf_l4_csum_replace for now, as we can't
update skb->csum, which can cause skb->csum invalid in the rx path with
CHECKSUM_COMPLETE mode.

What's more, we can't use the direct data access and have to use
skb_store_bytes() with the BPF_F_RECOMPUTE_CSUM flag in some case, such
as modifing the vni in the vxlan header and the underlay udp header has
no checksum.

In the first patch, we make skb->csum readable and writable, and we make
skb->ip_summed readable. For now, for tc only. With these 2 fields, we
don't need to call bpf helpers for csum update any more.

In the second patch, we add some testcases for the read/write testing for
skb->csum and skb->ip_summed.

If this series is acceptable, we can define the inlined functions for csum
update in libbpf in the next step.

Menglong Dong (2):
  bpf: add csum/ip_summed fields to __sk_buff
  testcases/bpf: add testcases for skb->csum to ctx_skb.c

 include/linux/skbuff.h                        |  2 +
 include/uapi/linux/bpf.h                      |  2 +
 net/core/filter.c                             | 22 ++++++++++
 tools/include/uapi/linux/bpf.h                |  2 +
 .../testing/selftests/bpf/verifier/ctx_skb.c  | 43 +++++++++++++++++++
 5 files changed, 71 insertions(+)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-01-03  6:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29  8:14 [PATCH bpf-next 0/2] bpf: add csum/ip_summed fields to __sk_buff Menglong Dong
2023-12-29  8:14 ` [PATCH bpf-next 1/2] " Menglong Dong
2023-12-29  8:14 ` [PATCH bpf-next 2/2] testcases/bpf: add testcases for skb->csum to ctx_skb.c Menglong Dong
2024-01-02 18:11 ` [PATCH bpf-next 0/2] bpf: add csum/ip_summed fields to __sk_buff Stanislav Fomichev
2024-01-03  0:52   ` Martin KaFai Lau
2024-01-03  2:54     ` Menglong Dong
2024-01-03  3:55       ` Yonghong Song
2024-01-03  6:03         ` Menglong Dong

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).