Skip to contentSkip to conversation

bpf: test_run: Remove ipv6_bpf_stub usage

PATCH Applied Martin KaFai Lau 4 participants 4 messages Mar 23 – Mar 24

Subsystems (3)
lore
Share & tools
lore

Martin KaFai Lau

author reviewer
#0 lore raw

PATCH 1/1 bpf: test_run: Remove ipv6_bpf_stub usage

From: Martin KaFai Lau <[email protected]>

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/[email protected]/

Cc Jakub Kicinski <[email protected]>
Cc Fernando Fernandez Mancera <[email protected]>
---
 net/bpf/test_run.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/bpf/test_run.c +2 -5
index 56bc8dc1e281..fb25184ed03b 100644
@@ -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
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 47 lines · Martin KaFai Lau

From: Martin KaFai Lau <[email protected]>

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/[email protected]/

Cc Jakub Kicinski <[email protected]>
Cc Fernando Fernandez Mancera <[email protected]>
---
 net/bpf/test_run.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/bpf/test_run.c +2 -6
index 56bc8dc1e281..fb25184ed03b 100644
@@ -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
--
Quoted 3 lines

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 on v1 1/1
#2 lore raw
In reply to Martin KaFai Lau
Quoted 14 lines · Martin KaFai Lau

From: Martin KaFai Lau <[email protected]>

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.

Quoted 6 lines

[1] https://lore.kernel.org/netdev/[email protected]/

Cc Jakub Kicinski <[email protected]>
Cc Fernando Fernandez Mancera <[email protected]>

---

LGTM!

#3 lore raw
In reply to Martin KaFai Lau
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 11 lines · On Mon, 23 Mar 2026 15:52:50 -0700 you wrote:

From: Martin KaFai Lau <[email protected]>

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html