public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage
@ 2026-03-23 22:52 Martin KaFai Lau
  2026-03-24  2:16 ` sun jian
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Martin KaFai Lau @ 2026-03-23 22:52 UTC (permalink / raw)
  To: bpf
  Cc: 'Alexei Starovoitov ', 'Andrii Nakryiko ',
	'Daniel Borkmann ', netdev, Jakub Kicinski,
	Fernando Fernandez Mancera

From: Martin KaFai Lau <martin.lau@kernel.org>

bpf_prog_test_run_skb() uses net->ipv6.ip6_null_entry for
BPF_PROG_TYPE_LWT_XMIT test runs.

It currently checks ipv6_bpf_stub before using ip6_null_entry.
ipv6_bpf_stub will be removed by the CONFIG_IPV6=m support removal
series posted at [1], so switch this check to ipv6_mod_enabled()
instead.

This change depends on that series [1]. Without it, CONFIG_IPV6=m is
still possible, and net->ipv6.ip6_null_entry remains NULL until
the IPv6 module is loaded.

[1] https://lore.kernel.org/netdev/20260320185649.5411-1-fmancera@suse.de/

Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
---
 net/bpf/test_run.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 56bc8dc1e281..fb25184ed03b 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -1157,15 +1157,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
 	}
 
 	if (prog->type == BPF_PROG_TYPE_LWT_XMIT) {
-		if (!ipv6_bpf_stub) {
-			pr_warn_once("Please test this program with the IPv6 module loaded\n");
+		if (!ipv6_mod_enabled()) {
+			pr_warn_once("Please test this program with IPv6 enabled kernel\n");
 			ret = -EOPNOTSUPP;
 			goto out;
 		}
 #if IS_ENABLED(CONFIG_IPV6)
-		/* For CONFIG_IPV6=n, ipv6_bpf_stub is NULL which is
-		 * handled by the above if statement.
-		 */
 		dst_hold(&net->ipv6.ip6_null_entry->dst);
 		skb_dst_set(skb, &net->ipv6.ip6_null_entry->dst);
 #endif
-- 
2.52.0


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

* Re: [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage
  2026-03-23 22:52 [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage Martin KaFai Lau
@ 2026-03-24  2:16 ` sun jian
  2026-03-24  9:55 ` Fernando Fernandez Mancera
  2026-03-24 15:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: sun jian @ 2026-03-24  2:16 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, netdev,
	Jakub Kicinski, Fernando Fernandez Mancera

On Tue, Mar 24, 2026 at 6:58 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> From: Martin KaFai Lau <martin.lau@kernel.org>
>
> bpf_prog_test_run_skb() uses net->ipv6.ip6_null_entry for
> BPF_PROG_TYPE_LWT_XMIT test runs.
>
> It currently checks ipv6_bpf_stub before using ip6_null_entry.
> ipv6_bpf_stub will be removed by the CONFIG_IPV6=m support removal
> series posted at [1], so switch this check to ipv6_mod_enabled()
> instead.
>
> This change depends on that series [1]. Without it, CONFIG_IPV6=m is
> still possible, and net->ipv6.ip6_null_entry remains NULL until
> the IPv6 module is loaded.
>
> [1] https://lore.kernel.org/netdev/20260320185649.5411-1-fmancera@suse.de/
>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Fernando Fernandez Mancera <fmancera@suse.de>
> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
> ---
>  net/bpf/test_run.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 56bc8dc1e281..fb25184ed03b 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -1157,15 +1157,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
>         }
>
>         if (prog->type == BPF_PROG_TYPE_LWT_XMIT) {
> -               if (!ipv6_bpf_stub) {
> -                       pr_warn_once("Please test this program with the IPv6 module loaded\n");
> +               if (!ipv6_mod_enabled()) {
> +                       pr_warn_once("Please test this program with IPv6 enabled kernel\n");
>                         ret = -EOPNOTSUPP;
>                         goto out;
>                 }
>  #if IS_ENABLED(CONFIG_IPV6)
> -               /* For CONFIG_IPV6=n, ipv6_bpf_stub is NULL which is
> -                * handled by the above if statement.
> -                */
>                 dst_hold(&net->ipv6.ip6_null_entry->dst);
>                 skb_dst_set(skb, &net->ipv6.ip6_null_entry->dst);
>  #endif
> --
> 2.52.0
>
>
 Since the CONFIG_IPV6=m removal series also removes the stubs, switching
 the check to ipv6_mod_enabled() makes sense.

Reviewed-by: Sun Jian <sun.jian.kdev@gmail.com>

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

* Re: [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage
  2026-03-23 22:52 [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage Martin KaFai Lau
  2026-03-24  2:16 ` sun jian
@ 2026-03-24  9:55 ` Fernando Fernandez Mancera
  2026-03-24 15:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Fernando Fernandez Mancera @ 2026-03-24  9:55 UTC (permalink / raw)
  To: Martin KaFai Lau, bpf
  Cc: 'Alexei Starovoitov ', 'Andrii Nakryiko ',
	'Daniel Borkmann ', netdev, Jakub Kicinski

On 3/23/26 11:52 PM, Martin KaFai Lau wrote:
> From: Martin KaFai Lau <martin.lau@kernel.org>
> 
> bpf_prog_test_run_skb() uses net->ipv6.ip6_null_entry for
> BPF_PROG_TYPE_LWT_XMIT test runs.
> 
> It currently checks ipv6_bpf_stub before using ip6_null_entry.
> ipv6_bpf_stub will be removed by the CONFIG_IPV6=m support removal
> series posted at [1], so switch this check to ipv6_mod_enabled()
> instead.
> 
> This change depends on that series [1]. Without it, CONFIG_IPV6=m is
> still possible, and net->ipv6.ip6_null_entry remains NULL until
> the IPv6 module is loaded.
> 
> [1] https://lore.kernel.org/netdev/20260320185649.5411-1-fmancera@suse.de/
> 
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Fernando Fernandez Mancera <fmancera@suse.de>
> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
> ---

LGTM!

Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>

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

* Re: [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage
  2026-03-23 22:52 [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage Martin KaFai Lau
  2026-03-24  2:16 ` sun jian
  2026-03-24  9:55 ` Fernando Fernandez Mancera
@ 2026-03-24 15:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-24 15:50 UTC (permalink / raw)
  To: Martin KaFai Lau; +Cc: bpf, ast, andrii, daniel, netdev, kuba, fmancera

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Mon, 23 Mar 2026 15:52:50 -0700 you wrote:
> From: Martin KaFai Lau <martin.lau@kernel.org>
> 
> bpf_prog_test_run_skb() uses net->ipv6.ip6_null_entry for
> BPF_PROG_TYPE_LWT_XMIT test runs.
> 
> It currently checks ipv6_bpf_stub before using ip6_null_entry.
> ipv6_bpf_stub will be removed by the CONFIG_IPV6=m support removal
> series posted at [1], so switch this check to ipv6_mod_enabled()
> instead.
> 
> [...]

Here is the summary with links:
  - [bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage
    https://git.kernel.org/bpf/bpf-next/c/280de43e88c0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-03-24 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 22:52 [PATCH bpf-next] bpf: test_run: Remove ipv6_bpf_stub usage Martin KaFai Lau
2026-03-24  2:16 ` sun jian
2026-03-24  9:55 ` Fernando Fernandez Mancera
2026-03-24 15:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox