Skip to content

Commit be3d72a

Browse files
LorenzoBianconiAlexei Starovoitov
authored andcommitted
bpf: move user_size out of bpf_test_init
Rely on data_size_in in bpf_test_init routine signature. This is a preliminary patch to introduce xdp frags selftest Acked-by: Toke Hoiland-Jorgensen <[email protected]> Acked-by: John Fastabend <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://lore.kernel.org/r/6b48d38ed3d60240d7d6bb15e6fa7fabfac8dfb2.1642758637.git.lorenzo@kernel.org Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent d991730 commit be3d72a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

net/bpf/test_run.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,10 @@ BTF_SET_START(test_sk_ret_null_kfunc_ids)
367367
BTF_ID(func, bpf_kfunc_call_test_acquire)
368368
BTF_SET_END(test_sk_ret_null_kfunc_ids)
369369

370-
static void *bpf_test_init(const union bpf_attr *kattr, u32 size,
371-
u32 headroom, u32 tailroom)
370+
static void *bpf_test_init(const union bpf_attr *kattr, u32 user_size,
371+
u32 size, u32 headroom, u32 tailroom)
372372
{
373373
void __user *data_in = u64_to_user_ptr(kattr->test.data_in);
374-
u32 user_size = kattr->test.data_size_in;
375374
void *data;
376375

377376
if (size < ETH_HLEN || size > PAGE_SIZE - headroom - tailroom)
@@ -699,7 +698,8 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
699698
if (kattr->test.flags || kattr->test.cpu)
700699
return -EINVAL;
701700

702-
data = bpf_test_init(kattr, size, NET_SKB_PAD + NET_IP_ALIGN,
701+
data = bpf_test_init(kattr, kattr->test.data_size_in,
702+
size, NET_SKB_PAD + NET_IP_ALIGN,
703703
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
704704
if (IS_ERR(data))
705705
return PTR_ERR(data);
@@ -908,7 +908,8 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
908908
/* XDP have extra tailroom as (most) drivers use full page */
909909
max_data_sz = 4096 - headroom - tailroom;
910910

911-
data = bpf_test_init(kattr, max_data_sz, headroom, tailroom);
911+
data = bpf_test_init(kattr, kattr->test.data_size_in,
912+
max_data_sz, headroom, tailroom);
912913
if (IS_ERR(data)) {
913914
ret = PTR_ERR(data);
914915
goto free_ctx;
@@ -994,7 +995,7 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog,
994995
if (size < ETH_HLEN)
995996
return -EINVAL;
996997

997-
data = bpf_test_init(kattr, size, 0, 0);
998+
data = bpf_test_init(kattr, kattr->test.data_size_in, size, 0, 0);
998999
if (IS_ERR(data))
9991000
return PTR_ERR(data);
10001001

0 commit comments

Comments
 (0)