Re: [PATCH 08/10 net-next v2] bpf: remove ipv6_bpf_stub completely and use direct function calls
From: Daniel Borkmann
Date: Thu Mar 12 2026 - 06:19:05 EST
On 3/10/26 4:34 PM, Fernando Fernandez Mancera wrote:
As IPv6 is built-in only, the ipv6_bpf_stub can be removed completely.
Convert all ipv6_bpf_stub usage to direct function calls instead. The
fallback functions introduced previously will prevent linkage errors
when CONFIG_IPV6 is disabled.
Signed-off-by: Fernando Fernandez Mancera <fmancera@xxxxxxx>
[...]
@@ -6000,11 +5996,9 @@ BPF_CALL_3(bpf_bind, struct bpf_sock_addr_kern *, ctx, struct sockaddr *, addr,
return err;
if (((struct sockaddr_in6 *)addr)->sin6_port == htons(0))
flags |= BIND_FORCE_ADDRESS_NO_PORT;
- /* ipv6_bpf_stub cannot be NULL, since it's called from
- * bpf_cgroup_inet6_connect hook and ipv6 is already loaded
- */
- return ipv6_bpf_stub->inet6_bind(sk, (struct sockaddr_unsized *)addr,
- addr_len, flags);
+
+ return inet6_bind_flags(sk, (struct sockaddr_unsized *)addr,
+ addr_len, flags);
nit: You're adding the inet6_bind_flags just as an alias for __inet6_bind, might as
well just call the latter directly like we do in IPv4 case further above.
[...]> @@ -6283,12 +6277,11 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
params->tbid = 0;
}
- tb = ipv6_stub->fib6_get_table(net, tbid);
+ tb = fib6_get_table(net, tbid);
if (unlikely(!tb))
return BPF_FIB_LKUP_RET_NOT_FWDED;
- err = ipv6_stub->fib6_table_lookup(net, tb, oif, &fl6, &res,
- strict);
+ err = fib6_table_lookup(net, tb, oif, &fl6, &res, strict);
} else {
if (flags & BPF_FIB_LOOKUP_MARK)
fl6.flowi6_mark = params->mark;
Love it, for the bpf_ipv6_fib_lookup we're now able to get rid of 3 subsequent
indirect calls in fast-path (ipv6_stub->fib6_lookup + ipv6_stub->fib6_select_path +
ipv6_bpf_stub->ipv6_dev_get_saddr in case BPF prog requested to fill src IP).
[...]
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c(wrt above comment)
index 448be9704313..75a9d9fe1308 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -460,6 +460,12 @@ int inet6_bind_sk(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len)
return __inet6_bind(sk, uaddr, addr_len, flags);
}
+int inet6_bind_flags(struct sock *sk, struct sockaddr_unsized *uaddr,
+ int addr_len, u32 flags)
+{
+ return __inet6_bind(sk, uaddr, addr_len, flags);
+}
+
Acked-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
Thanks,
Daniel