[PATCH bpf-next] bpf, test_run: Remove unnecessary prog type checks

Daniel Xu posted 1 patch 3 years, 11 months ago
net/bpf/test_run.c | 6 ------
1 file changed, 6 deletions(-)
[PATCH bpf-next] bpf, test_run: Remove unnecessary prog type checks
Posted by Daniel Xu 3 years, 11 months ago
These checks were effectively noops b/c there's only one way these
functions get called: through prog_ops dispatching. And since there's no
other callers, we can be sure that `prog` is always the correct type.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
 net/bpf/test_run.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 56f059b3c242..2ca96acbc50a 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -1420,9 +1420,6 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog,
 	void *data;
 	int ret;
 
-	if (prog->type != BPF_PROG_TYPE_FLOW_DISSECTOR)
-		return -EINVAL;
-
 	if (kattr->test.flags || kattr->test.cpu || kattr->test.batch_size)
 		return -EINVAL;
 
@@ -1487,9 +1484,6 @@ int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, const union bpf_attr *kat
 	u32 retval, duration;
 	int ret = -EINVAL;
 
-	if (prog->type != BPF_PROG_TYPE_SK_LOOKUP)
-		return -EINVAL;
-
 	if (kattr->test.flags || kattr->test.cpu || kattr->test.batch_size)
 		return -EINVAL;
 
-- 
2.36.1
Re: [PATCH bpf-next] bpf, test_run: Remove unnecessary prog type checks
Posted by patchwork-bot+netdevbpf@kernel.org 3 years, 11 months ago
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Sun, 29 May 2022 15:15:41 -0500 you wrote:
> These checks were effectively noops b/c there's only one way these
> functions get called: through prog_ops dispatching. And since there's no
> other callers, we can be sure that `prog` is always the correct type.
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
>  net/bpf/test_run.c | 6 ------
>  1 file changed, 6 deletions(-)

Here is the summary with links:
  - [bpf-next] bpf, test_run: Remove unnecessary prog type checks
    https://git.kernel.org/bpf/bpf-next/c/330eb2a696f2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH bpf-next] bpf, test_run: Remove unnecessary prog type checks
Posted by Song Liu 3 years, 11 months ago
On Sun, May 29, 2022 at 1:16 PM Daniel Xu <dxu@dxuuu.xyz> wrote:
>
> These checks were effectively noops b/c there's only one way these
> functions get called: through prog_ops dispatching. And since there's no
> other callers, we can be sure that `prog` is always the correct type.
>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>

Acked-by: Song Liu <songliubraving@fb.com>