]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Remove ipv6_bpf_stub usage in test_run
authorMartin KaFai Lau <martin.lau@kernel.org>
Mon, 23 Mar 2026 22:52:50 +0000 (15:52 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 24 Mar 2026 15:47:33 +0000 (08:47 -0700)
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>
Reviewed-by: Sun Jian <sun.jian.kdev@gmail.com>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Link: https://lore.kernel.org/r/20260323225250.1623542-1-martin.lau@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/bpf/test_run.c

index 56bc8dc1e28114af153c6c1de3e909d7f4347785..fb25184ed03b596c0d08bb1f6a88844c36874215 100644 (file)
@@ -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