[PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs

Fernando Fernandez Mancera posted 10 patches 2 weeks, 6 days ago
There is a newer version of this series
arch/arm64/configs/defconfig                  |   2 +-
arch/m68k/configs/amiga_defconfig             |  44 +-------
arch/m68k/configs/apollo_defconfig            |  44 +-------
arch/m68k/configs/atari_defconfig             |  44 +-------
arch/m68k/configs/bvme6000_defconfig          |  44 +-------
arch/m68k/configs/hp300_defconfig             |  44 +-------
arch/m68k/configs/mac_defconfig               |  44 +-------
arch/m68k/configs/multi_defconfig             |  44 +-------
arch/m68k/configs/mvme147_defconfig           |  44 +-------
arch/m68k/configs/mvme16x_defconfig           |  44 +-------
arch/m68k/configs/q40_defconfig               |  44 +-------
arch/m68k/configs/sun3_defconfig              |  44 +-------
arch/m68k/configs/sun3x_defconfig             |  44 +-------
drivers/infiniband/Kconfig                    |   1 -
drivers/infiniband/core/addr.c                |   3 +-
drivers/infiniband/hw/ocrdma/Kconfig          |   2 +-
drivers/infiniband/sw/rxe/rxe_net.c           |   6 +-
drivers/infiniband/ulp/ipoib/Kconfig          |   2 +-
drivers/net/Kconfig                           |   9 --
drivers/net/ethernet/broadcom/Kconfig         |   2 +-
drivers/net/ethernet/chelsio/Kconfig          |   2 +-
.../mellanox/mlx5/core/en/rep/neigh.c         |  12 ++-
.../ethernet/mellanox/mlx5/core/en/tc_tun.c   |   3 +-
.../mellanox/mlx5/core/en/tc_tun_encap.c      |   2 +-
.../mellanox/mlx5/core/en_accel/ipsec.c       |   1 -
.../net/ethernet/mellanox/mlx5/core/en_rep.c  |   1 -
.../net/ethernet/mellanox/mlx5/core/en_tc.c   |   1 -
drivers/net/ethernet/mellanox/mlxsw/Kconfig   |   1 -
.../ethernet/mellanox/mlxsw/spectrum_router.c |   9 +-
.../ethernet/mellanox/mlxsw/spectrum_span.c   |   3 +-
drivers/net/ethernet/netronome/Kconfig        |   1 -
.../ethernet/netronome/nfp/flower/action.c    |   2 +-
.../netronome/nfp/flower/tunnel_conf.c        |   9 +-
drivers/net/ethernet/sfc/tc_counters.c        |   2 +-
drivers/net/ethernet/sfc/tc_encap_actions.c   |   5 +-
drivers/net/geneve.c                          |   1 -
drivers/net/gtp.c                             |   2 +-
drivers/net/ovpn/peer.c                       |   3 +-
drivers/net/ovpn/udp.c                        |   3 +-
drivers/net/usb/cdc_mbim.c                    |  17 +--
drivers/net/vrf.c                             |   3 +-
drivers/net/vxlan/vxlan_core.c                |  11 +-
drivers/net/vxlan/vxlan_multicast.c           |   6 +-
drivers/net/wireguard/socket.c                |   3 +-
drivers/net/wireless/intel/ipw2x00/ipw2100.c  |   2 +-
drivers/scsi/bnx2fc/Kconfig                   |   1 -
drivers/scsi/bnx2i/Kconfig                    |   1 -
drivers/scsi/cxgbi/cxgb3i/Kconfig             |   2 +-
drivers/scsi/cxgbi/cxgb4i/Kconfig             |   2 +-
fs/dlm/Kconfig                                |   2 +-
fs/gfs2/Kconfig                               |   2 +-
include/linux/icmpv6.h                        |  26 +----
include/linux/indirect_call_wrapper.h         |   2 +-
include/linux/netfilter_ipv6.h                | 102 ++----------------
include/net/ip.h                              |   5 -
include/net/ip6_fib.h                         |  35 +++++-
include/net/ip6_route.h                       |  26 +++++
include/net/ipv6.h                            |  12 +++
include/net/ipv6_stubs.h                      | 101 -----------------
include/net/ndisc.h                           |  38 +++----
include/net/udp_tunnel.h                      |   3 +-
net/bridge/Kconfig                            |   1 -
net/bridge/br_arp_nd_proxy.c                  |   3 +-
net/bridge/br_netfilter_hooks.c               |  12 +--
net/bridge/br_netfilter_ipv6.c                |   7 +-
net/core/filter.c                             |  68 +++++-------
net/core/lwt_bpf.c                            |  10 +-
net/ieee802154/6lowpan/tx.c                   |   2 +-
net/ipv4/Kconfig                              |   9 +-
net/ipv4/fib_semantics.c                      |  11 +-
net/ipv4/icmp.c                               |   2 +-
net/ipv4/nexthop.c                            |  21 ++--
net/ipv4/route.c                              |   2 +-
net/ipv4/udp.c                                |   7 +-
net/ipv6/Kconfig                              |   6 +-
net/ipv6/addrconf.c                           |  10 +-
net/ipv6/addrconf_core.c                      |  91 ----------------
net/ipv6/af_inet6.c                           |  67 +-----------
net/ipv6/icmp.c                               |   6 --
net/ipv6/ip6_fib.c                            |  10 +-
net/ipv6/ip6_icmp.c                           |  46 +-------
net/ipv6/ip6_offload.c                        |   4 +-
net/ipv6/ip6_output.c                         |   5 +-
net/ipv6/ip6_udp_tunnel.c                     |   3 +-
net/ipv6/ndisc.c                              |  35 +++---
net/ipv6/netfilter.c                          |  48 ---------
net/ipv6/route.c                              |  13 +--
net/l2tp/Kconfig                              |   1 -
net/mpls/af_mpls.c                            |   3 +-
net/netfilter/Kconfig                         |   8 --
net/netfilter/core.c                          |   3 -
net/netfilter/nf_nat_masquerade.c             |  21 +---
net/netfilter/nfnetlink_queue.c               |  22 +++-
net/netfilter/utils.c                         |   1 -
net/openvswitch/actions.c                     |   3 +-
net/rxrpc/Kconfig                             |   2 +-
net/sched/sch_frag.c                          |   4 +-
net/sctp/Kconfig                              |   1 -
net/tipc/Kconfig                              |   1 -
net/tipc/udp_media.c                          |   9 +-
net/xfrm/espintcp.c                           |   5 +-
net/xfrm/xfrm_nat_keepalive.c                 |   4 +-
net/xfrm/xfrm_output.c                        |   3 +-
103 files changed, 324 insertions(+), 1286 deletions(-)
delete mode 100644 include/net/ipv6_stubs.h
[PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs
Posted by Fernando Fernandez Mancera 2 weeks, 6 days ago
Historically, the Linux kernel has supported compiling the IPv6 stack as
a loadable module. While this made sense in the early days of IPv6
adoption, modern deployments and distributions overwhelmingly either
build IPv6 directly into the kernel (CONFIG_IPV6=y) or disable it
entirely (CONFIG_IPV6=n). The modular IPv6 use-case offers image size
and memory savings for specific setups, this benefit is outweighed by
the architectural burden it imposes on the subsystems on implementation
and maintenance.

In addition, most of the distributions are already using CONFIG_IPV6=y
by default [1], including openWRT [2] and Android gki_defconfig [3]. So
this won't have an impact on them. The most impacted architecture would
probably be arm64 as their default config is still using CONFIG_IPV6=m. 

To allow core networking, BPF, Netfilter, and various device drivers to
safely interact with a potentially unloaded IPv6 module, the kernel
relies on indirect call structures like ipv6_stub, ipv6_bpf_stub, and
nf_ipv6_ops, along with dynamic RCU registrations for things like ICMPv6
senders.

This patch series addresses this by changing CONFIG_IPV6 from a tristate
to a boolean, enforcing that IPv6 is either built-in or disabled. This
allows us to completely rip out the stub infrastructures and safely
replace them with direct function calls.

The bloat-o-meter report the following results for m68k, arm64, x86_64
defconfig.

m68k (keep on mind that CONFIG_IPV6 is disabled now):
add/remove: 65/938 grow/shrink: 36/254 up/down: 3022/-49692 (-46670)

arm64:
add/remove: 1251/265 grow/shrink: 81/46 up/down: 448740/-71519 (377221)

x86_64:
add/remove: 62/98 grow/shrink: 10/39 up/down: 2497/-4357 (-1860)

Considering that each new kernel release increases sizes by 30-40KiB on
average, this size increase isn't a huge jump for the distributions that
are still using CONFIG_IPV6=m. For the ones that are already using
CONFIG_IPV6=y, the size is reduced actually.

All the patches has been independently build tested. With allmodconfig
and allmodconfig + CONFIG_IPV6=n. In addition, net selftest has been run
against them on virtme-ng.

The series applied as a whole as been tested with allyesconfig and also
allyesconfig + CONFIG_IPV6=n but not all patches has been independently
tested this way.

[1] https://github.com/nyrahul/linux-kernel-configs

[2] https://github.com/openwrt/openwrt/commit/832e7b817221d288df76b763ca12c585365db5d8

[3] https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/arch/arm64/configs/gki_defconfig


Changes:
  v3:
    Patch 1: bring back CONFIG_NET_FOU_IP_TUNNELS on m68k defconfigs and drop unrelated changes.
    Patch 4: add missing netlink error message indicating IPv6 is disabled
    Patch 8: use __inet6_bind() instead the alias that was just created.

  v2: https://lore.kernel.org/netdev/20260310153506.5181-1-fmancera@suse.de/
    Patch 1: change fs_initcall() to device_initcall() to avoid race condition and disable CONFIG_IPV6 on m68k defconfigs.

  v1: https://lore.kernel.org/netdev/20260309022013.5199-1-fmancera@suse.de/

Fernando Fernandez Mancera (10):
  ipv6: convert CONFIG_IPV6 to built-in only and clean up Kconfigs
  ipv6: replace IS_BUILTIN(CONFIG_IPV6) with IS_ENABLED(CONFIG_IPV6)
  ipv6: remove dynamic ICMPv6 sender registration infrastructure
  ipv6: prepare headers for ipv6_stub removal
  drivers: net: drop ipv6_stub usage and use direct function calls
  ipv4: drop ipv6_stub usage and use direct function calls
  net: convert remaining ipv6_stub users to direct function calls
  bpf: remove ipv6_bpf_stub completely and use direct function calls
  ipv6: remove ipv6_stub infrastructure completely
  netfilter: remove nf_ipv6_ops and use direct function calls

 arch/arm64/configs/defconfig                  |   2 +-
 arch/m68k/configs/amiga_defconfig             |  44 +-------
 arch/m68k/configs/apollo_defconfig            |  44 +-------
 arch/m68k/configs/atari_defconfig             |  44 +-------
 arch/m68k/configs/bvme6000_defconfig          |  44 +-------
 arch/m68k/configs/hp300_defconfig             |  44 +-------
 arch/m68k/configs/mac_defconfig               |  44 +-------
 arch/m68k/configs/multi_defconfig             |  44 +-------
 arch/m68k/configs/mvme147_defconfig           |  44 +-------
 arch/m68k/configs/mvme16x_defconfig           |  44 +-------
 arch/m68k/configs/q40_defconfig               |  44 +-------
 arch/m68k/configs/sun3_defconfig              |  44 +-------
 arch/m68k/configs/sun3x_defconfig             |  44 +-------
 drivers/infiniband/Kconfig                    |   1 -
 drivers/infiniband/core/addr.c                |   3 +-
 drivers/infiniband/hw/ocrdma/Kconfig          |   2 +-
 drivers/infiniband/sw/rxe/rxe_net.c           |   6 +-
 drivers/infiniband/ulp/ipoib/Kconfig          |   2 +-
 drivers/net/Kconfig                           |   9 --
 drivers/net/ethernet/broadcom/Kconfig         |   2 +-
 drivers/net/ethernet/chelsio/Kconfig          |   2 +-
 .../mellanox/mlx5/core/en/rep/neigh.c         |  12 ++-
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c   |   3 +-
 .../mellanox/mlx5/core/en/tc_tun_encap.c      |   2 +-
 .../mellanox/mlx5/core/en_accel/ipsec.c       |   1 -
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  |   1 -
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |   1 -
 drivers/net/ethernet/mellanox/mlxsw/Kconfig   |   1 -
 .../ethernet/mellanox/mlxsw/spectrum_router.c |   9 +-
 .../ethernet/mellanox/mlxsw/spectrum_span.c   |   3 +-
 drivers/net/ethernet/netronome/Kconfig        |   1 -
 .../ethernet/netronome/nfp/flower/action.c    |   2 +-
 .../netronome/nfp/flower/tunnel_conf.c        |   9 +-
 drivers/net/ethernet/sfc/tc_counters.c        |   2 +-
 drivers/net/ethernet/sfc/tc_encap_actions.c   |   5 +-
 drivers/net/geneve.c                          |   1 -
 drivers/net/gtp.c                             |   2 +-
 drivers/net/ovpn/peer.c                       |   3 +-
 drivers/net/ovpn/udp.c                        |   3 +-
 drivers/net/usb/cdc_mbim.c                    |  17 +--
 drivers/net/vrf.c                             |   3 +-
 drivers/net/vxlan/vxlan_core.c                |  11 +-
 drivers/net/vxlan/vxlan_multicast.c           |   6 +-
 drivers/net/wireguard/socket.c                |   3 +-
 drivers/net/wireless/intel/ipw2x00/ipw2100.c  |   2 +-
 drivers/scsi/bnx2fc/Kconfig                   |   1 -
 drivers/scsi/bnx2i/Kconfig                    |   1 -
 drivers/scsi/cxgbi/cxgb3i/Kconfig             |   2 +-
 drivers/scsi/cxgbi/cxgb4i/Kconfig             |   2 +-
 fs/dlm/Kconfig                                |   2 +-
 fs/gfs2/Kconfig                               |   2 +-
 include/linux/icmpv6.h                        |  26 +----
 include/linux/indirect_call_wrapper.h         |   2 +-
 include/linux/netfilter_ipv6.h                | 102 ++----------------
 include/net/ip.h                              |   5 -
 include/net/ip6_fib.h                         |  35 +++++-
 include/net/ip6_route.h                       |  26 +++++
 include/net/ipv6.h                            |  12 +++
 include/net/ipv6_stubs.h                      | 101 -----------------
 include/net/ndisc.h                           |  38 +++----
 include/net/udp_tunnel.h                      |   3 +-
 net/bridge/Kconfig                            |   1 -
 net/bridge/br_arp_nd_proxy.c                  |   3 +-
 net/bridge/br_netfilter_hooks.c               |  12 +--
 net/bridge/br_netfilter_ipv6.c                |   7 +-
 net/core/filter.c                             |  68 +++++-------
 net/core/lwt_bpf.c                            |  10 +-
 net/ieee802154/6lowpan/tx.c                   |   2 +-
 net/ipv4/Kconfig                              |   9 +-
 net/ipv4/fib_semantics.c                      |  11 +-
 net/ipv4/icmp.c                               |   2 +-
 net/ipv4/nexthop.c                            |  21 ++--
 net/ipv4/route.c                              |   2 +-
 net/ipv4/udp.c                                |   7 +-
 net/ipv6/Kconfig                              |   6 +-
 net/ipv6/addrconf.c                           |  10 +-
 net/ipv6/addrconf_core.c                      |  91 ----------------
 net/ipv6/af_inet6.c                           |  67 +-----------
 net/ipv6/icmp.c                               |   6 --
 net/ipv6/ip6_fib.c                            |  10 +-
 net/ipv6/ip6_icmp.c                           |  46 +-------
 net/ipv6/ip6_offload.c                        |   4 +-
 net/ipv6/ip6_output.c                         |   5 +-
 net/ipv6/ip6_udp_tunnel.c                     |   3 +-
 net/ipv6/ndisc.c                              |  35 +++---
 net/ipv6/netfilter.c                          |  48 ---------
 net/ipv6/route.c                              |  13 +--
 net/l2tp/Kconfig                              |   1 -
 net/mpls/af_mpls.c                            |   3 +-
 net/netfilter/Kconfig                         |   8 --
 net/netfilter/core.c                          |   3 -
 net/netfilter/nf_nat_masquerade.c             |  21 +---
 net/netfilter/nfnetlink_queue.c               |  22 +++-
 net/netfilter/utils.c                         |   1 -
 net/openvswitch/actions.c                     |   3 +-
 net/rxrpc/Kconfig                             |   2 +-
 net/sched/sch_frag.c                          |   4 +-
 net/sctp/Kconfig                              |   1 -
 net/tipc/Kconfig                              |   1 -
 net/tipc/udp_media.c                          |   9 +-
 net/xfrm/espintcp.c                           |   5 +-
 net/xfrm/xfrm_nat_keepalive.c                 |   4 +-
 net/xfrm/xfrm_output.c                        |   3 +-
 103 files changed, 324 insertions(+), 1286 deletions(-)
 delete mode 100644 include/net/ipv6_stubs.h

-- 
2.53.0
Re: [PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs
Posted by Jakub Kicinski 2 weeks, 6 days ago
On Tue, 17 Mar 2026 15:00:56 +0100 Fernando Fernandez Mancera wrote:
> Historically, the Linux kernel has supported compiling the IPv6 stack as
> a loadable module. While this made sense in the early days of IPv6
> adoption, modern deployments and distributions overwhelmingly either
> build IPv6 directly into the kernel (CONFIG_IPV6=y) or disable it
> entirely (CONFIG_IPV6=n). The modular IPv6 use-case offers image size
> and memory savings for specific setups, this benefit is outweighed by
> the architectural burden it imposes on the subsystems on implementation
> and maintenance.

Hi Fernando,

NIPA flags a few failures, still:

https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2026-03-17--18-00&pw-n=0&pass=0

See stderr for stack trace. The BPF build issue seems to be:

  ../net/bpf/test_run.c:1160:8: error: use of undeclared identifier 'ipv6_bpf_stub'
   1160 |                 if (!ipv6_bpf_stub) {
        |                      ^~~~~~~~~~~~~
  1 error generated.
  make[5]: *** [../scripts/Makefile.build:289: net/bpf/test_run.o] Error 1
  make[4]: *** [../scripts/Makefile.build:546: net/bpf] Error 2
  make[4]: *** Waiting for unfinished jobs....
-- 
pw-bot: cr
Re: [PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs
Posted by Fernando Fernandez Mancera 2 weeks, 5 days ago
On 3/17/26 8:49 PM, Jakub Kicinski wrote:
> On Tue, 17 Mar 2026 15:00:56 +0100 Fernando Fernandez Mancera wrote:
>> Historically, the Linux kernel has supported compiling the IPv6 stack as
>> a loadable module. While this made sense in the early days of IPv6
>> adoption, modern deployments and distributions overwhelmingly either
>> build IPv6 directly into the kernel (CONFIG_IPV6=y) or disable it
>> entirely (CONFIG_IPV6=n). The modular IPv6 use-case offers image size
>> and memory savings for specific setups, this benefit is outweighed by
>> the architectural burden it imposes on the subsystems on implementation
>> and maintenance.
> 
> Hi Fernando,
> 
> NIPA flags a few failures, still:
> 
> https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2026-03-17--18-00&pw-n=0&pass=0
> 

Hi Jakub,

This is test is applying the series in top of bpf tree which has this 
commit 
https://github.com/kernel-patches/bpf/commit/972787479ee73006fddb5e59ab5c8e733810ff42

AFAICS, net-next tree do not have it yet. I do not think I can do much 
about it for now. Will wait until they are merged and rebase in top of it.

Thanks,
Fernando.

> See stderr for stack trace. The BPF build issue seems to be:
> 
>    ../net/bpf/test_run.c:1160:8: error: use of undeclared identifier 'ipv6_bpf_stub'
>     1160 |                 if (!ipv6_bpf_stub) {
>          |                      ^~~~~~~~~~~~~
>    1 error generated.
>    make[5]: *** [../scripts/Makefile.build:289: net/bpf/test_run.o] Error 1
>    make[4]: *** [../scripts/Makefile.build:546: net/bpf] Error 2
>    make[4]: *** Waiting for unfinished jobs....
Re: [PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs
Posted by Jakub Kicinski 2 weeks, 4 days ago
On Wed, 18 Mar 2026 11:19:06 +0100 Fernando Fernandez Mancera wrote:
> > NIPA flags a few failures, still:
> > 
> > https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2026-03-17--18-00&pw-n=0&pass=0
> >   
> 
> Hi Jakub,
> 
> This is test is applying the series in top of bpf tree which has this 
> commit 
> https://github.com/kernel-patches/bpf/commit/972787479ee73006fddb5e59ab5c8e733810ff42
> 
> AFAICS, net-next tree do not have it yet. I do not think I can do much 
> about it for now. Will wait until they are merged and rebase in top of it.

I see, hopefully trees converge tomorrow, else we can fix it when
merging. But the RCU warnings in forwarding can't be a BPF problem,
right?
Re: [PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs
Posted by Jakub Kicinski 2 weeks, 4 days ago
On Wed, 18 Mar 2026 16:21:34 -0700 Jakub Kicinski wrote:
> > This is test is applying the series in top of bpf tree which has this 
> > commit 
> > https://github.com/kernel-patches/bpf/commit/972787479ee73006fddb5e59ab5c8e733810ff42
> > 
> > AFAICS, net-next tree do not have it yet. I do not think I can do much 
> > about it for now. Will wait until they are merged and rebase in top of it.  
> 
> I see, hopefully trees converge tomorrow, else we can fix it when
> merging.

Looking closer and talking to Alexei the fix is actually in bpf-next
not in bpf. So let's just merge your code and we'll deal with the
fallout. But please still look into the fowarding warnings, of course.
Re: [PATCH 00/10 net-next v3] Convert CONFIG_IPV6 to built-in and remove stubs
Posted by Fernando Fernandez Mancera 2 weeks, 4 days ago
On 3/19/26 1:48 AM, Jakub Kicinski wrote:
> On Wed, 18 Mar 2026 16:21:34 -0700 Jakub Kicinski wrote:
>>> This is test is applying the series in top of bpf tree which has this
>>> commit
>>> https://github.com/kernel-patches/bpf/commit/972787479ee73006fddb5e59ab5c8e733810ff42
>>>
>>> AFAICS, net-next tree do not have it yet. I do not think I can do much
>>> about it for now. Will wait until they are merged and rebase in top of it.
>>
>> I see, hopefully trees converge tomorrow, else we can fix it when
>> merging.
> 
> Looking closer and talking to Alexei the fix is actually in bpf-next
> not in bpf. So let's just merge your code and we'll deal with the
> fallout. But please still look into the fowarding warnings, of course.
> 

Yes I already handled the forwarding warnings. I am surprised this 
wasn't spotted by the AI :/

Thanks,
Fernando.