add gso_size to __sk_buff
Subsystems (6)
cover add gso_size to __sk_buff
From: Willem de Bruijn <[email protected]>
See first patch for details.
Patch split across three parts { kernel feature, uapi header, tools } following the custom for such __sk_buff changes.
Willem de Bruijn (3):
bpf: add gso_size to __sk_buff
bpf: Sync uapi bpf.h to tools/ selftests/bpf: test new __sk_buff field gso_size
include/uapi/linux/bpf.h | 1 + net/bpf/test_run.c | 7 +++ net/core/filter.c | 44 +++++++++++------ tools/include/uapi/linux/bpf.h | 1 + .../selftests/bpf/prog_tests/skb_ctx.c | 1 + .../selftests/bpf/progs/test_skb_ctx.c | 2 + .../testing/selftests/bpf/verifier/ctx_skb.c | 47 +++++++++++++++++++ 7 files changed, 89 insertions(+), 14 deletions(-)
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
PATCH 1/3 bpf: add gso_size to __sk_buff
From: Willem de Bruijn <[email protected]>
BPF programs may want to know whether an skb is gso. The canonical answer is skb_is_gso(skb), which tests that gso_size != 0.
Expose this field in the same manner as gso_segs. That field itself is not a sufficient signal, as the comment in skb_shared_info makes
clear: gso_segs may be zero, e.g., from dodgy sources.
Also prepare net/bpf/test_run for upcoming BPF_PROG_TEST_RUN tests of the feature.
--- include/uapi/linux/bpf.h | 1 + net/bpf/test_run.c | 7 +++++++ net/core/filter.c | 44 +++++++++++++++++++++++++++------------- 3 files changed, 38 insertions(+), 14 deletions(-)
include/uapi/linux/bpf.h +1 -0
@@ -3176,6 +3176,7 @@ struct __sk_buff {__u32 wire_len;__u32 gso_segs; __bpf_md_ptr(struct bpf_sock *, sk); +__u32 gso_size; };struct bpf_tunnel_key {
net/bpf/test_run.c +7 -0
@@ -277,6 +277,12 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)/* gso_segs is allowed */ if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_segs), + offsetof(struct __sk_buff , gso_size))) +return -EINVAL ; + +/* gso_size is allowed */ + + if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_size),sizeof (struct __sk_buff )))return -EINVAL ;
@@ -297,6 +303,7 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb)if (__skb->gso_segs >GSO_MAX_SEGS )return -EINVAL ;skb_shinfo (skb)->gso_segs = __skb->gso_segs; +skb_shinfo (skb)->gso_size = __skb->gso_size;return 0 ; }
net/core/filter.c +30 -14
62 lines not on this page · raw message
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
PATCH 2/3 bpf: Sync uapi bpf.h to tools/
In reply to Willem de BruijnFrom: Willem de Bruijn <[email protected]>
sync tools/include/uapi/linux/bpf.h to match include/uapi/linux/bpf.h
--- tools/include/uapi/linux/bpf.h | 1 + 1 file changed, 1 insertion(+)
tools/include/uapi/linux/bpf.h +1 -0
@@ -3176,6 +3176,7 @@ struct __sk_buff {__u32 wire_len;__u32 gso_segs; __bpf_md_ptr(struct bpf_sock *, sk); +__u32 gso_size; };struct bpf_tunnel_key {
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
PATCH 3/3 selftests/bpf: test new __sk_buff field gso_size
In reply to Willem de BruijnFrom: Willem de Bruijn <[email protected]>
Analogous to the gso_segs selftests introduced in commit d9ff286a0f59 ("bpf: allow BPF programs access skb_shared_info->gso_segs field").
--- .../selftests/bpf/prog_tests/skb_ctx.c | 1 + .../selftests/bpf/progs/test_skb_ctx.c | 2 + .../testing/selftests/bpf/verifier/ctx_skb.c | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+)
tools/testing/selftests/bpf/prog_tests/skb_ctx.c +1 -0
@@ -14,6 +14,7 @@ void test_skb_ctx(void) .wire_len = 100, .gso_segs = 8, .mark = 9, + .gso_size = 10, };struct bpf_prog_test_run_attr tattr = { .data_in = &pkt_v4,
tools/testing/selftests/bpf/progs/test_skb_ctx.c +2 -0
@@ -23,6 +23,8 @@ int process(struct __sk_buff *skb)return 1 ;if (skb->gso_segs !=8 )return 1 ; +if (skb->gso_size !=10 ) +return 1 ;return 0 ; }
tools/testing/selftests/bpf/verifier/ctx_skb.c +47 -0
53 lines not on this page · raw message
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
For the series: Acked-by: Petar Penkov <[email protected]>
Quoted 25 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
See first patch for details.
Patch split across three parts { kernel feature, uapi header, tools } following the custom for such
__sk_buffchanges.Willem de Bruijn (3):
bpf: addgso_sizeto__sk_buff
bpf: Sync uapibpf.htotools/selftests/bpf: test new__sk_bufffieldgso_sizeinclude/uapi/linux/bpf.h | 1 + net/bpf/test_run.c | 7 +++ net/core/filter.c | 44 +++++++++++------ tools/include/uapi/linux/bpf.h | 1 + .../selftests/bpf/prog_tests/skb_ctx.c | 1 + .../selftests/bpf/progs/test_skb_ctx.c | 2 + .../testing/selftests/bpf/verifier/ctx_skb.c | 47 +++++++++++++++++++ 7 files changed, 89 insertions(+), 14 deletions(-)--
2.25.0.265.gbab2e86ba0-goog
Alexei Starovoitov
AppliedQuoted 2 lines · Petar Penkov
For the series: Acked-by: Petar Penkov <[email protected]>
please don't top post.
Quoted 9 lines
Quoted 7 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
See first patch for details.
Patch split across three parts { kernel feature, uapi header, tools } following the custom for such
__sk_buffchanges.
Applied. Thanks