public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Paul Chaignon <paul.chaignon@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Amery Hung <ameryhung@gmail.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 4/5] selftests/bpf: Support non-linear flag in test loader
Date: Thu, 9 Oct 2025 10:37:59 -0700	[thread overview]
Message-ID: <2ea048fd-3ffc-4706-ba69-f77e92338b0d@linux.dev> (raw)
In-Reply-To: <0c44ad0d1f4899cbfd745ab654a2ad86e3737d37.1760015985.git.paul.chaignon@gmail.com>

On 10/9/25 7:02 AM, Paul Chaignon wrote:
> @@ -633,6 +635,11 @@ static int parse_test_spec(struct test_loader *tester,
>   					      &spec->unpriv.stdout);
>   			if (err)
>   				goto cleanup;
> +		} else if (str_has_pfx(s, TEST_TAG_LINEAR_SIZE)) {
> +			val = s + sizeof(TEST_TAG_LINEAR_SIZE) - 1;
> +			err = parse_int(val, &spec->linear_sz, "test linear size");
> +			if (err)
> +				goto cleanup;
>   		}
>   	}
>   
> @@ -1007,10 +1014,11 @@ static bool is_unpriv_capable_map(struct bpf_map *map)
>   	}
>   }
>   
> -static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts)
> +static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts, int linear_sz)
>   {
>   	__u8 tmp_out[TEST_DATA_LEN << 2] = {};
>   	__u8 tmp_in[TEST_DATA_LEN] = {};
> +	struct __sk_buff ctx = {};

since it needs a re-spin...

not all prog type uses "struct __sk_buff". linear_sz could be useful for xdp 
also but it also needs a different struct. This is pretty much "tc" and 
"cgroup_skb" only for now. How about error out earlier in the parse_test_spec? I 
think the bpf_program__type() should already be available at the parse_test_spec().

>   	int err, saved_errno;
>   	LIBBPF_OPTS(bpf_test_run_opts, topts,
>   		.data_in = tmp_in,
> @@ -1020,6 +1028,12 @@ static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts)
>   		.repeat = 1,
>   	);
>   
> +	if (linear_sz) {
> +		ctx.data_end = linear_sz;
> +		topts.ctx_in = &ctx;
> +		topts.ctx_size_in = sizeof(ctx);
> +	}
> +


  reply	other threads:[~2025-10-09 17:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 13:59 [PATCH bpf-next v7 0/5] Support non-linear skbs for BPF_PROG_TEST_RUN Paul Chaignon
2025-10-09 14:01 ` [PATCH bpf-next v7 1/5] bpf: Refactor cleanup of bpf_prog_test_run_skb Paul Chaignon
2025-10-09 14:02 ` [PATCH bpf-next v7 2/5] bpf: Reorder bpf_prog_test_run_skb initialization Paul Chaignon
2025-10-09 14:02 ` [PATCH bpf-next v7 3/5] bpf: Craft non-linear skbs in BPF_PROG_TEST_RUN Paul Chaignon
2025-10-09 17:14   ` Martin KaFai Lau
2025-10-09 14:02 ` [PATCH bpf-next v7 4/5] selftests/bpf: Support non-linear flag in test loader Paul Chaignon
2025-10-09 17:37   ` Martin KaFai Lau [this message]
2025-10-09 14:02 ` [PATCH bpf-next v7 5/5] selftests/bpf: Test direct packet access on non-linear skbs Paul Chaignon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ea048fd-3ffc-4706-ba69-f77e92338b0d@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=paul.chaignon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox