Allow compiling an IPv6-only kernel network stack
Subsystems (48)
cover Allow compiling an IPv6-only kernel network stack
The primary goal of this patch series is to enable the compilation of an IPv6-only kernel by decoupling the core networking infrastructure from the IPv4 protocol.
Historically, IPv4 has been intertwined with the generic socket and transport layers. By untangling these dependencies, this series allows systems to be built with CONFIG_IPV4 disabled. This configuration targets strict IPv6-only deployments, constrained environments, and specialized appliances where removing the IPv4 subsystem reduces the network attack surface.
To achieve this, subsystems with hard dependencies on IPv4 were modified to use conditional compilation guards. When CONFIG_IPV4 is disabled, the affected packet manipulation routines and routing hooks evaluate to stubs returning standard error codes. The INDIRECT_CALL_INET macros within the transport layer were adapted to safely bypass IPv4 function pointers without penalizing the dual-stack fast paths. In addition, there has been several code splits for UDP, RAW, ICMP or Ping isolating the IPv4 specific code.
Finally, CONFIG_IPV4 is exposed in Kconfig as an explicit boolean, defaulting to 'y' to preserve existing configurations.
The bloat-o-meter diff for x86_64 with dualstack and IPv6 disabled:
text data bss dec hex filename
31211950 8946390 1121076 41279416 275dfb8 vmlinux.dual 27464679 8008670 1069040 36542389 22d97b5 vmlinux.ipv6
add/remove: 52/25057 grow/shrink: 58/565 up/down: 937258/-4632671 (-3695413)
Performance testing:
Basic TCP performance validation was conducted using iperf3 on an AMD Ryzen 9 9950X between two bridged virtual machines. These benchmarks verify that there are no obvious performance regressions.
Kernel / Configuration Traffic Type Offloads ON Offloads OFF
-------------------------------------------------------------------------------
net-next (Dual-Stack Baseline) IPv4 20.8 Gbps 7.22 Gbps net-next (Dual-Stack Baseline) IPv6 20.4 Gbps 7.55 Gbps net-next (IPv4-Only Baseline) IPv4 20.9 Gbps 7.86 Gbps
Patched (Dual-Stack) IPv4 21.8 Gbps 7.77 Gbps Patched (Dual-Stack) IPv6 21.7 Gbps 7.35 Gbps Patched (IPv4-Only) IPv4 20.9 Gbps 7.91 Gbps Patched (IPv6-Only) IPv6 21.1 Gbps 8.06 Gbps
Follow-up for this series:
Future work decoupled from this initial series includes expanding Kconfig adaptations across remaining kernel subsystems to support an IPv6-only environment. This includes patches for network bonding modes that assume dual-stack availability and analyze Netfilter nftables expressions and connection tracking to ensure pure IPv6 operations are fully independent.
The main burden the series introduce is the noise in git which will be cumbersome when trying to identify breaking commits or blames and the risks of regressions.
Fernando Fernandez Mancera (13):
net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
net: core: add IPv4 fallback stubs and guards for CONFIG_IPV4=n
net: inet: relocate ip_generic_getfrag and guard IPv4 socket logic
net: tcp: move protocol agnostic TCP functions out of tcp_ipv4.c
net: raw: split IPv4 specific logic into raw_ipv4.c
net: udp: split IPv4 specific logic into udp_ipv4.c
net: icmp: split IPv4 specific logic into icmp_ipv4.c
net: ping: split IPv4 specific logic into ping_ipv4.c
net: fib: split common nexthop logic to fib_core.c
net: tunnel: guard IPv4 tunnel functions with CONFIG_IPV4
netfilter: ipv4: guard ip_route_me_harder() with CONFIG_IPV4
net: ipv4: disable IPv4-only sysctls when CONFIG_IPV4=n
net: ipv4: make CONFIG_IPV4 boolean
drivers/infiniband/Kconfig | 2 +- drivers/net/Kconfig | 24 +- drivers/net/ethernet/broadcom/Kconfig | 2 + drivers/net/ethernet/chelsio/Kconfig | 2 +- drivers/net/ethernet/intel/Kconfig | 2 + drivers/net/ethernet/marvell/prestera/Kconfig | 1 + .../net/ethernet/mellanox/mlx5/core/Kconfig | 3 +- drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 + drivers/net/ethernet/netronome/Kconfig | 1 + drivers/net/ethernet/qlogic/Kconfig | 2 + drivers/net/ethernet/sfc/Kconfig | 1 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 + drivers/net/ethernet/via/Kconfig | 1 + drivers/net/ppp/Kconfig | 1 + .../broadcom/brcm80211/brcmfmac/Kconfig | 1 + drivers/net/wireless/intel/iwlwifi/Kconfig | 1 + drivers/nvme/host/Kconfig | 2 +- drivers/nvme/target/Kconfig | 2 +- drivers/scsi/bnx2fc/Kconfig | 1 + drivers/scsi/bnx2i/Kconfig | 1 + drivers/scsi/cxgbi/cxgb3i/Kconfig | 2 +- drivers/scsi/cxgbi/cxgb4i/Kconfig | 2 +- drivers/target/iscsi/Kconfig | 2 +- fs/Kconfig | 1 + fs/afs/Kconfig | 2 +- fs/nfs/Kconfig | 2 +- fs/nfsd/Kconfig | 2 +- include/linux/indirect_call_wrapper.h | 8 +- include/net/icmp.h | 1 + include/net/ip.h | 104 +- include/net/ip_fib.h | 27 +- include/net/route.h | 14 + include/net/tcp.h | 16 +- net/Kconfig | 11 +- net/batman-adv/Kconfig | 1 + net/bridge/Kconfig | 3 +- net/bridge/netfilter/Kconfig | 6 +- net/core/Makefile | 2 +- net/core/dev_ioctl.c | 4 + net/core/fib_core.c | 307 +++ net/core/filter.c | 24 +- net/core/neighbour.c | 5 + net/ipv4/Kconfig | 29 +- net/ipv4/Makefile | 24 +- net/ipv4/af_inet.c | 124 +- net/ipv4/fib_frontend.c | 96 - net/ipv4/fib_semantics.c | 205 -- net/ipv4/icmp.c | 1419 +------------ net/ipv4/icmp_ipv4.c | 1445 +++++++++++++ net/ipv4/inet_connection_sock.c | 2 +- net/ipv4/inet_hashtables.c | 4 + net/ipv4/ip_output.c | 18 - net/ipv4/ip_tunnel_core.c | 11 + net/ipv4/netfilter.c | 4 + net/ipv4/netfilter/Kconfig | 2 +- net/ipv4/netlink.c | 2 + net/ipv4/nexthop.c | 9 +- net/ipv4/ping.c | 215 +- net/ipv4/ping_ipv4.c | 228 +++ net/ipv4/proc.c | 38 +- net/ipv4/raw.c | 853 -------- net/ipv4/raw_diag.c | 4 + net/ipv4/raw_ipv4.c | 883 ++++++++ net/ipv4/sysctl_net_ipv4.c | 32 +- net/ipv4/tcp.c | 1299 ++++++++++++ net/ipv4/tcp_bpf.c | 2 + net/ipv4/tcp_ipv4.c | 1307 +----------- net/ipv4/udp.c | 1781 +--------------- net/ipv4/udp_bpf.c | 6 + net/ipv4/udp_diag.c | 12 + net/ipv4/udp_ipv4.c | 1790 +++++++++++++++++ net/ipv4/udp_offload.c | 10 + net/ipv6/Kconfig | 17 +- net/ipv6/af_inet6.c | 5 + net/ipv6/datagram.c | 14 + net/ipv6/netfilter/Kconfig | 2 +- net/ipv6/tcp_ipv6.c | 25 +- net/ipv6/udp.c | 18 + net/l2tp/Kconfig | 2 +- net/mac80211/Kconfig | 2 +- net/mpls/Kconfig | 1 + net/mptcp/Kconfig | 2 +- net/netfilter/Kconfig | 2 +- net/netfilter/ipset/Kconfig | 2 +- net/netfilter/ipvs/Kconfig | 2 +- net/openvswitch/Kconfig | 2 +- net/packet/Kconfig | 1 + net/rds/Kconfig | 2 +- net/rxrpc/Kconfig | 2 +- net/sched/Kconfig | 2 +- net/sctp/Kconfig | 2 +- net/smc/Kconfig | 2 +- net/sunrpc/Kconfig | 2 +- net/tipc/Kconfig | 2 +- net/xfrm/Kconfig | 12 +- security/smack/Kconfig | 1 + 96 files changed, 6585 insertions(+), 5991 deletions(-) create mode 100644 net/core/fib_core.c create mode 100644 net/ipv4/icmp_ipv4.c create mode 100644 net/ipv4/ping_ipv4.c create mode 100644 net/ipv4/raw_ipv4.c create mode 100644 net/ipv4/udp_ipv4.c
Signature · 1 line
2.55.0
PATCH 1/13 net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.
This patch introduces the CONFIG_IPV4 Kconfig symbol, which is set to 'def_bool y' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.
In addition, multiple subsystems Kconfig symbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert the Kconfig symbol to bool and remove the dependency on IPv4 where it makes sense.
--- drivers/infiniband/Kconfig | 2 +- drivers/net/Kconfig | 24 ++++++++++--------- drivers/net/ethernet/broadcom/Kconfig | 2 ++ drivers/net/ethernet/chelsio/Kconfig | 2 +- drivers/net/ethernet/intel/Kconfig | 2 ++ drivers/net/ethernet/marvell/prestera/Kconfig | 1 + .../net/ethernet/mellanox/mlx5/core/Kconfig | 3 ++- drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 + drivers/net/ethernet/netronome/Kconfig | 1 + drivers/net/ethernet/qlogic/Kconfig | 2 ++ drivers/net/ethernet/sfc/Kconfig | 1 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 + drivers/net/ethernet/via/Kconfig | 1 + drivers/net/ppp/Kconfig | 1 + .../broadcom/brcm80211/brcmfmac/Kconfig | 1 + drivers/net/wireless/intel/iwlwifi/Kconfig | 1 + drivers/nvme/host/Kconfig | 2 +- drivers/nvme/target/Kconfig | 2 +- drivers/scsi/bnx2fc/Kconfig | 1 + drivers/scsi/bnx2i/Kconfig | 1 + drivers/scsi/cxgbi/cxgb3i/Kconfig | 2 +- drivers/scsi/cxgbi/cxgb4i/Kconfig | 2 +- drivers/target/iscsi/Kconfig | 2 +- fs/Kconfig | 1 + fs/afs/Kconfig | 2 +- fs/nfs/Kconfig | 2 +- fs/nfsd/Kconfig | 2 +- net/Kconfig | 11 +++++---- net/batman-adv/Kconfig | 1 + net/bridge/Kconfig | 3 ++- net/bridge/netfilter/Kconfig | 6 ++--- net/ipv4/Kconfig | 21 +++++++++++++--- net/ipv4/Makefile | 21 ++++++++-------- net/ipv4/netfilter/Kconfig | 2 +- net/ipv6/Kconfig | 17 +++++++++---- net/ipv6/netfilter/Kconfig | 2 +- net/l2tp/Kconfig | 2 +- net/mac80211/Kconfig | 2 +- net/mpls/Kconfig | 1 + net/mptcp/Kconfig | 2 +- net/netfilter/Kconfig | 2 +- net/netfilter/ipset/Kconfig | 2 +- net/netfilter/ipvs/Kconfig | 2 +- net/openvswitch/Kconfig | 2 +- net/packet/Kconfig | 1 + net/rds/Kconfig | 2 +- net/rxrpc/Kconfig | 2 +- net/sched/Kconfig | 2 +- net/sctp/Kconfig | 2 +- net/smc/Kconfig | 2 +- net/sunrpc/Kconfig | 2 +- net/tipc/Kconfig | 2 +- net/xfrm/Kconfig | 12 ++++++++-- security/smack/Kconfig | 1 + 54 files changed, 126 insertions(+), 66 deletions(-)
drivers/infiniband/Kconfig +1 -1
@@ -3,7 +3,7 @@ menuconfig INFINIBAND tristate "InfiniBand support" depends on HAS_IOMEM && HAS_DMA depends on NET - depends on INET + depends on INET && IPV4 depends on !ALPHA select DMA_SHARED_BUFFER select IRQ_POLL
drivers/net/Kconfig +13 -11
@@ -40,7 +40,7 @@ if NET_CORE config BONDING tristate "Bonding driver support" - depends on INET + depends on INET && IPV4 depends on TLS || TLS_DEVICE=n help Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet
@@ -73,7 +73,7 @@ config DUMMY config WIREGUARD tristate "WireGuard secure network tunnel" - depends on NET && INET + depends on NET && INET && IPV4 select NET_UDP_TUNNEL select DST_CACHE select CRYPTO_LIB_CURVE25519
@@ -102,7 +102,7 @@ config WIREGUARD_DEBUG config OVPN tristate "OpenVPN data channel offload" - depends on NET && INET + depends on NET && INET && IPV4 select DST_CACHE select NET_UDP_TUNNEL select CRYPTO
@@ -164,6 +164,7 @@ source "drivers/net/team/Kconfig" config MACVLAN tristate "MAC-VLAN support" + depends on IPV4 help This allows one to create virtual interfaces that map packets to or from specific MAC addresses to a particular interface.
@@ -198,7 +199,7 @@ config IPVLAN_L3S config IPVLAN tristate "IP-VLAN support" - depends on INET + depends on INET && IPV4 help This allows one to create virtual devices off of a main interface and packets will be delivered based on the dest L3 (IPv6/IPv4 addr)
@@ -229,7 +230,7 @@ config IPVTAP config VXLAN tristate "Virtual eXtensible Local Area Network (VXLAN)" - depends on INET + depends on INET && IPV4 select NET_UDP_TUNNEL select GRO_CELLS help
@@ -244,7 +245,7 @@ config VXLAN config GENEVE tristate "Generic Network Virtualization Encapsulation" - depends on INET + depends on INET && IPV4 select NET_UDP_TUNNEL select GRO_CELLS help
@@ -259,7 +260,7 @@ config GENEVE config BAREUDP tristate "Bare UDP Encapsulation" - depends on INET + depends on INET && IPV4 select NET_UDP_TUNNEL select GRO_CELLS help
@@ -271,7 +272,7 @@ config BAREUDP config GTP tristate "GPRS Tunneling Protocol datapath (GTP-U)" - depends on INET + depends on INET && IPV4 select NET_UDP_TUNNEL help This allows one to create gtp virtual interfaces that provide
@@ -288,7 +289,7 @@ config GTP config PFCP tristate "Packet Forwarding Control Protocol (PFCP)" - depends on INET + depends on INET && IPV4 select NET_UDP_TUNNEL help This allows one to create PFCP virtual interfaces that allows to
@@ -301,7 +302,7 @@ config PFCP config AMT tristate "Automatic Multicast Tunneling (AMT)" - depends on INET && IP_MULTICAST + depends on INET && IP_MULTICAST && IPV4 select NET_UDP_TUNNEL help This allows one to create AMT(Automatic Multicast Tunneling)
@@ -471,6 +472,7 @@ config NETKIT config NET_VRF tristate "Virtual Routing and Forwarding (Lite)" + depends on IPV4 depends on IP_MULTIPLE_TABLES depends on NET_L3_MASTER_DEV depends on IPV6_MULTIPLE_TABLES || IPV6=n
@@ -604,7 +606,7 @@ source "drivers/net/hyperv/Kconfig" config NETDEVSIM tristate "Simulated networking device" depends on DEBUG_FS - depends on INET + depends on INET && IPV4 depends on PSAMPLE || PSAMPLE=n depends on PTP_1588_CLOCK_MOCK || PTP_1588_CLOCK_MOCK=n select NET_DEVLINK
drivers/net/ethernet/broadcom/Kconfig +2 -0
@@ -97,6 +97,7 @@ config BNX2 config CNIC tristate "QLogic CNIC support" + depends on IPV4 depends on PCI select BNX2 select UIO
@@ -208,6 +209,7 @@ config BNXT tristate "Broadcom NetXtreme-C/E support" depends on PCI depends on PTP_1588_CLOCK_OPTIONAL + depends on IPV4 select FW_LOADER select CRC32 select NET_DEVLINK
drivers/net/ethernet/chelsio/Kconfig +1 -1
@@ -48,7 +48,7 @@ config CHELSIO_T1_1G config CHELSIO_T3 tristate "Chelsio Communications T3 10Gb Ethernet support" - depends on PCI && INET + depends on PCI && INET && IPV4 select FW_LOADER select MDIO help
drivers/net/ethernet/intel/Kconfig +2 -0
@@ -193,6 +193,7 @@ config IXGBE_DCB config IXGBE_IPSEC bool "IPSec XFRM cryptography-offload acceleration" + depends on IPV4 depends on IXGBE depends on XFRM_OFFLOAD default y
@@ -219,6 +220,7 @@ config IXGBEVF config IXGBEVF_IPSEC bool "IPSec XFRM cryptography-offload acceleration" + depends on IPV4 depends on IXGBEVF depends on XFRM_OFFLOAD default y
drivers/net/ethernet/marvell/prestera/Kconfig +1 -0
@@ -7,6 +7,7 @@ config PRESTERA tristate "Marvell Prestera Switch ASICs support" depends on NET_SWITCHDEV && VLAN_8021Q depends on BRIDGE || BRIDGE=n + depends on IPV4 select NET_DEVLINK select PHYLINK help
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +2 -1
@@ -12,6 +12,7 @@ config MLX5_CORE depends on PTP_1588_CLOCK_OPTIONAL depends on PCI_HYPERV_INTERFACE || !PCI_HYPERV_INTERFACE depends on HWMON || !HWMON + depends on IPV4 help Core driver for low level functionality of the ConnectX-4 and Connect-IB cards by Mellanox Technologies.
@@ -28,7 +29,7 @@ config MLX5_FPGA config MLX5_CORE_EN bool "Mellanox 5th generation network adapters (ConnectX series) Ethernet support" - depends on NETDEVICES && ETHERNET && INET && PCI && MLX5_CORE + depends on NETDEVICES && ETHERNET && INET && PCI && MLX5_CORE && IPV4 select PAGE_POOL select PAGE_POOL_STATS select DIMLIB
drivers/net/ethernet/mellanox/mlxsw/Kconfig +1 -0
@@ -53,6 +53,7 @@ config MLXSW_I2C config MLXSW_SPECTRUM tristate "Mellanox Technologies Spectrum family support" + depends on IPV4 depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && VLAN_8021Q depends on PSAMPLE || PSAMPLE=n depends on BRIDGE || BRIDGE=n
drivers/net/ethernet/netronome/Kconfig +1 -0
@@ -18,6 +18,7 @@ if NET_VENDOR_NETRONOME config NFP tristate "Netronome(R) NFP4000/NFP6000 NIC driver" + depends on IPV4 depends on PCI_MSI depends on VXLAN || VXLAN=n depends on TLS && TLS_DEVICE || TLS_DEVICE=n
drivers/net/ethernet/qlogic/Kconfig +2 -0
@@ -29,6 +29,7 @@ config QLA3XXX config QLCNIC tristate "QLOGIC QLCNIC 1/10Gb Converged Ethernet NIC Support" depends on PCI + depends on IPV4 select FW_LOADER help This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet
@@ -68,6 +69,7 @@ config QLCNIC_HWMON config NETXEN_NIC tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC" + depends on IPV4 depends on PCI select FW_LOADER help
drivers/net/ethernet/sfc/Kconfig +1 -0
@@ -18,6 +18,7 @@ if NET_VENDOR_SOLARFLARE config SFC tristate "Solarflare SFC9100/EF100-family support" + depends on IPV4 depends on PCI depends on PTP_1588_CLOCK_OPTIONAL select MDIO
drivers/net/ethernet/stmicro/stmmac/Kconfig +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config STMMAC_ETH tristate "STMicroelectronics Multi-Gigabit Ethernet driver" + depends on IPV4 depends on HAS_IOMEM && HAS_DMA depends on PTP_1588_CLOCK_OPTIONAL depends on ETHTOOL_NETLINK
drivers/net/ethernet/via/Kconfig +1 -0
@@ -45,6 +45,7 @@ config VIA_RHINE_MMIO config VIA_VELOCITY tristate "VIA Velocity support" + depends on IPV4 depends on (PCI || (OF_ADDRESS && OF_IRQ)) depends on HAS_DMA select CRC32
drivers/net/ppp/Kconfig +1 -0
@@ -160,6 +160,7 @@ config PPPOE_HASH_BITS config PPTP tristate "PPP over IPv4 (PPTP)" + depends on IPV4 depends on NET_IPGRE_DEMUX select PPPOX help
drivers/net/wireless/broadcom/brcm80211/brcmfmac/Kconfig +1 -0
@@ -1,6 +1,7 @@ config BRCMFMAC tristate "Broadcom FullMAC WLAN driver" depends on CFG80211 + depends on IPV4 select BRCMUTIL help This module adds support for wireless adapters based on Broadcom
drivers/net/wireless/intel/iwlwifi/Kconfig +1 -0
@@ -2,6 +2,7 @@ config IWLWIFI tristate "Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlwifi) " depends on PCI && HAS_IOMEM && CFG80211 + depends on IPV4 depends on IWLMEI || !IWLMEI select FW_LOADER help
drivers/nvme/host/Kconfig +1 -1
@@ -82,7 +82,7 @@ config NVME_FC config NVME_TCP tristate "NVM Express over Fabrics TCP host driver" - depends on INET + depends on INET && IPV4 depends on BLOCK select CRC32 select NET_CRC32C
drivers/nvme/target/Kconfig +1 -1
@@ -86,7 +86,7 @@ config NVME_TARGET_FCLOOP config NVME_TARGET_TCP tristate "NVMe over Fabrics TCP target support" - depends on INET + depends on INET && IPV4 depends on NVME_TARGET help This enables the NVMe TCP target support, which allows exporting NVMe
drivers/scsi/bnx2fc/Kconfig +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SCSI_BNX2X_FCOE tristate "QLogic FCoE offload support" + depends on IPV4 depends on PCI depends on LIBFC depends on LIBFCOE
drivers/scsi/bnx2i/Kconfig +1 -0
@@ -2,6 +2,7 @@ config SCSI_BNX2_ISCSI tristate "QLogic NetXtreme II iSCSI support" depends on NET + depends on IPV4 depends on PCI select SCSI_ISCSI_ATTRS select NETDEVICES
drivers/scsi/cxgbi/cxgb3i/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SCSI_CXGB3_ISCSI tristate "Chelsio T3 iSCSI support" - depends on PCI && INET + depends on PCI && INET && IPV4 select NETDEVICES select ETHERNET select NET_VENDOR_CHELSIO
drivers/scsi/cxgbi/cxgb4i/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SCSI_CXGB4_ISCSI tristate "Chelsio T4 iSCSI support" - depends on PCI && INET + depends on PCI && INET && IPV4 depends on PTP_1588_CLOCK_OPTIONAL depends on THERMAL || !THERMAL depends on ETHERNET
drivers/target/iscsi/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config ISCSI_TARGET tristate "SCSI Target Mode Stack" - depends on INET + depends on INET && IPV4 select CRC32 select CRYPTO select CRYPTO_HASH
fs/Kconfig +1 -0
@@ -358,6 +358,7 @@ config GRACE_PERIOD config LOCKD tristate + depends on IPV4 depends on FILE_LOCKING select CRC32 select GRACE_PERIOD
fs/afs/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config AFS_FS tristate "Andrew File System support (AFS)" - depends on INET + depends on INET && IPV4 select AF_RXRPC select DNS_RESOLVER select NETFS_SUPPORT
fs/nfs/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config NFS_FS tristate "NFS client support" - depends on INET && FILE_LOCKING && MULTIUSER + depends on INET && FILE_LOCKING && MULTIUSER && IPV4 select CRC32 select LOCKD select SUNRPC
fs/nfsd/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config NFSD tristate "NFS server support" - depends on INET + depends on INET && IPV4 depends on FILE_LOCKING depends on FSNOTIFY select CRC32
net/Kconfig +7 -4
@@ -136,9 +136,12 @@ config INET if INET source "net/ipv4/Kconfig" source "net/ipv6/Kconfig" -source "net/netlabel/Kconfig" source "net/mptcp/Kconfig" +if IPV4 +source "net/netlabel/Kconfig" +endif # if IPV4 + endif # if INET config NETWORK_SECMARK
@@ -385,7 +388,7 @@ menu "Network testing" config NET_PKTGEN tristate "Packet Generator (USE WITH CAUTION)" - depends on INET && PROC_FS + depends on INET && IPV4 && PROC_FS help This module will inject preconfigured packets, at a configurable rate, out of a given interface. It is used for network interface
@@ -452,7 +455,7 @@ config LWTUNNEL config LWTUNNEL_BPF bool "Execute BPF program as route nexthop action" - depends on LWTUNNEL && INET + depends on LWTUNNEL && INET && IPV4 default y if LWTUNNEL=y help Allows to run BPF programs as a nexthop action following a route
@@ -474,7 +477,7 @@ config NET_IEEE8021Q_HELPERS config NET_SELFTESTS def_tristate PHYLIB - depends on PHYLIB && INET + depends on PHYLIB && INET && IPV4 config NET_SOCK_MSG bool
net/batman-adv/Kconfig +1 -0
@@ -9,6 +9,7 @@ config BATMAN_ADV tristate "B.A.T.M.A.N. Advanced Meshing Protocol" + depends on IPV4 select CRC32 help B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is
net/bridge/Kconfig +2 -1
@@ -7,6 +7,7 @@ config BRIDGE tristate "802.1d Ethernet Bridging" select LLC select STP + depends on IPV4 help If you say Y here, then your Linux box will be able to act as an Ethernet bridge, which means that the different Ethernet segments it
@@ -36,7 +37,7 @@ config BRIDGE config BRIDGE_IGMP_SNOOPING bool "IGMP/MLD snooping" depends on BRIDGE - depends on INET + depends on INET && IPV4 default y help If you say Y here, then the Ethernet bridge will be able selectively
net/bridge/netfilter/Kconfig +3 -3
@@ -4,7 +4,7 @@ # # menuconfig NF_TABLES_BRIDGE - depends on BRIDGE && NETFILTER && NF_TABLES + depends on BRIDGE && NETFILTER && NF_TABLES && IPV4 select NETFILTER_FAMILY_BRIDGE tristate "Ethernet Bridge nf_tables support"
@@ -43,7 +43,7 @@ config NF_CONNTRACK_BRIDGE config BRIDGE_NF_EBTABLES_LEGACY tristate "Legacy EBTABLES support" depends on BRIDGE && NETFILTER_XTABLES_LEGACY - depends on NETFILTER_XTABLES + depends on NETFILTER_XTABLES && IPV4 default n help Legacy ebtables packet/frame classifier.
@@ -52,7 +52,7 @@ config BRIDGE_NF_EBTABLES_LEGACY menuconfig BRIDGE_NF_EBTABLES tristate "Ethernet Bridge tables (ebtables) support" - depends on BRIDGE && NETFILTER && NETFILTER_XTABLES + depends on BRIDGE && NETFILTER && NETFILTER_XTABLES && IPV4 select NETFILTER_FAMILY_BRIDGE help ebtables is a general, extensible frame/packet identification
net/ipv4/Kconfig +18 -3
@@ -2,6 +2,9 @@ # # IP configuration # +config IPV4 + def_bool y + config IP_MULTICAST bool "IP: multicasting" help
@@ -62,7 +65,7 @@ config IP_FIB_TRIE_STATS config IP_MULTIPLE_TABLES bool "IP: policy routing" - depends on IP_ADVANCED_ROUTER + depends on IPV4 && IP_ADVANCED_ROUTER select FIB_RULES help Normally, a router decides what to do with a received packet based
@@ -105,6 +108,7 @@ config IP_ROUTE_CLASSID config IP_PNP bool "IP: kernel level autoconfiguration" + depends on IPV4 help This enables automatic configuration of IP addresses of devices and of the routing table during kernel boot, based on either information
@@ -161,6 +165,7 @@ config IP_PNP_RARP config NET_IPIP tristate "IP: tunneling" + depends on IPV4 select INET_TUNNEL select NET_IP_TUNNEL help
@@ -185,12 +190,14 @@ config NET_IPGRE_DEMUX config NET_IP_TUNNEL tristate + depends on IPV4 select DST_CACHE select GRO_CELLS default n config NET_IPGRE tristate "IP: GRE tunnels over IP" + depends on IPV4 depends on NET_IPGRE_DEMUX select NET_IP_TUNNEL help
@@ -219,7 +226,7 @@ config IP_MROUTE_COMMON config IP_MROUTE bool "IP: multicast routing" - depends on IP_MULTICAST + depends on IP_MULTICAST && IPV4 select IP_MROUTE_COMMON help This is used if you want your machine to act as a router for IP
@@ -267,6 +274,7 @@ config IP_PIMSM_V2 config SYN_COOKIES bool "IP: TCP syncookie support" + depends on IPV4 help Normal TCP/IP networking is open to an attack known as "SYN flooding". This denial-of-service attack prevents legitimate remote
@@ -303,6 +311,7 @@ config SYN_COOKIES config NET_IPVTI tristate "Virtual (secure) IP: tunneling" + depends on IPV4 select INET_TUNNEL select NET_IP_TUNNEL select XFRM
@@ -315,11 +324,13 @@ config NET_IPVTI config NET_UDP_TUNNEL tristate + depends on IPV4 select NET_IP_TUNNEL default n config NET_FOU tristate "IP: Foo (IP protocols) over UDP" + depends on IPV4 select NET_UDP_TUNNEL help Foo over UDP allows any IP protocol to be directly encapsulated
@@ -338,6 +349,7 @@ config NET_FOU_IP_TUNNELS config INET_AH tristate "IP: AH transformation" + depends on IPV4 select XFRM_AH help Support for IPsec AH (Authentication Header).
@@ -353,6 +365,7 @@ config INET_AH config INET_ESP tristate "IP: ESP transformation" + depends on IPV4 select XFRM_ESP help Support for IPsec ESP (Encapsulating Security Payload).
@@ -393,6 +406,7 @@ config INET_ESPINTCP config INET_IPCOMP tristate "IP: IPComp transformation" + depends on IPV4 select INET_XFRM_TUNNEL select XFRM_IPCOMP help
@@ -747,7 +761,7 @@ config TCP_AO select CRYPTO_LIB_SHA1 select CRYPTO_LIB_SHA256 select CRYPTO_LIB_UTILS - depends on 64BIT # seq-number extension needs WRITE_ONCE(u64) + depends on IPV4 && 64BIT # seq-number extension needs WRITE_ONCE(u64) help TCP-AO specifies the use of stronger Message Authentication Codes (MACs), protects against replays for long-lived TCP connections, and
@@ -758,6 +772,7 @@ config TCP_AO config TCP_MD5SIG bool "TCP: MD5 Signature Option support (RFC2385)" + depends on IPV4 select CRYPTO_LIB_MD5 select CRYPTO_LIB_UTILS help
net/ipv4/Makefile +10 -11
@@ -3,18 +3,17 @@ # Makefile for the Linux TCP/IP (INET) layer. # -obj-y := route.o inetpeer.o protocol.o \ - ip_input.o ip_fragment.o ip_forward.o ip_options.o \ - ip_output.o ip_sockglue.o inet_hashtables.o \ - inet_timewait_sock.o inet_connection_sock.o \ - tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ +obj-y := inetpeer.o protocol.o inet_hashtables.o inet_timewait_sock.o \ + inet_connection_sock.o tcp.o tcp_input.o tcp_output.o tcp_timer.o \ tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \ - tcp_recovery.o tcp_ulp.o \ - tcp_offload.o tcp_plb.o datagram.o raw.o udp.o \ - udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \ - fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \ - inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \ - metrics.o netlink.o nexthop.o udp_tunnel_stub.o + tcp_recovery.o tcp_ulp.o tcp_offload.o tcp_plb.o raw.o udp.o \ + udp_offload.o af_inet.o inet_fragment.o ping.o ip_tunnel_core.o \ + gre_offload.o metrics.o netlink.o nexthop.o udp_tunnel_stub.o + +obj-$(CONFIG_IPV4) += route.o ip_input.o ip_fragment.o ip_forward.o ip_options.o \ + ip_sockglue.o tcp_ipv4.o datagram.o icmp.o arp.o devinet.o \ + igmp.o fib_notifier.o ip_output.o fib_frontend.o \ + fib_semantics.o fib_trie.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
net/ipv4/netfilter/Kconfig +1 -1
@@ -4,7 +4,7 @@ # menu "IP: Netfilter Configuration" - depends on INET && NETFILTER + depends on INET && NETFILTER && IPV4 config NF_DEFRAG_IPV4 tristate
net/ipv6/Kconfig +13 -4
@@ -47,6 +47,7 @@ config IPV6_OPTIMISTIC_DAD config INET6_AH tristate "IPv6: AH transformation" select XFRM_AH + depends on IPV4 help Support for IPsec AH (Authentication Header).
@@ -61,6 +62,7 @@ config INET6_AH config INET6_ESP tristate "IPv6: ESP transformation" + depends on IPV4 select XFRM_ESP help Support for IPsec ESP (Encapsulating Security Payload).
@@ -101,6 +103,7 @@ config INET6_ESPINTCP config INET6_IPCOMP tristate "IPv6: IPComp transformation" + depends on IPV4 select INET6_XFRM_TUNNEL select XFRM_IPCOMP help
@@ -111,6 +114,7 @@ config INET6_IPCOMP config IPV6_MIP6 tristate "IPv6: Mobility" + depends on IPV4 select XFRM help Support for IPv6 Mobility described in RFC 3775.
@@ -119,6 +123,7 @@ config IPV6_MIP6 config IPV6_ILA tristate "IPv6: Identifier Locator Addressing (ILA)" + depends on IPV4 depends on NETFILTER select DST_CACHE select LWTUNNEL
@@ -149,6 +154,7 @@ config INET6_TUNNEL config IPV6_VTI tristate "Virtual (secure) IPv6: tunneling" + depends on IPV4 select IPV6_TUNNEL select NET_IP_TUNNEL select XFRM
@@ -161,6 +167,7 @@ config IPV6_VTI config IPV6_SIT tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)" + depends on IPV4 select INET_TUNNEL select NET_IP_TUNNEL select IPV6_NDISC_NODETYPE
@@ -198,6 +205,7 @@ config IPV6_NDISC_NODETYPE config IPV6_TUNNEL tristate "IPv6: IP-in-IPv6 tunnel (RFC2473)" + depends on IPV4 select INET6_TUNNEL select DST_CACHE select GRO_CELLS
@@ -209,6 +217,7 @@ config IPV6_TUNNEL config IPV6_GRE tristate "IPv6: GRE tunnel" + depends on IPV4 select IPV6_TUNNEL select NET_IP_TUNNEL depends on NET_IPGRE_DEMUX
@@ -256,7 +265,7 @@ config IPV6_SUBTREES config IPV6_MROUTE bool "IPv6: multicast routing" - depends on IPV6 + depends on IPV4 && IPV6 select IP_MROUTE_COMMON help Support for IPv6 multicast forwarding.
@@ -285,7 +294,7 @@ config IPV6_PIMSM_V2 config IPV6_SEG6_LWTUNNEL bool "IPv6: Segment Routing Header encapsulation support" - depends on IPV6 + depends on IPV4 && IPV6 select LWTUNNEL select DST_CACHE select IPV6_MULTIPLE_TABLES
@@ -316,7 +325,7 @@ config IPV6_SEG6_BPF config IPV6_RPL_LWTUNNEL bool "IPv6: RPL Source Routing Header support" - depends on IPV6 + depends on IPV4 && IPV6 select LWTUNNEL select DST_CACHE help
@@ -327,7 +336,7 @@ config IPV6_RPL_LWTUNNEL config IPV6_IOAM6_LWTUNNEL bool "IPv6: IOAM Pre-allocated Trace insertion support" - depends on IPV6 + depends on IPV4 && IPV6 select LWTUNNEL select DST_CACHE help
net/ipv6/netfilter/Kconfig +1 -1
@@ -4,7 +4,7 @@ # menu "IPv6: Netfilter Configuration" - depends on INET && IPV6 && NETFILTER + depends on INET && IPV6 && NETFILTER && IPV4 # old sockopt interface and eval loop config IP6_NF_IPTABLES_LEGACY
net/l2tp/Kconfig +1 -1
@@ -5,7 +5,7 @@ menuconfig L2TP tristate "Layer Two Tunneling Protocol (L2TP)" - depends on INET + depends on INET && IPV4 select NET_UDP_TUNNEL help Layer Two Tunneling Protocol
net/mac80211/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config MAC80211 tristate "Generic IEEE 802.11 Networking Stack (mac80211)" - depends on CFG80211 + depends on CFG80211 && IPV4 select CRYPTO select CRYPTO_LIB_AES_CBC_MACS select CRYPTO_LIB_ARC4
net/mpls/Kconfig +1 -0
@@ -25,6 +25,7 @@ config NET_MPLS_GSO config MPLS_ROUTING tristate "MPLS: routing support" + depends on IPV4 depends on NET_IP_TUNNEL || NET_IP_TUNNEL=n depends on SYSCTL help
net/mptcp/Kconfig +1 -1
@@ -1,7 +1,7 @@ config MPTCP bool "MPTCP: Multipath TCP" - depends on INET + depends on INET && IPV4 select SKB_EXTENSIONS select CRYPTO_LIB_SHA256 select CRYPTO_LIB_UTILS
net/netfilter/Kconfig +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only menu "Core Netfilter Configuration" - depends on INET && NETFILTER + depends on INET && IPV4 && NETFILTER config NETFILTER_INGRESS bool "Netfilter ingress support"
net/netfilter/ipset/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig IP_SET tristate "IP set support" - depends on INET && NETFILTER + depends on INET && IPV4 && NETFILTER select NETFILTER_NETLINK help This option adds IP set support to the kernel.
net/netfilter/ipvs/Kconfig +1 -1
@@ -4,7 +4,7 @@ # menuconfig IP_VS tristate "IP virtual server support" - depends on INET && NETFILTER + depends on INET && NETFILTER && IPV4 depends on (NF_CONNTRACK || NF_CONNTRACK=n) help IP Virtual Server support will let you build a high-performance
net/openvswitch/Kconfig +1 -1
@@ -5,7 +5,7 @@ config OPENVSWITCH tristate "Open vSwitch" - depends on INET + depends on INET && IPV4 depends on !NF_CONNTRACK || \ (NF_CONNTRACK && ((!NF_DEFRAG_IPV6 || NF_DEFRAG_IPV6) && \ (!NF_NAT || NF_NAT) && \
net/packet/Kconfig +1 -0
@@ -5,6 +5,7 @@ config PACKET tristate "Packet socket" + depends on IPV4 help The Packet protocol is used by applications which communicate directly with network devices without an intermediate network
net/rds/Kconfig +1 -1
@@ -2,7 +2,7 @@ config RDS tristate "The Reliable Datagram Sockets Protocol" - depends on INET + depends on INET && IPV4 help The RDS (Reliable Datagram Sockets) protocol provides reliable, sequenced delivery of datagrams over Infiniband or TCP.
net/rxrpc/Kconfig +1 -1
@@ -5,7 +5,7 @@ config AF_RXRPC tristate "RxRPC session sockets" - depends on INET + depends on INET && IPV4 select CRYPTO select CRYPTO_LIB_DES if RXKAD select KEYS
net/sched/Kconfig +1 -1
@@ -807,7 +807,7 @@ config NET_ACT_SKBEDIT config NET_ACT_CSUM tristate "Checksum Updating" - depends on NET_CLS_ACT && INET + depends on NET_CLS_ACT && INET && IPV4 select NET_CRC32C help Say Y here to update some common checksum after some direct
net/sctp/Kconfig +1 -1
@@ -5,7 +5,7 @@ menuconfig IP_SCTP tristate "The SCTP Protocol" - depends on INET + depends on INET && IPV4 select CRYPTO_LIB_SHA1 select CRYPTO_LIB_SHA256 select CRYPTO_LIB_UTILS
net/smc/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SMC tristate "SMC socket protocol family" - depends on INET && INFINIBAND && DIBS + depends on INET && INFINIBAND && DIBS && IPV4 help SMC-R provides a "sockets over RDMA" solution making use of RDMA over Converged Ethernet (RoCE) technology to upgrade
net/sunrpc/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SUNRPC tristate - depends on MULTIUSER + depends on MULTIUSER && IPV4 config SUNRPC_GSS tristate
net/tipc/Kconfig +1 -1
@@ -5,7 +5,7 @@ menuconfig TIPC tristate "The TIPC Protocol" - depends on INET + depends on INET && IPV4 help The Transparent Inter Process Communication (TIPC) protocol is specially designed for intra cluster communication. This protocol
net/xfrm/Kconfig +10 -2
@@ -4,7 +4,7 @@ # config XFRM bool - depends on INET + depends on INET && IPV4 select GRO_CELLS select SKB_EXTENSIONS
@@ -13,6 +13,7 @@ config XFRM_OFFLOAD config XFRM_ALGO tristate + depends on IPV4 select XFRM select CRYPTO select CRYPTO_AEAD
@@ -23,6 +24,7 @@ if INET config XFRM_USER tristate "Transformation user configuration interface" select XFRM_ALGO + depends on IPV4 help Support for Transformation(XFRM) user configuration interface like IPsec used by native Linux tools.
@@ -42,7 +44,7 @@ config XFRM_USER_COMPAT config XFRM_INTERFACE tristate "Transformation virtual interface" - depends on XFRM && IPV6 + depends on XFRM && IPV4 && IPV6 help This provides a virtual interface to route IPsec traffic.
@@ -83,6 +85,7 @@ config XFRM_STATISTICS # RFC 8221 lists as MUST be implemented. config XFRM_AH tristate + depends on IPV4 select XFRM_ALGO select CRYPTO select CRYPTO_HMAC
@@ -92,6 +95,7 @@ config XFRM_AH # algorithms that RFC 8221 lists as MUST be implemented. config XFRM_ESP tristate + depends on IPV4 select XFRM_ALGO select CRYPTO select CRYPTO_AES
@@ -105,12 +109,14 @@ config XFRM_ESP config XFRM_IPCOMP tristate + depends on IPV4 select XFRM_ALGO select CRYPTO select CRYPTO_DEFLATE config NET_KEY tristate "PF_KEY sockets (deprecated)" + depends on IPV4 select XFRM_ALGO help PF_KEYv2 socket family, compatible to KAME ones.
@@ -140,6 +146,7 @@ config NET_KEY_MIGRATE config XFRM_IPTFS tristate "IPsec IP-TFS/AGGFRAG (RFC 9347) encapsulation support" + depends on IPV4 depends on XFRM help Information on the IP-TFS/AGGFRAG encapsulation can be found
@@ -156,5 +163,6 @@ config XFRM_IPTFS config XFRM_ESPINTCP bool + depends on IPV4 endif # INET
security/smack/Kconfig +1 -0
@@ -3,6 +3,7 @@ config SECURITY_SMACK bool "Simplified Mandatory Access Control Kernel Support" depends on NET depends on INET + depends on IPV4 depends on SECURITY select NETLABEL select SECURITY_NETWORK
Signature · 1 line
2.55.0
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Hi Fernando,
Thanks for the patch - after nearly 30 years IPv6 should be mature enough :)
Quoted 26 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>---
[...]
net/packet/Kconfig +0
-0
net/packet/Kconfig line 8
Quoted 4 lines
net/packet/Kconfig +1
-0@@ -5,6 +5,7 @@ config PACKET tristate "Packet socket" + depends on IPV4
depends on IPV4 || !INET
Otherwise this would break existing configs with INET=n. The same applies to other affected options that currently permit INET=n.
Quoted 1 line
[...]
Thanks,
Nicolai
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Quoted 32 lines · Nicolai Buchwitz
Hi Fernando,
Thanks for the patch - after nearly 30 years IPv6 should be mature enough :)
Quoted 27 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>---
[...]
net/packet/Kconfig +0
-0@@ -5,6 +5,7 @@
Quoted 8 lines
Quoted 3 lines
config PACKET
tristate "Packet socket"
+ depends on IPV4depends on IPV4 || !INET
Otherwise this would break existing configs with INET=n. The same applies to other affected options that currently permit INET=n.
That is a good point. I will review the other configs too.
Thanks!
Fernando.
Quoted 6 lines
Quoted 2 lines
[...]
Thanks,
Nicolai
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
In reply to Nicolai BuchwitzQuoted 6 lines · Nicolai Buchwitz
Quoted 6 lines
net/packet/Kconfig +0
-0@@ -5,6 +5,7 @@
Quoted 8 lines
net/packet/Kconfig line 8
Quoted 3 lines
net/packet/Kconfig +1
-0config PACKET tristate "Packet socket" + depends on IPV4depends on IPV4 || !INETOtherwise this would break existing configs with INET=n. The same applies to other affected options that currently permit INET=n.
Since that's a lot of symbols that all need the same dependency, maybe we could have an intermediate symbol for it:
config IPV4_IF_INET # or any better name you can think of
def_bool IPV4 || !INET
Similarly, everything that currently has 'depends on INET && IPV4' could be simplified to just 'depends on IPV4', and the leftover 'depends on INET && IPV6' from the days of modular IPV6 can now become 'depends on IPV4'. We only needed to list both in the past to deal with the IPV6=m case.
Arnd
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
In reply to Fernando Fernandez ManceraQuoted 10 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.
Quoted 7 lines
In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>
FWIW, I just checked and the following symbols that are currently marked as "depends on IPV4" can already be compiled without IPV4:
IPV6_MIP6, IPV6_ILA and IPV6_MROUTE
They will be adjusted on the next revision of the series. A re-check for all the symbols will be performed.
Thanks,
Fernando.
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Quoted 17 lines · Fernando Fernandez Mancera
Quoted 16 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.
Quoted 5 lines
Quoted 1 line
Signed-off-by Fernando Fernandez Mancera <[email protected]>FWIW, I just checked and the following symbols that are currently marked as "depends on IPV4" can already be compiled without IPV4:
IPV6_MIP6,IPV6_ILAandIPV6_MROUTE
MIP6 depends on XFRM so it actually depends on IPV4 for now.
Quoted 4 lines
They will be adjusted on the next revision of the series. A re-check for all the symbols will be performed.
Thanks,
Fernando.
Sven Eckelmann
maintainerRe: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
In reply to Fernando Fernandez Manceranet/batman-adv/Kconfig line 15
Quoted 12 lines · On Thursday, 10 September 2026 16:48:26 CEST Fernando Fernandez Mancera wrote:
net/batman-adv/Kconfig +1
-0@@ -9,6 +9,7 @@ config BATMAN_ADV tristate "B.A.T.M.A.N. Advanced Meshing Protocol" + depends on IPV4 select CRC32 help B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is
This doesn't make a lot of sense to me IPV4 is not a requirement for batman-adv. Only very specific features will require symbols from IPv4:
* CONFIG_BATMAN_ADV_BLA
- arp_create
* CONFIG_BATMAN_ADV_DAT
- arp_create
* CONFIG_BATMAN_ADV_MCAST
- ip_mc_check_igmp
Basically things which currently depend on INET in net/batman-adv/Kconfig
Or am I missing something here?
Regards,
Sven
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Quoted 25 lines · Sven Eckelmann
net/batman-adv/Kconfig line 15
Quoted 12 lines · On Thursday, 10 September 2026 16:48:26 CEST Fernando Fernandez Mancera wrote:
net/batman-adv/Kconfig +1
-0@@ -9,6 +9,7 @@ config BATMAN_ADV tristate "B.A.T.M.A.N. Advanced Meshing Protocol" + depends on IPV4 select CRC32 help B.A.T.M.A.N. (better approach to mobile ad-hoc networking) isThis doesn't make a lot of sense to me IPV4 is not a requirement for batman-adv. Only very specific features will require symbols from IPv4:
*
CONFIG_BATMAN_ADV_BLA-
arp_create*
CONFIG_BATMAN_ADV_DAT-
arp_create
Quoted 9 lines
*
CONFIG_BATMAN_ADV_MCAST-
ip_mc_check_igmpBasically things which currently depend on INET in
net/batman-adv/KconfigOr am I missing something here?
Yes, you are right. I must re-check all the symbols again. So thank you!
Quoted 2 lines
Regards,
Sven
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
In reply to Fernando Fernandez ManceraQuoted 23 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>net/sunrpc/Kconfig +0
-0
net/sunrpc/Kconfig line 7
Quoted 8 lines
net/sunrpc/Kconfig +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SUNRPC tristate - depends on MULTIUSER + depends on MULTIUSER && IPV4 config SUNRPC_GSS tristate
Signature · 1 line
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)
[email protected]
AI reviewRe: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
In reply to Fernando Fernandez ManceraThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Layer-2 networking features and core drivers incorrectly depend on IPV4, breaking INET=n builds. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Layer-2 networking features and core drivers incorrectly depend on IPV4, breaking INET=n builds. --
commit a6e6a467093e978fadc9f73c8f0d22f0bf0ee577
Author: Fernando Fernandez Mancera <[email protected]>
Subject: net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Historically, the IPv4 protocol has been linked to the core INET subsystem. This patch introduces the CONFIG_IPV4 Kconfig symbol and adds it as a dependency to multiple networking Kconfig symbols.
drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_CORE · line 15
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +1
-0@@ -12,6 +12,7 @@ config MLX5_CORE depends on PTP_1588_CLOCK_OPTIONAL depends on PCI_HYPERV_INTERFACE || !PCI_HYPERV_INTERFACE depends on HWMON || !HWMON + depends on IPV4
[Severity: High]
Does adding this dependency on IPV4 mean the Mellanox core driver can no longer be used for L2/DPDK in IP-less kernels?
The IPV4 symbol is sourced inside the if INET block in net/Kconfig, so it evaluates to n when INET=n. This seems to prevent selecting MLX5_CORE without TCP/IP, which causes a regression for valid Layer-2-only kernel configurations.
[ ... ]
net/bridge/Kconfig config BRIDGE · line 10
Quoted 9 lines
net/bridge/Kconfig +1
-0@@ -7,6 +7,7 @@ config BRIDGE tristate "802.1d Ethernet Bridging" select LLC select STP + depends on IPV4
[Severity: High]
Is it intentional that Ethernet bridging requires IPV4 here?
Bridging is a Layer-2 feature that does not require INET, but since IPV4 is evaluated as n in INET=n builds, this completely disables bridging in kernels configured without TCP/IP, resulting in a configuration regression.
[ ... ]
net/mac80211/Kconfig line 4
Quoted 10 lines
net/mac80211/Kconfig +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config MAC80211 tristate "Generic IEEE 802.11 Networking Stack (mac80211)" - depends on CFG80211 + depends on CFG80211 && IPV4
[Severity: High]
Does the generic 802.11 stack need to be rendered unavailable if INET=n?
Since it does not require IP, adding the IPV4 dependency seems to cause a regression for valid Layer-2-only configurations.
[ ... ]
net/packet/Kconfig line 8
Quoted 9 lines
net/packet/Kconfig +1
-0@@ -5,6 +5,7 @@ config PACKET tristate "Packet socket" + depends on IPV4
[Severity: High]
Can packet sockets (AF_PACKET) still be used when INET=n?
They provide direct Layer-2 access and are independent of INET, but this dependency causes a regression by making them unavailable in INET=n builds.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Casey Schaufler
maintainerRe: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
In reply to Fernando Fernandez ManceraQuoted 19 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>---
...
Quoted 3 lines
security/smack/Kconfig | 1 + 54 files changed, 126 insertions(+), 66 deletions(-)
...
security/smack/Kconfig config SECURITY_SMACK · line 9
Quoted 12 lines
security/smack/Kconfig +1
-0@@ -3,6 +3,7 @@ config SECURITY_SMACK bool "Simplified Mandatory Access Control Kernel Support" depends on NET depends on INET + depends on IPV4 depends on SECURITY select NETLABEL select SECURITY_NETWORK
Why would this make sense? You're introducing the capability to use IP6 by itself, which is admirable, but you're disallowing that configuration with the Smack LSM. It appears that you've done a mechanical lookup in the Kconfig files and applied the minimal change to make the kernel compile, which probably works for most cases. It does not work for Smack. Unless there's a strong argument that Smack with IPv6 and without IPv4 is and always will be a pointless configuration you have my NAK.
Re: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Quoted 42 lines · Casey Schaufler
Quoted 19 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>---
...
Quoted 3 lines
security/smack/Kconfig | 1 + 54 files changed, 126 insertions(+), 66 deletions(-)...
security/smack/Kconfig config SECURITY_SMACK · line 9
Quoted 12 lines
security/smack/Kconfig +1
-0@@ -3,6 +3,7 @@ config SECURITY_SMACK bool "Simplified Mandatory Access Control Kernel Support" depends on NET depends on INET + depends on IPV4 depends on SECURITY select NETLABEL select SECURITY_NETWORK
Quoted 9 lines
Why would this make sense? You're introducing the capability to use IP6 by itself, which is admirable, but you're disallowing that configuration with the Smack LSM. It appears that you've done a mechanical lookup in the
Kconfigfiles and applied the minimal change to make the kernel compile, which probably works for most cases. It does not work for Smack. Unless there's a strong argument that Smack with IPv6 and without IPv4 is and always will be a pointless configuration you have my NAK.
Right, that was kind of the point. The idea was to be able to compile core networking without IPv4. There are still plenty of modules that depends on IPv4. It does not mean that they will remain like that forever as I mentioned my idea was a follow-up on the series to avoid having a too long series.
Anyway, I can make Smack to do not depend on IPv4 on this series if that could grant an ACK.
Thanks,
Fernando.
Casey Schaufler
maintainerRe: [PATCH 01/13 net-next] net: ipv4: introduce CONFIG_IPV4 to decouple the IPv4 stack
Quoted 57 lines · Fernando Fernandez Mancera
Quoted 45 lines · Casey Schaufler
Quoted 20 lines · Fernando Fernandez Mancera
Historically, the IPv4 protocol has been linked to the core INET subsystem. Because shared infrastructure like the TCP/UDP engine, routing or INET hashtables live inside
net/ipv4/, it has been impossible
to compile a kernel with only IPv6 support.This patch introduces the
CONFIG_IPV4Kconfigsymbol, which is set to 'def_booly' for now. This does not allow to completely disable the IPv4 stack yet but it lays the necessary build-system work for that goal.In addition, multiple subsystems
Kconfigsymbols across networking features like tunnels, drivers and filesystems have been adjusted to depend on IPv4. Keep on mind that follow-up work is required to convert theKconfigsymbol to bool and remove the dependency on IPv4 where it makes sense.Signed-off-by Fernando Fernandez Mancera <[email protected]>---
...
Quoted 3 lines
security/smack/Kconfig | 1 +
54 files changed, 126 insertions(+), 66 deletions(-)...
Quoted 5 lines
security/smack/Kconfig +0
-0@@ -3,6 +3,7 @@ config SECURITY_SMACKQuoted 7 lines
bool "Simplified Mandatory Access Control Kernel Support" depends on NET
depends on INET
+ depends on IPV4
depends on SECURITY
select NETLABEL
selectSECURITY_NETWORKWhy would this make sense? You're introducing the capability to use IP6 by itself, which is admirable, but you're disallowing that
Quoted 10 lines
configuration
with the Smack LSM. It appears that you've done a mechanical lookup in theKconfigfiles and applied the minimal change to make the kernel compile, which probably works for most cases. It does not work for Smack. Unless there's a strong argument that Smack with IPv6 and without IPv4 is and always
will be a pointless configuration you have my NAK.
Quoted 8 lines
Right, that was kind of the point. The idea was to be able to compile core networking without IPv4. There are still plenty of modules that depends on IPv4. It does not mean that they will remain like that forever as I mentioned my idea was a follow-up on the series to avoid having a too long series.
Anyway, I can make Smack to do not depend on IPv4 on this series if that could grant an ACK.
Yes, that would be acceptable. I apologize in advance for the Smack IPv6 implementation. Replacing it with a proper CALIPSO stack has been on the todo list since CALIPSO was introduced.
Quoted 4 lines
Thanks,
Fernando.
PATCH 2/13 net: core: add IPv4 fallback stubs and guards for CONFIG_IPV4=n
In reply to Fernando Fernandez ManceraTo enable compiling the core network stack without IPv4, generic networking code must avoid referencing missing IPv4 symbols.
This patch provides static inline stubs in include/net/ip.h and include/net/route.h that return a proper error code when IPv4 is disabled. This behaves as IPv6 code does. In addition, it introduces guards around IPv4 specific code in generic implementations to prevent undefined reference errors while linking.
--- include/linux/indirect_call_wrapper.h | 8 +- include/net/ip.h | 104 ++++++++++++++++++++++---- include/net/route.h | 8 ++ net/core/dev_ioctl.c | 4 + net/core/filter.c | 20 ++--- net/core/neighbour.c | 5 ++ net/ipv4/inet_hashtables.c | 4 + 7 files changed, 124 insertions(+), 29 deletions(-)
include/linux/indirect_call_wrapper.h +5 -3
@@ -57,16 +57,18 @@* builtin, this macro simplify dealing with indirect calls with only ipv4/ipv6 * alternatives */ -#if IS_ENABLED (CONFIG_IPV6 ) +#if IS_ENABLED (CONFIG_IPV4 ) &&IS_ENABLED (CONFIG_IPV6 )#define INDIRECT_CALL_INET (f, f2, f1, ...) \ INDIRECT_CALL_2(f, f2, f1, __VA_ARGS__) -#elif IS_ENABLED (CONFIG_INET ) +#elif IS_ENABLED (CONFIG_IPV4 )#define INDIRECT_CALL_INET (f, f2, f1, ...) INDIRECT_CALL_1(f, f1, __VA_ARGS__) +#elif IS_ENABLED (CONFIG_IPV6 ) +#define INDIRECT_CALL_INET (f, f2, f1, ...) INDIRECT_CALL_1(f, f2, __VA_ARGS__)#else #define INDIRECT_CALL_INET (f, f2, f1, ...) f(__VA_ARGS__)#endif -#if IS_ENABLED (CONFIG_INET ) +#if IS_ENABLED (CONFIG_IPV4 )#define INDIRECT_CALL_INET_1 (f, f1, ...) INDIRECT_CALL_1(f, f1, __VA_ARGS__)#else #define INDIRECT_CALL_INET_1 (f, f1, ...) f(__VA_ARGS__)
include/net/ip.h +88 -16
153 lines not on this page · raw message
include/net/route.h +8 -0
@@ -169,8 +169,16 @@ static inline struct rtable *__ip_route_output_key(struct net *net,return ip_route_output_key_hash (net, flp,NULL ); } +#if IS_ENABLED (CONFIG_IPV4 )struct rtable *ip_route_output_flow (struct net *,struct flowi4 *flp,const struct sock *sk); +#else +static inline struct rtable *ip_route_output_flow (struct net *,struct flowi4 *flp, +const struct sock *sk) +{ +return ERR_PTR (-EAFNOSUPPORT ); +} +#endif struct dst_entry *ipv4_blackhole_route (struct net *net,struct dst_entry *dst_orig);
net/core/dev_ioctl.c +4 -0
@@ -39,6 +39,7 @@ static int dev_ifname(struct net *net, struct ifreq *ifr)*/ int dev_ifconf (struct net *net,struct ifconf __user *uifc) { +#if IS_ENABLED (CONFIG_IPV4 )struct net_device *dev;void __user *pos;size_t size;
@@ -82,6 +83,9 @@ int dev_ifconf(struct net *net, struct ifconf __user *uifc)rtnl_net_unlock (net);return put_user (total, &uifc->ifc_len); +#else +return -EAFNOSUPPORT ; +#endif }static int dev_getifmap (struct net_device *dev,struct ifreq *ifr)
net/core/filter.c +10 -10
@@ -2318,7 +2318,7 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev, }#endif /* CONFIG_IPV6 */ -#if IS_ENABLED (CONFIG_INET ) +#if IS_ENABLED (CONFIG_IPV4 )static int bpf_out_neigh_v4 (struct net *net,struct sk_buff *skb,struct net_device *dev,struct bpf_nh_params *nh) {
@@ -2427,7 +2427,7 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,kfree_skb (skb); return NET_XMIT_DROP; } -#endif /* CONFIG_INET */ +#endif /* CONFIG_IPV4 */ static int __bpf_redirect_neigh (struct sk_buff *skb,struct net_device *dev,struct bpf_nh_params *nh)
@@ -5782,7 +5782,7 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,if (level ==SOL_SOCKET )return sol_socket_sockopt (sk, optname, optval, &optlen, false); -else if (IS_ENABLED (CONFIG_INET ) && level ==SOL_IP ) +else if (IS_ENABLED (CONFIG_IPV4 ) && level ==SOL_IP )return sol_ip_sockopt (sk, optname, optval, &optlen, false);else if (IS_ENABLED (CONFIG_IPV6 ) && level ==SOL_IPV6 )return sol_ipv6_sockopt (sk, optname, optval, &optlen, false);
@@ -5819,7 +5819,7 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname, err =sol_socket_sockopt (sk, optname, optval, &optlen, true); else if (IS_ENABLED(CONFIG_INET) && level == SOL_TCP) err =sol_tcp_sockopt (sk, optname, optval, &optlen, true); - else if (IS_ENABLED(CONFIG_INET) && level == SOL_IP) + else if (IS_ENABLED(CONFIG_IPV4) && level == SOL_IP) err =sol_ip_sockopt (sk, optname, optval, &optlen, true); else if (IS_ENABLED(CONFIG_IPV6) && level == SOL_IPV6) err =sol_ipv6_sockopt (sk, optname, optval, &optlen, true);
@@ -6347,7 +6347,7 @@ static struct net_device *bpf_fib_vlan_input_dev(struct net_device *dev, }#endif -#if IS_ENABLED (CONFIG_INET ) +#if IS_ENABLED (CONFIG_IPV4 )static int bpf_ipv4_fib_lookup (struct net *net,struct bpf_fib_lookup *params,u32 flags,bool check_mtu) {
@@ -6679,7 +6679,7 @@ BPF_CALL_4(bpf_xdp_fib_lookup, struct xdp_buff *, ctx,return -EINVAL ;switch (params->family) { -#if IS_ENABLED (CONFIG_INET ) +#if IS_ENABLED (CONFIG_IPV4 )case AF_INET :return bpf_ipv4_fib_lookup (dev_net (ctx->rxq->dev), params, flags, true);
@@ -6723,7 +6723,7 @@ BPF_CALL_4(bpf_skb_fib_lookup, struct sk_buff *, skb, check_mtu = true;switch (params->family) { -#if IS_ENABLED (CONFIG_INET ) +#if IS_ENABLED (CONFIG_IPV4 )case AF_INET : rc =bpf_ipv4_fib_lookup (net, params, flags, check_mtu);break ;
@@ -12240,7 +12240,7 @@ BPF_CALL_1(bpf_skc_to_tcp_timewait_sock, struct sock *, sk)BTF_TYPE_EMIT (struct inet_timewait_sock );BTF_TYPE_EMIT (struct tcp_timewait_sock ); -#ifdef CONFIG_INET +#ifdef CONFIG_IPV4 if (sk && sk->sk_prot == &tcp_prot && sk->sk_state ==TCP_TIME_WAIT )return (unsigned long )sk;#endif
@@ -12263,7 +12263,7 @@ const struct bpf_func_proto bpf_skc_to_tcp_timewait_sock_proto = { BPF_CALL_1(bpf_skc_to_tcp_request_sock, struct sock *, sk) { -#ifdef CONFIG_INET +#ifdef CONFIG_IPV4 if (sk && sk->sk_prot == &tcp_prot && sk->sk_state ==TCP_NEW_SYN_RECV )return (unsigned long )sk;#endif
@@ -12745,7 +12745,7 @@ __bpf_kfunc int bpf_icmp_send(struct __sk_buff *skb_ctx, int type, int code)return -ENETUNREACH ;switch (skb->protocol) { -#if IS_ENABLED (CONFIG_INET ) +#if IS_ENABLED (CONFIG_IPV4 )case htons (ETH_P_IP ): {struct sk_buff *nskb;
net/core/neighbour.c +5 -0
@@ -3223,9 +3223,14 @@ int neigh_xmit(int index, struct net_device *dev, goto out_kfree_skb; }if (index ==NEIGH_ARP_TABLE ) { +#if IS_ENABLED (CONFIG_IPV4 )u32 key = *((u32 *)addr); neigh =__ipv4_neigh_lookup_noref (dev, key); +#else +rcu_read_unlock (); + goto out_kfree_skb; +#endif }else { neigh =__neigh_lookup_noref (tbl, addr, dev); }
net/ipv4/inet_hashtables.c +4 -0
@@ -581,6 +581,7 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row, bool rcu_lookup, u32 hash) { +#if IS_ENABLED (CONFIG_IPV4 )struct inet_hashinfo *hinfo = death_row->hashinfo;struct inet_sock *inet =inet_sk (sk);__be32 daddr = inet->inet_rcv_saddr;
@@ -651,6 +652,9 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row, not_unique:spin_unlock (lock);return -EADDRNOTAVAIL ; +#else +return -EAFNOSUPPORT ; +#endif }static u64 inet_sk_port_offset (const struct sock *sk)
Signature · 1 line
2.55.0
PATCH 3/13 net: inet: relocate ip_generic_getfrag and guard IPv4 socket logic
In reply to Fernando Fernandez ManceraTo enable compiling the INET subsystem without IPv4, shared generic utilities must be relocated and IPv4 socket logic must be guarded for CONFIG_IPV4.
This patch moves the generic ip_generec_getfrag() from ip_output.c to af_inet.c. It also introduces CONFIG_IPV4 guards around af_inet.c to reject IPv4-specific ioctls, protocol registrations and bind requests. The same guard is added to reject IPv4-mapped IPv6.
--- net/ipv4/af_inet.c | 96 +++++++++++++++++++++++++++++++++++++------- net/ipv4/ip_output.c | 18 --------- net/ipv6/af_inet6.c | 5 +++ net/ipv6/datagram.c | 12 ++++++ 4 files changed, 99 insertions(+), 32 deletions(-)
net/ipv4/af_inet.c +82 -14
@@ -129,6 +129,28 @@int disable_ipv6_mod;EXPORT_SYMBOL (disable_ipv6_mod); +/* Keep the function here for now as it is generic, it should be moved +* to a common L3 place +*/ +int +ip_generic_getfrag (void *from,char *to,int offset,int len,int odd,struct sk_buff *skb) +{ +struct msghdr *msg = from; + +if (skb->ip_summed ==CHECKSUM_PARTIAL ) { +if (!copy_from_iter_full (to, len, &msg->msg_iter)) +return -EFAULT ; + }else { +__wsum csum =0 ; + +if (!csum_and_copy_from_iter_full (to, len, &csum, &msg->msg_iter)) +return -EFAULT ; + skb->csum =csum_block_add (skb->csum, csum, odd); + } +return 0 ; +} +EXPORT_SYMBOL (ip_generic_getfrag); +/* The inetsw table contains everything that inet_create needs to * build a new socket. */
@@ -425,8 +447,10 @@ int inet_release(struct socket *sock)if (!sk->sk_kern_sock)BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE (sk); +#if IS_ENABLED (CONFIG_IPV4 )/* Applications forget to leave groups before exiting */ ip_mc_drop_socket (sk); +#endif /* If linger is set, we don't return until the close * is complete. Otherwise we return immediately. The
@@ -478,6 +502,7 @@ EXPORT_SYMBOL(inet_bind);int __inet_bind (struct sock *sk,struct sockaddr_unsized *uaddr,int addr_len,u32 flags) { +#if IS_ENABLED (CONFIG_IPV4 )struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;struct inet_sock *inet =inet_sk (sk);struct net *net =sock_net (sk);
@@ -570,6 +595,9 @@ int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,release_sock (sk); out:return err; +#else +return -EAFNOSUPPORT ; +#endif } int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
@@ -962,18 +990,24 @@ EXPORT_SYMBOL(inet_shutdown);int inet_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {struct sock *sk = sock->sk; -int err =0 ; -struct net *net =sock_net (sk); +#if IS_ENABLED (CONFIG_IPV4 )void __user *p = (void __user *)arg; -struct ifreq ifr; +struct net *net =sock_net (sk);struct rtentry rt; +struct ifreq ifr; +#endif +int err =0 ;switch (cmd) {case SIOCADDRT :case SIOCDELRT : +#if IS_ENABLED (CONFIG_IPV4 )if (copy_from_user (&rt, p,sizeof (struct rtentry )))return -EFAULT ; err =ip_rt_ioctl (net, cmd, &rt); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCRTMSG : err = -EINVAL ;
@@ -981,18 +1015,26 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCDARP :case SIOCGARP :case SIOCSARP : +#if IS_ENABLED (CONFIG_IPV4 ) err =arp_ioctl (net, cmd, (void __user *)arg); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCGIFADDR :case SIOCGIFBRDADDR :case SIOCGIFNETMASK :case SIOCGIFDSTADDR :case SIOCGIFPFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr);if (!err &&put_user_ifreq (&ifr, p)) err = -EFAULT ; +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCSIFADDR :
@@ -1001,9 +1043,13 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCSIFDSTADDR :case SIOCSIFPFLAGS :case SIOCSIFFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr); +#else + err = -EOPNOTSUPP ; +#endif break ;default :if (sk->sk_prot->ioctl)
@@ -1020,6 +1066,7 @@ EXPORT_SYMBOL(inet_ioctl);static int inet_compat_routing_ioctl (struct sock *sk,unsigned int cmd,struct compat_rtentry __user *ur) { +#if IS_ENABLED (CONFIG_IPV4 )compat_uptr_t rtdev;struct rtentry rt;
@@ -1035,6 +1082,9 @@ static int inet_compat_routing_ioctl(struct sock *sk, unsigned int cmd, rt.rt_dev =compat_ptr (rtdev);return ip_rt_ioctl (sock_net (sk), cmd, &rt); +#else +return -EOPNOTSUPP ; +#endif }static int inet_compat_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg)
@@ -1153,6 +1203,7 @@ static const struct net_proto_family inet_family_ops = { .owner = THIS_MODULE, }; +#if IS_ENABLED (CONFIG_IPV4 )/* Upon startup we insert all the elements in inetsw_array[] into * the linked list inetsw. */
@@ -1166,7 +1217,6 @@ static struct inet_protosw inetsw_array[] = .flags = INET_PROTOSW_PERMANENT | INET_PROTOSW_ICSK, }, - { .type = SOCK_DGRAM, .protocol = IPPROTO_UDP,
@@ -1193,6 +1243,7 @@ static struct inet_protosw inetsw_array[] = };#define INETSW_ARRAY_LEN ARRAY_SIZE(inetsw_array) +#endif void inet_register_protosw (struct inet_protosw *p) {
@@ -1258,6 +1309,7 @@ EXPORT_SYMBOL(inet_unregister_protosw);static int inet_sk_reselect_saddr (struct sock *sk) { +#if IS_ENABLED (CONFIG_IPV4 )struct inet_sock *inet =inet_sk (sk);__be32 old_saddr = inet->inet_saddr;__be32 daddr = inet->inet_daddr;
@@ -1309,6 +1361,9 @@ static int inet_sk_reselect_saddr(struct sock *sk)* uniqueness. Wait for troubles. */ return __sk_prot_rehash (sk); +#else +return -EAFNOSUPPORT ; +#endif }int inet_sk_rebuild_header (struct sock *sk)
@@ -1361,6 +1416,7 @@ void inet_sk_state_store(struct sock *sk, int newstate)struct sk_buff *inet_gso_segment (struct sk_buff *skb,netdev_features_t features) { +#if IS_ENABLED (CONFIG_IPV4 )bool udpfrag = false, fixedid = false, gso_partial, encap;struct sk_buff *segs =ERR_PTR (-EINVAL );const struct net_offload *ops;
@@ -1451,6 +1507,9 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb, out:return segs; +#else +return ERR_PTR (-EPROTONOSUPPORT ); +#endif } static struct sk_buff *ipip_gso_segment(struct sk_buff *skb,
@@ -1774,6 +1833,10 @@ static int __init init_ipv4_mibs(void)return register_pernet_subsys (&ipv4_mib_ops); } +#if IS_ENABLED (CONFIG_IPV4 ) +static int ipv4_proc_init (void ); +#endif +static __net_init int inet_init_net (struct net *net) {/*
@@ -1824,8 +1887,6 @@ static int __init init_inet_pernet_ops(void)return register_pernet_subsys (&af_inet_ops); } -static int ipv4_proc_init (void ); -/* * IP protocol layer initialiser */
@@ -1870,26 +1931,30 @@ static int __init ipv4_offload_init(void)fs_initcall (ipv4_offload_init); +#if IS_ENABLED (CONFIG_IPV4 )static struct packet_type ip_packet_type__read_mostly = { .type =cpu_to_be16 (ETH_P_IP ), .func = ip_rcv, .list_func = ip_list_rcv, }; +#endif static int __init inet_init (void ) { +#if IS_ENABLED (CONFIG_IPV4 )struct inet_protosw *q;struct list_head *r;int rc; +#endif sock_skb_cb_check_size (sizeof (struct inet_skb_parm )); +#if IS_ENABLED (CONFIG_IPV4 )raw_hashinfo_init (&raw_v4_hashinfo); rc =proto_register (&tcp_prot,1 );if (rc) goto out; - rc =proto_register (&udp_prot,1 );if (rc) goto out_unregister_tcp_proto;
@@ -1926,7 +1991,6 @@ static int __init inet_init(void) };if (inet_add_protocol (&net_hotdata.udp_protocol,IPPROTO_UDP ) <0 )pr_crit ("%s: Cannot add UDP protocol\n" , __func__); - net_hotdata.tcp_protocol = (struct net_protocol ) { .handler = tcp_v4_rcv, .err_handler = tcp_v4_err,
@@ -1958,7 +2022,7 @@ static int __init inet_init(void)*/ ip_init (); - +#endif /* CONFIG_IPV4 */ /* Initialise per-cpu ipv4 mibs */ if (init_ipv4_mibs ())panic ("%s: Cannot init ipv4 mibs\n" , __func__);
@@ -1980,6 +2044,9 @@ static int __init inet_init(void)if (icmp_init () <0 )panic ("Failed to create the ICMP control socket.\n" ); +if (init_inet_pernet_ops ()) +pr_crit ("%s: Cannot init ipv4 inet pernet ops\n" , __func__); +#if IS_ENABLED (CONFIG_IPV4 )/* * Initialise the multicast router */
@@ -1987,19 +2054,17 @@ static int __init inet_init(void)if (ip_mr_init ())pr_crit ("%s: Cannot init ipv4 mroute\n" , __func__);#endif - -if (init_inet_pernet_ops ()) -pr_crit ("%s: Cannot init ipv4 inet pernet ops\n" , __func__); -ipv4_proc_init ();ipfrag_init ();dev_add_pack (&ip_packet_type); +#endif /* CONFIG_IPV4 */ ip_tunnel_core_init (); - rc =0 ; +return 0 ; +#if IS_ENABLED (CONFIG_IPV4 ) out:return rc; out_unregister_raw_proto:
@@ -2009,12 +2074,14 @@ static int __init inet_init(void) out_unregister_tcp_proto:proto_unregister (&tcp_prot); goto out; +#endif }fs_initcall (inet_init);/* ------------------------------------------------------------------------ */ +#if IS_ENABLED(CONFIG_IPV4) #ifdef CONFIG_PROC_FS static int __init ipv4_proc_init(void) {
@@ -2051,3 +2118,4 @@ static int __init ipv4_proc_init(void)return 0 ; }#endif /* CONFIG_PROC_FS */ +#endif
net/ipv4/ip_output.c +0 -18
@@ -932,24 +932,6 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, }EXPORT_SYMBOL (ip_do_fragment); -int -ip_generic_getfrag (void *from,char *to,int offset,int len,int odd,struct sk_buff *skb) -{ -struct msghdr *msg = from; - -if (skb->ip_summed ==CHECKSUM_PARTIAL ) { -if (!copy_from_iter_full (to, len, &msg->msg_iter)) -return -EFAULT ; - }else { -__wsum csum =0 ; -if (!csum_and_copy_from_iter_full (to, len, &csum, &msg->msg_iter)) -return -EFAULT ; - skb->csum =csum_block_add (skb->csum, csum, odd); - } -return 0 ; -} -EXPORT_SYMBOL (ip_generic_getfrag); - static int __ip_append_data(struct sock *sk, struct flowi4 *fl4, struct sk_buff_head *queue,
net/ipv6/af_inet6.c +5 -0
@@ -299,6 +299,7 @@ int __inet6_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,/* Check if the address belongs to the host. */ if (addr_type ==IPV6_ADDR_MAPPED ) { +#if IS_ENABLED (CONFIG_IPV4 )struct net_device *dev =NULL ;int chk_addr_ret;
@@ -329,6 +330,10 @@ int __inet6_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len, err = -EADDRNOTAVAIL ; goto out; } +#else + err = -EADDRNOTAVAIL ; + goto out; +#endif }else {if (addr_type !=IPV6_ADDR_ANY ) {struct net_device *dev =NULL ;
net/ipv6/datagram.c +12 -0
@@ -33,10 +33,12 @@#include <linux/errqueue.h> #include <linux/uaccess.h> +#if IS_ENABLED (CONFIG_IPV4 )static bool ipv6_mapped_addr_any (const struct in6_addr *a) {return ipv6_addr_v4mapped (a) && (a->s6_addr32[3 ] ==0 ); } +#endif static void ip6_datagram_flow_key_init (struct flowi6 *fl6,const struct sock *sk)
@@ -153,10 +155,14 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr_unsized *uaddr,int err;if (usin->sin6_family ==AF_INET ) { +#if IS_ENABLED (CONFIG_IPV4 )if (ipv6_only_sock (sk))return -EAFNOSUPPORT ; err =__ip4_datagram_connect (sk, uaddr, addr_len); goto ipv4_connected; +#else +return -EAFNOSUPPORT ; +#endif }if (addr_len <SIN6_LEN_RFC2133 )
@@ -184,6 +190,7 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr_unsized *uaddr, daddr = &usin->sin6_addr;if (addr_type &IPV6_ADDR_MAPPED ) { +#if IS_ENABLED (CONFIG_IPV4 )struct sockaddr_in sin;if (ipv6_only_sock (sk)) {
@@ -217,6 +224,9 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr_unsized *uaddr, } goto out; +#else +return -ENETUNREACH ; +#endif }if (__ipv6_addr_needs_scope_id (addr_type)) {
@@ -522,10 +532,12 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)ipv6_iface_scope_id (&sin->sin6_addr,IP6CB (skb)->iif); }else { +#if IS_ENABLED (CONFIG_IPV4 )ipv6_addr_set_v4mapped (ip_hdr (skb)->saddr, &sin->sin6_addr);if (inet_cmsg_flags (inet_sk (sk)))ip_cmsg_recv (msg, skb); +#endif } }
Signature · 1 line
2.55.0
Re: [PATCH 03/13 net-next] net: inet: relocate ip_generic_getfrag and guard IPv4 socket logic
Quoted 135 lines · Fernando Fernandez Mancera
To enable compiling the INET subsystem without IPv4, shared generic utilities must be relocated and IPv4 socket logic must be guarded for
CONFIG_IPV4.This patch moves the generic
ip_generec_getfrag()fromip_output.ctoaf_inet.c. It also introducesCONFIG_IPV4guards aroundaf_inet.cto reject IPv4-specific ioctls, protocol registrations and bind requests. The same guard is added to reject IPv4-mapped IPv6.Signed-off-by Fernando Fernandez Mancera <[email protected]>--- net/ipv4/af_inet.c | 96 +++++++++++++++++++++++++++++++++++++------- net/ipv4/ip_output.c | 18 --------- net/ipv6/af_inet6.c | 5 +++ net/ipv6/datagram.c | 12 ++++++ 4 files changed, 99 insertions(+), 32 deletions(-)net/ipv4/af_inet.c +45
-3@@ -129,6 +129,28 @@int disable_ipv6_mod;EXPORT_SYMBOL (disable_ipv6_mod); +/* Keep the function here for now as it is generic, it should be moved +* to a common L3 place +*/ +int +ip_generic_getfrag (void *from,char *to,int offset,int len,int odd,struct sk_buff *skb) +{ +struct msghdr *msg = from; + +if (skb->ip_summed ==CHECKSUM_PARTIAL ) { +if (!copy_from_iter_full (to, len, &msg->msg_iter)) +return -EFAULT ; + }else { +__wsum csum =0 ; + +if (!csum_and_copy_from_iter_full (to, len, &csum, &msg->msg_iter)) +return -EFAULT ; + skb->csum =csum_block_add (skb->csum, csum, odd); + } +return 0 ; +} +EXPORT_SYMBOL (ip_generic_getfrag); +/* The inetsw table contains everything that inet_create needs to * build a new socket. */ @@ -425,8 +447,10 @@ int inet_release(struct socket *sock)if (!sk->sk_kern_sock)BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE (sk); +#if IS_ENABLED (CONFIG_IPV4 )/* Applications forget to leave groups before exiting */ ip_mc_drop_socket (sk); +#endif /* If linger is set, we don't return until the close * is complete. Otherwise we return immediately. The @@ -478,6 +502,7 @@ EXPORT_SYMBOL(inet_bind);int __inet_bind (struct sock *sk,struct sockaddr_unsized *uaddr,int addr_len,u32 flags) { +#if IS_ENABLED (CONFIG_IPV4 )struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;struct inet_sock *inet =inet_sk (sk);struct net *net =sock_net (sk);@@ -570,6 +595,9 @@ int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,release_sock (sk); out:return err; +#else +return -EAFNOSUPPORT ; +#endif } int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr,@@ -962,18 +990,24 @@ EXPORT_SYMBOL(inet_shutdown);int inet_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {struct sock *sk = sock->sk; -int err =0 ; -struct net *net =sock_net (sk); +#if IS_ENABLED (CONFIG_IPV4 )void __user *p = (void __user *)arg; -struct ifreq ifr; +struct net *net =sock_net (sk);struct rtentry rt; +struct ifreq ifr; +#endif +int err =0 ;switch (cmd) {case SIOCADDRT :case SIOCDELRT : +#if IS_ENABLED (CONFIG_IPV4 )if (copy_from_user (&rt, p,sizeof (struct rtentry )))return -EFAULT ; err =ip_rt_ioctl (net, cmd, &rt); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCRTMSG : err = -EINVAL ;@@ -981,18 +1015,26 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCDARP :case SIOCGARP :case SIOCSARP : +#if IS_ENABLED (CONFIG_IPV4 ) err =arp_ioctl (net, cmd, (void __user *)arg); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCGIFADDR :case SIOCGIFBRDADDR :case SIOCGIFNETMASK :case SIOCGIFDSTADDR :case SIOCGIFPFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr);if (!err &&put_user_ifreq (&ifr, p)) err = -EFAULT ; +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCSIFADDR :
net/ipv4/af_inet.c int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) · line 1052
Quoted 10 lines
net/ipv4/af_inet.c +4
-0@@ -1001,9 +1043,13 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCSIFDSTADDR :case SIOCSIFPFLAGS :case SIOCSIFFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr); +#else + err = -EOPNOTSUPP ; +#endif
(passing by comment)
Don't we have a coding style rule to avoid ifdef conditional in C code? Should we add some new devinet4_ioctl/etc wrappers that we can conditionally compile out in the headers?
Re: [PATCH 03/13 net-next] net: inet: relocate ip_generic_getfrag and guard IPv4 socket logic
Quoted 149 lines · Stanislav Fomichev
Quoted 135 lines · Fernando Fernandez Mancera
To enable compiling the INET subsystem without IPv4, shared generic utilities must be relocated and IPv4 socket logic must be guarded for
CONFIG_IPV4.This patch moves the generic
ip_generec_getfrag()fromip_output.ctoaf_inet.c. It also introducesCONFIG_IPV4guards aroundaf_inet.cto reject IPv4-specific ioctls, protocol registrations and bind requests. The same guard is added to reject IPv4-mapped IPv6.Signed-off-by Fernando Fernandez Mancera <[email protected]>--- net/ipv4/af_inet.c | 96 +++++++++++++++++++++++++++++++++++++------- net/ipv4/ip_output.c | 18 --------- net/ipv6/af_inet6.c | 5 +++ net/ipv6/datagram.c | 12 ++++++ 4 files changed, 99 insertions(+), 32 deletions(-)net/ipv4/af_inet.c +45
-3@@ -129,6 +129,28 @@int disable_ipv6_mod;EXPORT_SYMBOL (disable_ipv6_mod); +/* Keep the function here for now as it is generic, it should be moved +* to a common L3 place +*/ +int +ip_generic_getfrag (void *from,char *to,int offset,int len,int odd,struct sk_buff *skb) +{ +struct msghdr *msg = from; + +if (skb->ip_summed ==CHECKSUM_PARTIAL ) { +if (!copy_from_iter_full (to, len, &msg->msg_iter)) +return -EFAULT ; + }else { +__wsum csum =0 ; + +if (!csum_and_copy_from_iter_full (to, len, &csum, &msg->msg_iter)) +return -EFAULT ; + skb->csum =csum_block_add (skb->csum, csum, odd); + } +return 0 ; +} +EXPORT_SYMBOL (ip_generic_getfrag); +/* The inetsw table contains everything that inet_create needs to * build a new socket. */ @@ -425,8 +447,10 @@ int inet_release(struct socket *sock)if (!sk->sk_kern_sock)BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE (sk); +#if IS_ENABLED (CONFIG_IPV4 )/* Applications forget to leave groups before exiting */ ip_mc_drop_socket (sk); +#endif /* If linger is set, we don't return until the close * is complete. Otherwise we return immediately. The @@ -478,6 +502,7 @@ EXPORT_SYMBOL(inet_bind);int __inet_bind (struct sock *sk,struct sockaddr_unsized *uaddr,int addr_len,u32 flags) { +#if IS_ENABLED (CONFIG_IPV4 )struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;struct inet_sock *inet =inet_sk (sk);struct net *net =sock_net (sk);@@ -570,6 +595,9 @@ int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,release_sock (sk); out:return err; +#else +return -EAFNOSUPPORT ; +#endif } int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr,@@ -962,18 +990,24 @@ EXPORT_SYMBOL(inet_shutdown);int inet_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {struct sock *sk = sock->sk; -int err =0 ; -struct net *net =sock_net (sk); +#if IS_ENABLED (CONFIG_IPV4 )void __user *p = (void __user *)arg; -struct ifreq ifr; +struct net *net =sock_net (sk);struct rtentry rt; +struct ifreq ifr; +#endif +int err =0 ;switch (cmd) {case SIOCADDRT :case SIOCDELRT : +#if IS_ENABLED (CONFIG_IPV4 )if (copy_from_user (&rt, p,sizeof (struct rtentry )))return -EFAULT ; err =ip_rt_ioctl (net, cmd, &rt); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCRTMSG : err = -EINVAL ;@@ -981,18 +1015,26 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCDARP :case SIOCGARP :case SIOCSARP : +#if IS_ENABLED (CONFIG_IPV4 ) err =arp_ioctl (net, cmd, (void __user *)arg); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCGIFADDR :case SIOCGIFBRDADDR :case SIOCGIFNETMASK :case SIOCGIFDSTADDR :case SIOCGIFPFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr);if (!err &&put_user_ifreq (&ifr, p)) err = -EFAULT ; +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCSIFADDR :net/ipv4/af_inet.c int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) · line 1052
Quoted 10 lines
net/ipv4/af_inet.c +4
-0@@ -1001,9 +1043,13 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCSIFDSTADDR :case SIOCSIFPFLAGS :case SIOCSIFFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr); +#else + err = -EOPNOTSUPP ; +#endif (passing by comment)
Quoted 3 lines
Don't we have a coding style rule to avoid ifdef conditional in C code? Should we add some new devinet4_ioctl/etc wrappers that we can conditionally compile out in the headers?
I think yes but when it makes sense. Of course, that is something a bit hard to judge IMHO. I tried to use it when it makes sense, like for stubs or for functions that are protocol agnostic but contains a small part related to IPv4/IPV6. I was willing to avoid code duplication as much as possible.
Re: [PATCH 03/13 net-next] net: inet: relocate ip_generic_getfrag and guard IPv4 socket logic
In reply to Stanislav FomichevQuoted 149 lines · Stanislav Fomichev
Quoted 135 lines · Fernando Fernandez Mancera
To enable compiling the INET subsystem without IPv4, shared generic utilities must be relocated and IPv4 socket logic must be guarded for
CONFIG_IPV4.This patch moves the generic
ip_generec_getfrag()fromip_output.ctoaf_inet.c. It also introducesCONFIG_IPV4guards aroundaf_inet.cto reject IPv4-specific ioctls, protocol registrations and bind requests. The same guard is added to reject IPv4-mapped IPv6.Signed-off-by Fernando Fernandez Mancera <[email protected]>--- net/ipv4/af_inet.c | 96 +++++++++++++++++++++++++++++++++++++------- net/ipv4/ip_output.c | 18 --------- net/ipv6/af_inet6.c | 5 +++ net/ipv6/datagram.c | 12 ++++++ 4 files changed, 99 insertions(+), 32 deletions(-)net/ipv4/af_inet.c +45
-3@@ -129,6 +129,28 @@int disable_ipv6_mod;EXPORT_SYMBOL (disable_ipv6_mod); +/* Keep the function here for now as it is generic, it should be moved +* to a common L3 place +*/ +int +ip_generic_getfrag (void *from,char *to,int offset,int len,int odd,struct sk_buff *skb) +{ +struct msghdr *msg = from; + +if (skb->ip_summed ==CHECKSUM_PARTIAL ) { +if (!copy_from_iter_full (to, len, &msg->msg_iter)) +return -EFAULT ; + }else { +__wsum csum =0 ; + +if (!csum_and_copy_from_iter_full (to, len, &csum, &msg->msg_iter)) +return -EFAULT ; + skb->csum =csum_block_add (skb->csum, csum, odd); + } +return 0 ; +} +EXPORT_SYMBOL (ip_generic_getfrag); +/* The inetsw table contains everything that inet_create needs to * build a new socket. */ @@ -425,8 +447,10 @@ int inet_release(struct socket *sock)if (!sk->sk_kern_sock)BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE (sk); +#if IS_ENABLED (CONFIG_IPV4 )/* Applications forget to leave groups before exiting */ ip_mc_drop_socket (sk); +#endif /* If linger is set, we don't return until the close * is complete. Otherwise we return immediately. The @@ -478,6 +502,7 @@ EXPORT_SYMBOL(inet_bind);int __inet_bind (struct sock *sk,struct sockaddr_unsized *uaddr,int addr_len,u32 flags) { +#if IS_ENABLED (CONFIG_IPV4 )struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;struct inet_sock *inet =inet_sk (sk);struct net *net =sock_net (sk);@@ -570,6 +595,9 @@ int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,release_sock (sk); out:return err; +#else +return -EAFNOSUPPORT ; +#endif } int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr,@@ -962,18 +990,24 @@ EXPORT_SYMBOL(inet_shutdown);int inet_ioctl (struct socket *sock,unsigned int cmd,unsigned long arg) {struct sock *sk = sock->sk; -int err =0 ; -struct net *net =sock_net (sk); +#if IS_ENABLED (CONFIG_IPV4 )void __user *p = (void __user *)arg; -struct ifreq ifr; +struct net *net =sock_net (sk);struct rtentry rt; +struct ifreq ifr; +#endif +int err =0 ;switch (cmd) {case SIOCADDRT :case SIOCDELRT : +#if IS_ENABLED (CONFIG_IPV4 )if (copy_from_user (&rt, p,sizeof (struct rtentry )))return -EFAULT ; err =ip_rt_ioctl (net, cmd, &rt); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCRTMSG : err = -EINVAL ;@@ -981,18 +1015,26 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCDARP :case SIOCGARP :case SIOCSARP : +#if IS_ENABLED (CONFIG_IPV4 ) err =arp_ioctl (net, cmd, (void __user *)arg); +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCGIFADDR :case SIOCGIFBRDADDR :case SIOCGIFNETMASK :case SIOCGIFDSTADDR :case SIOCGIFPFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr);if (!err &&put_user_ifreq (&ifr, p)) err = -EFAULT ; +#else + err = -EOPNOTSUPP ; +#endif break ;case SIOCSIFADDR :net/ipv4/af_inet.c int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) · line 1052
Quoted 10 lines
net/ipv4/af_inet.c +4
-0@@ -1001,9 +1043,13 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case SIOCSIFDSTADDR :case SIOCSIFPFLAGS :case SIOCSIFFLAGS : +#if IS_ENABLED (CONFIG_IPV4 )if (get_user_ifreq (&ifr,NULL , p))return -EFAULT ; err =devinet_ioctl (net, cmd, &ifr); +#else + err = -EOPNOTSUPP ; +#endif (passing by comment)
Quoted 3 lines
Don't we have a coding style rule to avoid ifdef conditional in C code? Should we add some new devinet4_ioctl/etc wrappers that we can conditionally compile out in the headers?
I agree here.. and went on a different direction for the upcoming v2. I decided to rely on DCE (Dead Code Elimination) to avoid using ifdef conditional. I think the v2 looks much better (to be sent in some minutes).
Thanks!
PATCH 4/13 net: tcp: move protocol agnostic TCP functions out of tcp_ipv4.c
In reply to Fernando Fernandez ManceraAs the tcp_ipv4.c file isn't compile anymore with CONFIG_IPV4=n, the generic TCP function must be moved out of tcp_ipv4.c file and they should be placed in tcp.c file.
As part of this migration, rename tcp_v4_destroy_sock() to tcp_destroy_sock() to reflect its shared usage by IPv4 and IPv6.
In addition, guard IPv4 code around IPv6 TCP implementation. This ensures that IPv4-mapped IPv6 sockects are rejected with a proper error code when IPv4 stack is disabled.
Please note that this commit also addresses how /proc/net/sockstat output is handled for all protocols. The implementation now force the inuse attrtibute to be zero when CONFIG_IPV4=n but the shared stats are represented correctly.
--- include/net/tcp.h | 16 +- net/ipv4/af_inet.c | 18 +- net/ipv4/inet_connection_sock.c | 2 +- net/ipv4/proc.c | 38 +- net/ipv4/tcp.c | 1299 ++++++++++++++++++++++++++++++ net/ipv4/tcp_bpf.c | 2 + net/ipv4/tcp_ipv4.c | 1307 +------------------------------ net/ipv6/tcp_ipv6.c | 25 +- 8 files changed, 1382 insertions(+), 1325 deletions(-)
include/net/tcp.h +15 -1
@@ -2437,7 +2437,7 @@ struct tcp_iter_state {extern struct request_sock_ops tcp_request_sock_ops;extern struct request_sock_ops tcp6_request_sock_ops; -void tcp_v4_destroy_sock (struct sock *sk); +void tcp_destroy_sock (struct sock *sk);struct sk_buff *tcp_gso_segment (struct sk_buff *skb,netdev_features_t features);
@@ -2855,6 +2855,20 @@ struct sk_psock;#ifdef CONFIG_BPF_SYSCALL int tcp_bpf_update_proto (struct sock *sk,struct sk_psock *psock,bool restore);void tcp_bpf_clone (const struct sock *sk,struct sock *newsk); + +union bpf_tcp_iter_batch_item { +struct sock *sk; +__u64 cookie; +}; + +struct bpf_tcp_iter_state { +struct tcp_iter_state state; +unsigned int cur_sk; +unsigned int end_sk; +unsigned int max_sk; +union bpf_tcp_iter_batch_item *batch; +}; +#ifdef CONFIG_BPF_STREAM_PARSER struct strparser ; int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,
net/ipv4/af_inet.c +14 -4
@@ -1952,6 +1952,7 @@ static int __init inet_init(void)#if IS_ENABLED (CONFIG_IPV4 )raw_hashinfo_init (&raw_v4_hashinfo); +#if IS_ENABLED (CONFIG_IPV4 ) rc =proto_register (&tcp_prot,1 );if (rc) goto out;
@@ -1999,6 +2000,7 @@ static int __init inet_init(void) };if (inet_add_protocol (&net_hotdata.tcp_protocol,IPPROTO_TCP ) <0 )pr_crit ("%s: Cannot add TCP protocol\n" , __func__); +#endif #ifdef CONFIG_IP_MULTICAST if (inet_add_protocol (&igmp_protocol,IPPROTO_IGMP ) <0 )pr_crit ("%s: Cannot add IGMP protocol\n" , __func__);
@@ -2046,6 +2048,12 @@ static int __init inet_init(void)if (init_inet_pernet_ops ())pr_crit ("%s: Cannot init ipv4 inet pernet ops\n" , __func__); + +#ifdef CONFIG_PROC_FS +if (ip_misc_proc_init ()) +pr_crit ("%s: Cannot init ipv4 misc proc\n" , __func__); +#endif +#if IS_ENABLED (CONFIG_IPV4 )/* * Initialise the multicast router
@@ -2072,7 +2080,9 @@ static int __init inet_init(void) out_unregister_udp_proto:proto_unregister (&udp_prot); out_unregister_tcp_proto: +#if IS_ENABLED (CONFIG_IPV4 )proto_unregister (&tcp_prot); +#endif goto out;#endif }
@@ -2089,23 +2099,23 @@ static int __init ipv4_proc_init(void)if (raw_proc_init ()) goto out_raw; +#if IS_ENABLED (CONFIG_IPV4 )if (tcp4_proc_init ()) goto out_tcp; +#endif if (udp4_proc_init ()) goto out_udp;if (ping_proc_init ()) goto out_ping; -if (ip_misc_proc_init ()) - goto out_misc; out:return rc; -out_misc: -ping_proc_exit (); out_ping:udp4_proc_exit (); out_udp: +#if IS_ENABLED(CONFIG_IPV4)tcp4_proc_exit (); out_tcp: +#endifraw_proc_exit (); out_raw: rc = -ENOMEM ;
net/ipv4/inet_connection_sock.c +1 -1
@@ -1384,7 +1384,7 @@ static void inet_child_forget(struct sock *sk, struct request_sock *req,* an inbound pkt destined for child is * blocked by sock lock in tcp_v4_rcv(). * Also to satisfy an assertion in -* tcp_v4_destroy_sock(). +* tcp_destroy_sock(). */ RCU_INIT_POINTER (tcp_sk (child)->fastopen_rsk,NULL ); }
net/ipv4/proc.c +27 -11
@@ -29,6 +29,7 @@*/ #include <linux/types.h> #include <net/net_namespace.h> +#include <net/aligned_data.h> #include <net/icmp.h> #include <net/protocol.h> #include <net/tcp.h>
@@ -50,25 +51,34 @@*/ static int sockstat_seq_show (struct seq_file *seq,void *v) { +int tcp_inuse =0 , udp_inuse =0 , raw_inuse =0 ;struct net *net = seq->private; +long tcp_mem, udp_mem;int orphans, sockets; orphans =tcp_orphan_count_sum (); - sockets =proto_sockets_allocated_sum_positive (&tcp_prot); + sockets =percpu_counter_sum_positive (&tcp_sockets_allocated); + tcp_mem =max (0L ,atomic_long_read (&net_aligned_data.tcp_memory_allocated)); + udp_mem =max (0L ,atomic_long_read (&net_aligned_data.udp_memory_allocated)); + +#if IS_ENABLED (CONFIG_IPV4 ) + tcp_inuse =sock_prot_inuse_get (net, &tcp_prot); + udp_inuse =sock_prot_inuse_get (net, &udp_prot); + raw_inuse =sock_prot_inuse_get (net, &raw_prot); +#endif socket_seq_show (seq);seq_printf (seq,"TCP: inuse %d orphan %d tw %d alloc %d mem %ld\n" , -sock_prot_inuse_get (net, &tcp_prot), orphans, + tcp_inuse, orphans,refcount_read (&net->ipv4.tcp_death_row.tw_refcount) -1 , - sockets,proto_memory_allocated (&tcp_prot)); -seq_printf (seq,"UDP: inuse %d mem %ld\n" , -sock_prot_inuse_get (net, &udp_prot), -proto_memory_allocated (&udp_prot)); -seq_printf (seq,"RAW: inuse %d\n" , -sock_prot_inuse_get (net, &raw_prot)); + sockets, tcp_mem); +seq_printf (seq,"UDP: inuse %d mem %ld\n" , udp_inuse, udp_mem); +seq_printf (seq,"RAW: inuse %d\n" , raw_inuse); +#if IS_ENABLED (CONFIG_IPV4 )seq_printf (seq,"FRAG: inuse %u memory %lu\n" ,atomic_read (&net->ipv4.fqdir->rhashtable.nelems),frag_mem_limit (net->ipv4.fqdir)); +#endif return 0 ; }
@@ -304,6 +314,7 @@ static const struct snmp_mib snmp4_net_list[] = { SNMP_MIB_ITEM("TCPAODroppedIcmps", LINUX_MIB_TCPAODROPPEDICMPS), }; +#if IS_ENABLED (CONFIG_IPV4 )static void icmpmsg_put_line (struct seq_file *seq,unsigned long *vals,unsigned short *type,int count) {
@@ -405,8 +416,9 @@ static int snmp_seq_show_ipstats(struct seq_file *seq, void *v) return 0; } +#endif /* CONFIG_IPV4 */ -static int snmp_seq_show_tcp_udp (struct seq_file *seq,void *v) +static int snmp_seq_show_tcp_udp (struct seq_file *seq,void *v,bool first) {const int udp_cnt =ARRAY_SIZE (snmp4_udp_list);const int tcp_cnt =ARRAY_SIZE (snmp4_tcp_list);
@@ -416,7 +428,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v)memset (buff,0 , tcp_cnt *sizeof (unsigned long )); -seq_puts (seq,"\nTcp:" ); +seq_puts (seq, first ?"Tcp:" :"\nTcp:" );for (i =0 ; i < tcp_cnt; i++)seq_printf (seq," %s" , snmp4_tcp_list[i].name);
@@ -450,12 +462,16 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v)static int snmp_seq_show (struct seq_file *seq,void *v) { +#if IS_ENABLED (CONFIG_IPV4 )snmp_seq_show_ipstats (seq, v);icmp_put (seq);/* RFC 2011 compatibility */ icmpmsg_put (seq); -snmp_seq_show_tcp_udp (seq, v); +snmp_seq_show_tcp_udp (seq, v, false); +#else +snmp_seq_show_tcp_udp (seq, v, true); +#endif return 0 ; }
net/ipv4/tcp.c +1299 -0
1,330 lines not on this page · raw message
net/ipv4/tcp_bpf.c +2 -0
@@ -669,12 +669,14 @@ static void tcp_bpf_check_v6_needs_rebuild(struct proto *ops) } } +#if IS_ENABLED (CONFIG_IPV4 )static int __init tcp_bpf_v4_build_proto (void ) {tcp_bpf_rebuild_protos (tcp_bpf_prots[TCP_BPF_IPV4 ], &tcp_prot);return 0 ; }late_initcall (tcp_bpf_v4_build_proto); +#endif static int tcp_bpf_assert_proto_ops (struct proto *ops) {
net/ipv4/tcp_ipv4.c +1 -1306
1,372 lines not on this page · raw message
net/ipv6/tcp_ipv6.c +23 -2
@@ -217,6 +217,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr_unsized *uaddr,*/ if (addr_type &IPV6_ADDR_MAPPED ) { +#if IS_ENABLED (CONFIG_IPV4 )u32 exthdrlen = icsk->icsk_ext_hdr_len;struct sockaddr_in sin;
@@ -253,6 +254,9 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr_unsized *uaddr, np->saddr = sk->sk_v6_rcv_saddr;return err; +#else +return -ENETUNREACH ; +#endif }if (!ipv6_addr_any (&sk->sk_v6_rcv_saddr))
@@ -1316,7 +1320,11 @@ u16 tcp_v6_get_syncookie(struct sock *sk, struct ipv6hdr *iph,static int tcp_v6_conn_request (struct sock *sk,struct sk_buff *skb) { if (skb->protocol == htons(ETH_P_IP)) +#if IS_ENABLED (CONFIG_IPV4 )return tcp_v4_conn_request (sk, skb); +#else + goto drop; +#endif if (!ipv6_unicast_destination (skb)) goto drop;
@@ -1344,6 +1352,7 @@ static void tcp_v6_restore_cb(struct sk_buff *skb) sizeof(struct inet6_skb_parm)); } +#if IS_ENABLED (CONFIG_IPV4 )/* Called from tcp_v4_syn_recv_sock() for v6_mapped children. */ static void tcp_v6_mapped_child_init (struct sock *newsk,const struct sock *sk) {
@@ -1378,6 +1387,7 @@ static void tcp_v6_mapped_child_init(struct sock *newsk, const struct sock *sk)if (inet6_test_bit (REPFLOW , sk)) newnp->flow_label =0 ; } +#endif static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, struct request_sock *req,
@@ -1402,9 +1412,14 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *struct flowi6 fl6; if (skb->protocol == htons(ETH_P_IP)) +#if IS_ENABLED (CONFIG_IPV4 )return tcp_v4_syn_recv_sock (sk, skb, req, dst, req_unhash, own_req, tcp_v6_mapped_child_init); +#else +return NULL ; +#endif + ireq =inet_rsk (req);if (sk_acceptq_is_full (sk))
@@ -1579,8 +1594,14 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)tcp_v6_hnd_req and tcp_v6_send_reset(). --ANK */ -if (skb->protocol ==htons (ETH_P_IP )) +if (skb->protocol ==htons (ETH_P_IP )) { +#if IS_ENABLED (CONFIG_IPV4 )return tcp_v4_do_rcv (sk, skb); +#else +kfree_skb (skb); +return 0 ; +#endif + } reason =psp_sk_rx_policy_check (sk, skb);if (reason)
@@ -2283,7 +2304,7 @@ struct proto tcpv6_prot = { .accept = inet_csk_accept, .ioctl = tcp_ioctl, .init = tcp_v6_init_sock, - .destroy = tcp_v4_destroy_sock, + .destroy = tcp_destroy_sock, .shutdown = tcp_shutdown, .setsockopt = tcp_setsockopt, .getsockopt = tcp_getsockopt,
Signature · 1 line
2.55.0
PATCH 5/13 net: raw: split IPv4 specific logic into raw_ipv4.c
In reply to Fernando Fernandez ManceraTo enable compiling the INET subsystem without IPv4, RAW socket IPv4 specific functions must be isolated from the generic RAW socket infrastructure, similar to how it is done for TCP.
This patch creates raw_ipv4.c and move all the functions for packet matching, input/output processing, ICMP filtering and the AF_INET raw_prot definition from raw.c to the new file. The Makefile is updated to compile raw_ipv4.c only when CONFIG_IPV4 is enabled.
--- net/ipv4/Makefile | 2 +- net/ipv4/raw.c | 853 ------------------------------------------ net/ipv4/raw_diag.c | 4 + net/ipv4/raw_ipv4.c | 883 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 888 insertions(+), 854 deletions(-) create mode 100644 net/ipv4/raw_ipv4.c
net/ipv4/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-y := inetpeer.o protocol.o inet_hashtables.o inet_timewait_sock.o \ obj-$(CONFIG_IPV4) += route.o ip_input.o ip_fragment.o ip_forward.o ip_options.o \ ip_sockglue.o tcp_ipv4.o datagram.o icmp.o arp.o devinet.o \ igmp.o fib_notifier.o ip_output.o fib_frontend.o \ - fib_semantics.o fib_trie.o + fib_semantics.o fib_trie.o raw_ipv4.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
net/ipv4/raw.c +0 -853
896 lines not on this page · raw message
net/ipv4/raw_diag.c +4 -0
@@ -40,10 +40,14 @@ static bool raw_lookup(struct net *net, const struct sock *sk,struct inet_diag_req_raw *r = (void *)req; if (r->sdiag_family == AF_INET) +#if IS_ENABLED (CONFIG_IPV4 )return raw_v4_match (net, sk, r->sdiag_raw_protocol, r->id.idiag_dst[0 ], r->id.idiag_src[0 ], r->id.idiag_if,0 ); +#else +return false; +#endif #if IS_ENABLED (CONFIG_IPV6 ) else return raw_v6_match(net, sk, r->sdiag_raw_protocol,
net/ipv4/raw_ipv4.c new file +883 -0
883 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 6/13 net: udp: split IPv4 specific logic into udp_ipv4.c
In reply to Fernando Fernandez ManceraTo enable compiling the INET subsystem without IPv4, UDP socket IPv4 specific functions must be isolated from the generic UDP socket infrastructure, similar to how it is done for TCP.
This patch creates udp_ipv4.c and move all the functions for packet matching, input/output processing, multicast and the AF_INET udp_prot from udp.c to the new file. The Makefile is updated to compile udp_ipv4.c only when CONFIG_IPV4 is enabled.
--- net/core/filter.c | 4 + net/ipv4/Makefile | 2 +- net/ipv4/af_inet.c | 10 + net/ipv4/udp.c | 1781 +-------------------------------------- net/ipv4/udp_bpf.c | 6 + net/ipv4/udp_diag.c | 12 + net/ipv4/udp_ipv4.c | 1790 ++++++++++++++++++++++++++++++++++++++++ net/ipv4/udp_offload.c | 10 + net/ipv6/udp.c | 18 + 9 files changed, 1868 insertions(+), 1765 deletions(-) create mode 100644 net/ipv4/udp_ipv4.c
net/core/filter.c +4 -0
@@ -7181,9 +7181,13 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple, dst4, tuple->ipv4.dport, dif, sdif, &refcounted); else +#if IS_ENABLED(CONFIG_IPV4) sk =__udp4_lib_lookup (net, src4, tuple->ipv4.sport, dst4, tuple->ipv4.dport, dif, sdif,NULL ); +#else + sk =NULL ; +#endif #if IS_ENABLED (CONFIG_IPV6 ) } else {struct in6_addr *src6 = (struct in6_addr *)&tuple->ipv6.saddr;
net/ipv4/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-y := inetpeer.o protocol.o inet_hashtables.o inet_timewait_sock.o \ obj-$(CONFIG_IPV4) += route.o ip_input.o ip_fragment.o ip_forward.o ip_options.o \ ip_sockglue.o tcp_ipv4.o datagram.o icmp.o arp.o devinet.o \ igmp.o fib_notifier.o ip_output.o fib_frontend.o \ - fib_semantics.o fib_trie.o raw_ipv4.o + fib_semantics.o fib_trie.o raw_ipv4.o udp_ipv4.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
net/ipv4/af_inet.c +10 -0
@@ -888,8 +888,13 @@ int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)return -EAGAIN ; prot =READ_ONCE (sk->sk_prot); +#if IS_ENABLED (CONFIG_IPV4 )return INDIRECT_CALL_2 (prot->sendmsg, tcp_sendmsg, udp_sendmsg, sk, msg, size); +#else +return INDIRECT_CALL_1 (prot->sendmsg, tcp_sendmsg, + sk, msg, size); +#endif }EXPORT_SYMBOL (inet_sendmsg);
@@ -916,8 +921,13 @@ int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,sock_rps_record_flow (sk); prot =READ_ONCE (sk->sk_prot); +#if IS_ENABLED (CONFIG_IPV4 )return INDIRECT_CALL_2 (prot->recvmsg, tcp_recvmsg, udp_recvmsg, sk, msg, size, flags); +#else +return INDIRECT_CALL_1 (prot->recvmsg, tcp_recvmsg, + sk, msg, size, flags); +#endif }EXPORT_SYMBOL (inet_recvmsg);
net/ipv4/udp.c +17 -1764
1,890 lines not on this page · raw message
net/ipv4/udp_bpf.c +6 -0
@@ -16,7 +16,11 @@ static int sk_udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,if (sk->sk_family ==AF_INET6 )return udpv6_prot_saved->recvmsg (sk, msg, len, flags);#endif +#if IS_ENABLED (CONFIG_IPV4 )return udp_prot.recvmsg (sk, msg, len, flags); +#else +return -EAFNOSUPPORT ; +#endif }static bool udp_sk_has_data (struct sock *sk)
@@ -153,12 +157,14 @@ static void udp_bpf_check_v6_needs_rebuild(struct proto *ops) } } +#if IS_ENABLED (CONFIG_IPV4 )static int __init udp_bpf_v4_build_proto (void ) {udp_bpf_rebuild_protos (&udp_bpf_prots[UDP_BPF_IPV4 ], &udp_prot);return 0 ; }late_initcall (udp_bpf_v4_build_proto); +#endif int udp_bpf_update_proto (struct sock *sk,struct sk_psock *psock,bool restore) {
net/ipv4/udp_diag.c +12 -0
@@ -37,11 +37,15 @@ static int udp_diag_dump_one(struct netlink_callback *cb,rcu_read_lock (); if (req->sdiag_family == AF_INET) +#if IS_ENABLED (CONFIG_IPV4 )/* src and dst are swapped for historical reasons */ sk =__udp4_lib_lookup (net, req->id.idiag_src[0 ], req->id.idiag_sport, req->id.idiag_dst[0 ], req->id.idiag_dport, req->id.idiag_if,0 ,NULL ); +#else + sk =NULL ; +#endif #if IS_ENABLED (CONFIG_IPV6 ) else if (req->sdiag_family == AF_INET6) sk = __udp6_lib_lookup(net,
@@ -159,18 +163,26 @@ static int udp_diag_destroy(struct sk_buff *in_skb,rcu_read_lock (); if (req->sdiag_family == AF_INET) +#if IS_ENABLED (CONFIG_IPV4 ) sk =__udp4_lib_lookup (net, req->id.idiag_dst[0 ], req->id.idiag_dport, req->id.idiag_src[0 ], req->id.idiag_sport, req->id.idiag_if,0 ,NULL ); +#else + sk =NULL ; +#endif #if IS_ENABLED (CONFIG_IPV6 ) else if (req->sdiag_family == AF_INET6) {if (ipv6_addr_v4mapped ((struct in6_addr *)req->id.idiag_dst) && ipv6_addr_v4mapped((struct in6_addr *)req->id.idiag_src)) +#if IS_ENABLED (CONFIG_IPV4 ) sk =__udp4_lib_lookup (net, req->id.idiag_dst[3 ], req->id.idiag_dport, req->id.idiag_src[3 ], req->id.idiag_sport, req->id.idiag_if,0 ,NULL ); +#else + sk =NULL ; +#endif else sk = __udp6_lib_lookup(net, (struct in6_addr *)req->id.idiag_dst,
net/ipv4/udp_ipv4.c new file +1790 -0
997 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.55.0
Part of the diff is not shown here. View the raw message.
[email protected]
AI reviewRe: [PATCH 06/13 net-next] net: udp: split IPv4 specific logic into udp_ipv4.c
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Aggregated IPv4 UDP packets are silently dropped during GRO completion when CONFIG_IPV4 is…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Aggregated IPv4 UDP packets are silently dropped during GRO completion when CONFIG_IPV4 is disabled. --
commit d963ce43c73f11f406bea2e26b36c86cf494d30c
Author: Fernando Fernandez Mancera <[email protected]>
net: udp: split IPv4 specific logic into udp_ipv4.c
This commit moves IPv4-specific UDP socket logic from udp.c into a new udp_ipv4.c file. This isolates the IPv4 functions from the generic UDP socket infrastructure, allowing the INET subsystem to be compiled without IPv4.
Quoted 3 lines
net/ipv4/udp_offload.c +0
-0
[ ... ]
Quoted 8 lines
net/ipv4/udp_offload.c +1
-0@@ -954,6 +960,7 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff, INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) { +#if IS_ENABLED (CONFIG_IPV4 )const u16 offset =NAPI_GRO_CB (skb)->network_offsets[skb->encapsulation];const struct iphdr *iph = (struct iphdr *)(skb->data + offset);struct udphdr *uh = (struct udphdr *)(skb->data + nhoff);
[ ... ]
net/ipv4/udp_offload.c INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) · line 988
Quoted 8 lines
net/ipv4/udp_offload.c +3
-0@@ -975,6 +982,9 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) iph->daddr, 0);return udp_gro_complete (skb, nhoff, udp4_lib_lookup_skb); +#else +return -EAFNOSUPPORT ; +#endif }
[Severity: High]
Does this cause aggregated IPv4 UDP packets to be silently dropped during GRO completion when CONFIG_IPV4 is disabled?
When an IPv4 UDP packet stream is aggregated by GRO on a system compiled with CONFIG_IPV4=n, returning -EAFNOSUPPORT causes the GRO engine (gro_complete) to treat the completion as a failure, invoking kfree_skb() and dropping the packet.
Since udp4_gro_receive remains unconditionally enabled in udpv4_offload_init (as net/ipv4/udp_offload.c is compiled when CONFIG_INET=y), untrusted network input can reach this path. Even on an IPv6-only node, an L2 bridge or packet sniffer expects to see L2 traffic correctly. Dropping aggregated packets breaks L2 bridging of IPv4 UDP traffic and prevents packet sniffers from seeing bulk traffic streams.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH 7/13 net: icmp: split IPv4 specific logic into icmp_ipv4.c
In reply to Fernando Fernandez ManceraTo enable compiling INET subsystem withot IPv4, ICMP protocol IPv4 specific functions must be isolated from the generic ICMP protocol infrastructure.
This patch creates icmp_ipv4.c and move all the functions for packet processing, error handling, and other from icmp.c to a new file. The Makefile is updated to compile icmp_ipv4.c only when CONFIG_IPV4 is enabled.
--- include/net/icmp.h | 1 + net/ipv4/Makefile | 9 +- net/ipv4/icmp.c | 1419 +---------------------------------------- net/ipv4/icmp_ipv4.c | 1445 ++++++++++++++++++++++++++++++++++++++++++ net/ipv6/datagram.c | 2 + 5 files changed, 1461 insertions(+), 1415 deletions(-) create mode 100644 net/ipv4/icmp_ipv4.c
include/net/icmp.h +1 -0
@@ -57,6 +57,7 @@ static inline void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __bint icmp_rcv (struct sk_buff *skb);int icmp_err (struct sk_buff *skb,u32 info); +int icmp_init_ipv4 (void );int icmp_init (void );void icmp_out_count (struct net *net,unsigned char type);bool icmp_build_probe (struct sk_buff *skb,struct icmphdr *icmphdr);
net/ipv4/Makefile +5 -4
@@ -8,12 +8,13 @@ obj-y := inetpeer.o protocol.o inet_hashtables.o inet_timewait_sock.o \ tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \ tcp_recovery.o tcp_ulp.o tcp_offload.o tcp_plb.o raw.o udp.o \ udp_offload.o af_inet.o inet_fragment.o ping.o ip_tunnel_core.o \ - gre_offload.o metrics.o netlink.o nexthop.o udp_tunnel_stub.o + gre_offload.o metrics.o netlink.o nexthop.o udp_tunnel_stub.o \ + icmp.o obj-$(CONFIG_IPV4) += route.o ip_input.o ip_fragment.o ip_forward.o ip_options.o \ - ip_sockglue.o tcp_ipv4.o datagram.o icmp.o arp.o devinet.o \ - igmp.o fib_notifier.o ip_output.o fib_frontend.o \ - fib_semantics.o fib_trie.o raw_ipv4.o udp_ipv4.o + ip_sockglue.o tcp_ipv4.o datagram.o arp.o devinet.o igmp.o \ + fib_notifier.o ip_output.o fib_frontend.o fib_semantics.o \ + fib_trie.o raw_ipv4.o udp_ipv4.o icmp_ipv4.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
net/ipv4/icmp.c +8 -1411
1,466 lines not on this page · raw message
net/ipv4/icmp_ipv4.c new file +1445 -0
1,445 lines not on this page · raw message
net/ipv6/datagram.c +2 -0
@@ -205,7 +205,9 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr_unsized *uaddr, (struct sockaddr_unsized *)&sin, sizeof(sin)); +#if IS_ENABLED (CONFIG_IPV4 ) ipv4_connected: +#endif if (err) goto out;
Signature · 1 line
2.55.0
PATCH 8/13 net: ping: split IPv4 specific logic into ping_ipv4.c
In reply to Fernando Fernandez ManceraTo enable compiling INET subsystem withot IPv4, ping socket IPv4 specific functions must be isolated from the generic ping infrastructure.
This patch creates ping_ipv4.c and move all the functions for packet transmission and the AF_INET ping_prot definition from ping.c to the new file. The Makefile is updated to compile ping_ipv4.c only when CONFIG_IPV4 is enabled.
--- net/ipv4/Makefile | 2 +- net/ipv4/ping.c | 215 +++------------------------------------- net/ipv4/ping_ipv4.c | 228 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+), 204 deletions(-) create mode 100644 net/ipv4/ping_ipv4.c
net/ipv4/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-y := inetpeer.o protocol.o inet_hashtables.o inet_timewait_sock.o \ obj-$(CONFIG_IPV4) += route.o ip_input.o ip_fragment.o ip_forward.o ip_options.o \ ip_sockglue.o tcp_ipv4.o datagram.o arp.o devinet.o igmp.o \ fib_notifier.o ip_output.o fib_frontend.o fib_semantics.o \ - fib_trie.o raw_ipv4.o udp_ipv4.o icmp_ipv4.o + fib_trie.o raw_ipv4.o udp_ipv4.o icmp_ipv4.o ping_ipv4.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
net/ipv4/ping.c +12 -203
292 lines not on this page · raw message
net/ipv4/ping_ipv4.c new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 9/13 net: fib: split common nexthop logic to fib_core.c
In reply to Fernando Fernandez ManceraTo enable compiling INET subsystem without IPv4, shared FIB and nexthop logic must be accessible to IPv6 when IPv4 routing stack is omitted.
This patch creates fib_core.c and move all the functions for common nexthop initialization and release from fib_semantics.c to fib_core.c. Note that fib_core.c is under net/core.
--- include/net/ip_fib.h | 27 +++- include/net/route.h | 6 + net/core/Makefile | 2 +- net/core/fib_core.c | 307 +++++++++++++++++++++++++++++++++++++ net/ipv4/Makefile | 2 + net/ipv4/fib_frontend.c | 96 ------------ net/ipv4/fib_semantics.c | 205 ------------------------- net/ipv4/netlink.c | 2 + net/ipv4/nexthop.c | 9 +- net/ipv4/sysctl_net_ipv4.c | 2 + 10 files changed, 353 insertions(+), 305 deletions(-) create mode 100644 net/core/fib_core.c
include/net/ip_fib.h +26 -1
@@ -250,7 +250,13 @@ int call_fib4_notifiers(struct net *net, enum fib_event_type event_type,int __net_init fib4_notifier_init (struct net *net); void __net_exit fib4_notifier_exit(struct net *net); +#if IS_ENABLED (CONFIG_IPV4 )void fib_info_notify_update (struct net *net,struct nl_info *info); +#else +static inline void fib_info_notify_update (struct net *net,struct nl_info *info) +{ +} +#endif int fib_notify (struct net *net,struct notifier_block *nb,struct netlink_ext_ack *extack);
@@ -442,7 +448,7 @@ static inline bool fib_dscp_masked_match(dscp_t dscp, const struct flowi4 *fl4)return dscp == (fl4->flowi4_dscp &INET_DSCP_LEGACY_TOS_MASK ); } -/* Exported by fib_frontend.c */ +/* Exported by net/core/fib_core.c */ extern const struct nla_policy rtm_ipv4_policy[];void ip_fib_init (void ); int fib_gw_from_via(struct fib_config *cfg, struct nlattr *nla,
@@ -578,10 +584,23 @@ void fib_select_multipath(struct fib_result *res, int hash,void fib_select_path (struct net *net,struct fib_result *res,struct flowi4 *fl4,const struct sk_buff *skb); +#if IS_ENABLED (CONFIG_IPV4 )int fib_nh_init (struct net *net,struct fib_nh *fib_nh,struct fib_config *cfg,int nh_weight,struct netlink_ext_ack *extack);void fib_nh_release (struct net *net,struct fib_nh *fib_nh); +#else +static inline int fib_nh_init (struct net *net,struct fib_nh *fib_nh, +struct fib_config *cfg,int gfp, +struct netlink_ext_ack *extack) +{ +return -EAFNOSUPPORT ; +} + +static inline void fib_nh_release (struct net *net,struct fib_nh *fib_nh) +{ +} +#endif int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc, struct nlattr *fc_encap, u16 fc_encap_type, void *cfg, gfp_t gfp_flags,
@@ -620,7 +639,13 @@ static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)#endif } +#if IS_ENABLED (CONFIG_IPV4 )void fib_flush (struct net *net); +#else +static inline void fib_flush (struct net *net) +{ +} +#endif void free_fib_info (struct fib_info *fi);static inline void fib_info_hold (struct fib_info *fi)
include/net/route.h +6 -0
@@ -128,7 +128,13 @@ extern struct ip_rt_acct __percpu *ip_rt_acct;struct in_device ;int ip_rt_init (void ); +#if IS_ENABLED (CONFIG_IPV4 )void rt_cache_flush (struct net *net); +#else +static inline void rt_cache_flush (struct net *net) +{ +} +#endif void rt_flush_dev (struct net_device *dev); static inline void inet_sk_init_flowi4(const struct inet_sock *inet,
net/core/Makefile +1 -1
@@ -12,7 +12,7 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o obj-y += dev.o dev_api.o dev_addr_lists.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \ - fib_notifier.o xdp.o flow_offload.o gro.o \ + fib_notifier.o fib_core.o xdp.o flow_offload.o gro.o \ netdev-genl.o netdev-genl-gen.o netdev_work.o gso.o obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o
net/core/fib_core.c new file +307 -0
307 lines not on this page · raw message
net/ipv4/Makefile +2 -0
@@ -19,7 +19,9 @@ obj-$(CONFIG_IPV4) += route.o ip_input.o ip_fragment.o ip_forward.o ip_options.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o obj-$(CONFIG_PROC_FS) += proc.o +ifeq ($(CONFIG_IPV4),y) obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o +endif obj-$(CONFIG_IP_MROUTE) += ipmr.o obj-$(CONFIG_IP_MROUTE_COMMON) += ipmr_base.o obj-$(CONFIG_NET_IPIP) += ipip.o
net/ipv4/fib_frontend.c +0 -96
108 lines not on this page · raw message
net/ipv4/fib_semantics.c +0 -205
223 lines not on this page · raw message
net/ipv4/netlink.c +2 -0
@@ -16,10 +16,12 @@ int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family,case IPPROTO_TCP :case IPPROTO_UDP :return 0 ; +#if IS_ENABLED (CONFIG_IPV4 )case IPPROTO_ICMP :if (family !=AF_INET )break ;return 0 ; +#endif #if IS_ENABLED (CONFIG_IPV6 )case IPPROTO_ICMPV6 :if (family !=AF_INET6 )
net/ipv4/nexthop.c +7 -2
@@ -1421,7 +1421,7 @@ static bool nexthop_is_good_nh(const struct nexthop *nh)switch (nhi->family) {case AF_INET : -return ipv4_good_nh (&nhi->fib_nh); +return IS_ENABLED (CONFIG_IPV4 ) &&ipv4_good_nh (&nhi->fib_nh);case AF_INET6 :return IS_ENABLED (CONFIG_IPV6 ) &&ipv6_good_nh (&nhi->fib6_nh); }
@@ -3970,6 +3970,7 @@ static int rtm_get_nexthop_bucket(struct sk_buff *in_skb, struct nlmsghdr *nlh,return err; } +#if IS_ENABLED (CONFIG_IPV4 )static void nexthop_sync_mtu (struct net_device *dev,u32 orig_mtu) {unsigned int hash =nh_dev_hashfn (dev->ifindex);
@@ -3986,13 +3987,13 @@ static void nexthop_sync_mtu(struct net_device *dev, u32 orig_mtu) } } } +#endif /* rtnl */ static int nh_netdev_event (struct notifier_block *this,unsigned long event,void *ptr) {struct net_device *dev =netdev_notifier_info_to_dev (ptr); -struct netdev_notifier_info_ext *info_ext;switch (event) {case NETDEV_DOWN :
@@ -4004,8 +4005,12 @@ static int nh_netdev_event(struct notifier_block *this,nexthop_flush_dev (dev, event);break ;case NETDEV_CHANGEMTU : +#if IS_ENABLED (CONFIG_IPV4 ) +struct netdev_notifier_info_ext *info_ext; + info_ext = ptr;nexthop_sync_mtu (dev, info_ext->ext.mtu); +#endif rt_cache_flush (dev_net (dev));break ; }
net/ipv4/sysctl_net_ipv4.c +2 -0
@@ -613,6 +613,7 @@ static struct ctl_table ipv4_table[] = { .mode = 0644, .proc_handler = proc_doulongvec_minmax, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "fib_sync_mem", .data = &sysctl_fib_sync_mem,
@@ -622,6 +623,7 @@ static struct ctl_table ipv4_table[] = { .extra1 = &sysctl_fib_sync_mem_min, .extra2 = &sysctl_fib_sync_mem_max, }, +#endif }; static const struct ctl_table ipv4_net_table[] = {
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 09/13 net-next] net: fib: split common nexthop logic to fib_core.c
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Syntax error in `nh_netdev_event` when `CONFIG_IPV4` is enabled, causing a build failure. - [Low]…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Syntax error in nh_netdev_event when CONFIG_IPV4 is enabled, causing a build failure.
- [Low] Parameter name mismatch in the dummy inline function for fib_nh_init. --
commit 243925357332d15aa13a077472006e05019dde8d
Author: Fernando Fernandez Mancera <[email protected]>
net: fib: split common nexthop logic to fib_core.c
This commit creates fib_core.c and moves functions for common nexthop initialization and release from fib_semantics.c to fib_core.c. This makes shared FIB and nexthop logic accessible to IPv6 when the IPv4 routing stack is omitted.
Quoted 4 lines
include/net/ip_fib.h +0
-0
[ ... ]
include/net/ip_fib.h void fib_select_multipath(struct fib_result *res, int hash, · line 594
Quoted 12 lines
include/net/ip_fib.h +4
-0@@ -578,10 +584,23 @@ void fib_select_multipath(struct fib_result *res, int hash,void fib_select_path (struct net *net,struct fib_result *res,struct flowi4 *fl4,const struct sk_buff *skb); +#if IS_ENABLED (CONFIG_IPV4 )int fib_nh_init (struct net *net,struct fib_nh *fib_nh,struct fib_config *cfg,int nh_weight,struct netlink_ext_ack *extack);void fib_nh_release (struct net *net,struct fib_nh *fib_nh); +#else +static inline int fib_nh_init(struct net *net, struct fib_nh *fib_nh, + struct fib_config *cfg, int gfp,
^^^
[Severity: Low]
Does this code use the correct parameter name here? The actual definition of fib_nh_init in the IPv4 block uses int nh_weight for the fourth parameter. Using gfp in the stub obscures the API contract and might mislead developers into passing a GFP flag instead of a routing weight.
Quoted 4 lines
include/net/ip_fib.h +4
-0+ struct netlink_ext_ack *extack) +{ +return -EAFNOSUPPORT ; +}
[ ... ]
Quoted 4 lines
net/ipv4/nexthop.c +0
-0
[ ... ]
net/ipv4/nexthop.c static int nh_netdev_event(struct notifier_block *this, · line 4013
Quoted 10 lines
net/ipv4/nexthop.c +4
-0@@ -4004,8 +4005,12 @@ static int nh_netdev_event(struct notifier_block *this,nexthop_flush_dev (dev, event);break ;case NETDEV_CHANGEMTU : +#if IS_ENABLED (CONFIG_IPV4 ) +struct netdev_notifier_info_ext *info_ext; + info_ext = ptr;nexthop_sync_mtu (dev, info_ext->ext.mtu); +#endif
[Severity: Low]
Can this sequence cause a build failure when CONFIG_IPV4 is enabled? In C, a case label cannot be immediately followed by a declaration. This causes a compilation error because a label can only be part of a statement, and a declaration is not a statement. Could we add a block or move the declaration to avoid breaking the build?
Quoted 3 lines
net/ipv4/nexthop.c +0
-0rt_cache_flush (dev_net (dev));break ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
PATCH 10/13 net: tunnel: guard IPv4 tunnel functions with CONFIG_IPV4
In reply to Fernando Fernandez ManceraTo enable compiling INET subsystem withou IPv4, IPv4 specific IP tunnel core functions must be bypassed when the protocol is disabled.
--- net/ipv4/ip_tunnel_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/ipv4/ip_tunnel_core.c +11 -0
@@ -52,6 +52,7 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, __u8 tos, __u8 ttl, __be16 df, bool xnet, u16 ipcb_flags) { +#if IS_ENABLED(CONFIG_IPV4) int pkt_len = skb->len -skb_inner_network_offset (skb);struct net *net =dev_net (rt->dst.dev);struct net_device *dev = skb->dev;
@@ -103,6 +104,12 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb, }dev_xmit_recursion_dec (); +#else +if (skb->dev) +DEV_STATS_INC (skb->dev, tx_errors); +ip_rt_put (rt); +kfree_skb (skb); +#endif }EXPORT_SYMBOL_GPL (iptunnel_xmit);
@@ -212,6 +219,7 @@ EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);*/ static int iptunnel_pmtud_build_icmp (struct sk_buff *skb,int mtu) { +#if IS_ENABLED (CONFIG_IPV4 )const struct iphdr *iph;struct icmphdr *icmph;struct iphdr *niph;
@@ -269,6 +277,9 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu)skb_reset_mac_header (skb);return skb->len; +#else +return -EOPNOTSUPP ; +#endif }/**
Signature · 1 line
2.55.0
PATCH 11/13 netfilter: ipv4: guard ip_route_me_harder() with CONFIG_IPV4
In reply to Fernando Fernandez ManceraTo enable compiling the network stack without IPv4, IPv4 specific packet rerouting logic inside netfilter must be bypassed. Therefore, guard ip_route_me_harder() with IS_ENABLED(CONFIG_IPV4) so it returns -EPROTONOSUPPORT when IPv4 is disabled.
--- net/ipv4/netfilter.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv4/netfilter.c +4 -0
@@ -21,6 +21,7 @@/* route_me_harder function, used by iptable_nat, iptable_mangle + ip_queue */ int ip_route_me_harder (struct net *net,struct sock *sk,struct sk_buff *skb,unsigned int addr_type) { +#if IS_ENABLED (CONFIG_IPV4 )struct net_device *dev =skb_dst_dev (skb);const struct iphdr *iph =ip_hdr (skb);struct rtable *rt;
@@ -85,6 +86,9 @@ int ip_route_me_harder(struct net *net, struct sock *sk, struct sk_buff *skb, unreturn -ENOMEM ;return 0 ; +#else +return -EPROTONOSUPPORT ; +#endif }EXPORT_SYMBOL (ip_route_me_harder);
Signature · 1 line
2.55.0
PATCH 12/13 net: ipv4: disable IPv4-only sysctls when CONFIG_IPV4=n
In reply to Fernando Fernandez ManceraTo avoid noise and unexpected problems, let's hide all the sysctls that are related to IPv4 only when the kernel is compiled without IPv4 support.
--- net/ipv4/sysctl_net_ipv4.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
net/ipv4/sysctl_net_ipv4.c +27 -3
@@ -31,8 +31,8 @@ static int tcp_min_snd_mss_max = 65535;static int tcp_rto_max_max =TCP_RTO_MAX_SEC *MSEC_PER_SEC ;static int ip_privileged_port_min;static int ip_privileged_port_max =65535 ; -static int ip_ttl_min =1 ; -static int ip_ttl_max =255 ; +static int ip_ttl_min__maybe_unused =1 ; +static int ip_ttl_max__maybe_unused =255 ;static int tcp_syn_retries_min =1 ;static int tcp_syn_retries_max =MAX_TCP_SYNCNT ;static int tcp_syn_linear_timeouts_max =MAX_TCP_SYNCNT ;
@@ -48,7 +48,7 @@ static int tcp_plb_max_rounds = 31;static int tcp_plb_max_cong_thresh =256 ;static unsigned int tcp_tw_reuse_delay_max =TCP_PAWS_MSL *MSEC_PER_SEC ;static int tcp_ecn_mode_max =5 ; -static u32 icmp_errors_extension_mask_all = +static u32 icmp_errors_extension_mask_all__maybe_unused =GENMASK_U8 (ICMP_ERR_EXT_COUNT -1 ,0 );/* obsolete */
@@ -199,6 +199,7 @@ static int ipv4_ping_group_range(const struct ctl_table *table, int write,return ret; } +#if IS_ENABLED (CONFIG_IPV4 )static int ipv4_fwd_update_priority (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -214,6 +215,7 @@ static int ipv4_fwd_update_priority(const struct ctl_table *table, int write, return ret; } +#endif static int proc_tcp_congestion_control (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos)
@@ -439,6 +441,7 @@ static int proc_udp_hash_entries(const struct ctl_table *table, int write, }#ifdef CONFIG_IP_ROUTE_MULTIPATH +#if IS_ENABLED (CONFIG_IPV4 )static int proc_fib_multipath_hash_policy (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos)
@@ -469,6 +472,7 @@ static int proc_fib_multipath_hash_fields(const struct ctl_table *table, int wri return ret; } +#endif static u32 proc_fib_multipath_hash_rand_seed__ro_after_init ;
@@ -490,6 +494,7 @@ static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed)WRITE_ONCE (net->ipv4.sysctl_fib_multipath_hash_seed.mp_seed, new.mp_seed); } +#if IS_ENABLED (CONFIG_IPV4 )static int proc_fib_multipath_hash_seed (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos)
@@ -515,6 +520,7 @@ static int proc_fib_multipath_hash_seed(const struct ctl_table *table, int write return ret; } +#endif #else static void proc_fib_multipath_hash_init_rand_seed (void )
@@ -634,6 +640,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "icmp_echo_ignore_all", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
@@ -643,6 +650,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE }, +#endif { .procname = "icmp_echo_enable_probe", .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe,
@@ -652,6 +660,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
@@ -702,6 +711,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, +#endif { .procname = "icmp_msgs_per_sec", .data = &init_net.ipv4.sysctl_icmp_msgs_per_sec,
@@ -772,6 +782,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "ip_dynaddr", .data = &init_net.ipv4.sysctl_ip_dynaddr,
@@ -779,6 +790,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, }, +#endif { .procname = "ip_early_demux", .data = &init_net.ipv4.sysctl_ip_early_demux,
@@ -809,6 +821,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "ip_default_ttl", .data = &init_net.ipv4.sysctl_ip_default_ttl,
@@ -818,6 +831,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = &ip_ttl_min, .extra2 = &ip_ttl_max, }, +#endif { .procname = "ip_local_port_range", .maxlen = 0,
@@ -839,6 +853,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_do_large_bitmap, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "ip_no_pmtu_disc", .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
@@ -869,6 +884,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, }, +#endif { .procname = "ip_autobind_reuse", .data = &init_net.ipv4.sysctl_ip_autobind_reuse,
@@ -878,6 +894,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "fwmark_reflect", .data = &init_net.ipv4.sysctl_fwmark_reflect,
@@ -885,6 +902,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, }, +#endif { .procname = "tcp_fwmark_accept", .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
@@ -950,6 +968,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_douintvec_minmax, .extra2 = &u32_max_div_HZ, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "igmp_link_local_mcast_reports", .data = &init_net.ipv4.sysctl_igmp_llm_reports,
@@ -980,6 +999,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE }, +#endif #endif { .procname = "tcp_congestion_control",
@@ -1152,6 +1172,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_tfo_blackhole_detect_timeout, .extra1 = SYSCTL_ZERO, }, +#if IS_ENABLED(CONFIG_IPV4) #ifdef CONFIG_IP_ROUTE_MULTIPATH { .procname = "fib_multipath_use_neigh",
@@ -1187,6 +1208,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_fib_multipath_hash_seed, }, +#endif #endif { .procname = "ip_unprivileged_port_start",
@@ -1561,6 +1583,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "fib_notify_on_flag_change", .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change,
@@ -1570,6 +1593,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, +#endif { .procname = "tcp_plb_enabled", .data = &init_net.ipv4.sysctl_tcp_plb_enabled,
Signature · 1 line
2.55.0
Re: [PATCH 12/13 net-next] net: ipv4: disable IPv4-only sysctls when CONFIG_IPV4=n
Quoted 178 lines · Fernando Fernandez Mancera
To avoid noise and unexpected problems, let's hide all the sysctls that are related to IPv4 only when the kernel is compiled without IPv4 support.
Signed-off-by Fernando Fernandez Mancera <[email protected]>--- net/ipv4/sysctl_net_ipv4.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)net/ipv4/sysctl_net_ipv4.c +21
-3@@ -31,8 +31,8 @@ static int tcp_min_snd_mss_max = 65535;static int tcp_rto_max_max =TCP_RTO_MAX_SEC *MSEC_PER_SEC ;static int ip_privileged_port_min;static int ip_privileged_port_max =65535 ; -static int ip_ttl_min =1 ; -static int ip_ttl_max =255 ; +static int ip_ttl_min__maybe_unused =1 ; +static int ip_ttl_max__maybe_unused =255 ;static int tcp_syn_retries_min =1 ;static int tcp_syn_retries_max =MAX_TCP_SYNCNT ;static int tcp_syn_linear_timeouts_max =MAX_TCP_SYNCNT ;@@ -48,7 +48,7 @@ static int tcp_plb_max_rounds = 31;static int tcp_plb_max_cong_thresh =256 ;static unsigned int tcp_tw_reuse_delay_max =TCP_PAWS_MSL *MSEC_PER_SEC ;static int tcp_ecn_mode_max =5 ; -static u32 icmp_errors_extension_mask_all = +static u32 icmp_errors_extension_mask_all__maybe_unused =GENMASK_U8 (ICMP_ERR_EXT_COUNT -1 ,0 );/* obsolete */ @@ -199,6 +199,7 @@ static int ipv4_ping_group_range(const struct ctl_table *table, int write,return ret; } +#if IS_ENABLED (CONFIG_IPV4 )static int ipv4_fwd_update_priority (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {@@ -214,6 +215,7 @@ static int ipv4_fwd_update_priority(const struct ctl_table *table, int write, return ret; } +#endif static int proc_tcp_congestion_control (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos)@@ -439,6 +441,7 @@ static int proc_udp_hash_entries(const struct ctl_table *table, int write, }#ifdef CONFIG_IP_ROUTE_MULTIPATH +#if IS_ENABLED (CONFIG_IPV4 )static int proc_fib_multipath_hash_policy (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos)@@ -469,6 +472,7 @@ static int proc_fib_multipath_hash_fields(const struct ctl_table *table, int wri return ret; } +#endif static u32 proc_fib_multipath_hash_rand_seed__ro_after_init ;@@ -490,6 +494,7 @@ static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed)WRITE_ONCE (net->ipv4.sysctl_fib_multipath_hash_seed.mp_seed, new.mp_seed); } +#if IS_ENABLED (CONFIG_IPV4 )static int proc_fib_multipath_hash_seed (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos)@@ -515,6 +520,7 @@ static int proc_fib_multipath_hash_seed(const struct ctl_table *table, int write return ret; } +#endif #else static void proc_fib_multipath_hash_init_rand_seed (void )@@ -634,6 +640,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "icmp_echo_ignore_all", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,@@ -643,6 +650,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE }, +#endif { .procname = "icmp_echo_enable_probe", .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe,@@ -652,6 +660,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,@@ -702,6 +711,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, +#endif { .procname = "icmp_msgs_per_sec", .data = &init_net.ipv4.sysctl_icmp_msgs_per_sec,@@ -772,6 +782,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "ip_dynaddr", .data = &init_net.ipv4.sysctl_ip_dynaddr,@@ -779,6 +790,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, }, +#endif { .procname = "ip_early_demux", .data = &init_net.ipv4.sysctl_ip_early_demux,@@ -809,6 +821,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "ip_default_ttl", .data = &init_net.ipv4.sysctl_ip_default_ttl,@@ -818,6 +831,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = &ip_ttl_min, .extra2 = &ip_ttl_max, }, +#endif { .procname = "ip_local_port_range", .maxlen = 0,@@ -839,6 +853,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_do_large_bitmap, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "ip_no_pmtu_disc", .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,@@ -869,6 +884,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, }, +#endif { .procname = "ip_autobind_reuse", .data = &init_net.ipv4.sysctl_ip_autobind_reuse,@@ -878,6 +894,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "fwmark_reflect", .data = &init_net.ipv4.sysctl_fwmark_reflect,@@ -885,6 +902,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, }, +#endif { .procname = "tcp_fwmark_accept", .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
net/ipv4/sysctl_net_ipv4.c static const struct ctl_table ipv4_net_table[] = { · line 971
Quoted 4 lines
net/ipv4/sysctl_net_ipv4.c +1
-0@@ -950,6 +968,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_douintvec_minmax, .extra2 = &u32_max_div_HZ, }, +#if IS_ENABLED (CONFIG_IPV4 )
That is a *lot* of #if IS_ENABLED....#endif.
Is it possible to just have one #if...#endif and put all the related IPV4 sysctl together?
Quoted 46 lines
net/ipv4/sysctl_net_ipv4.c +5
-0{ .procname = "igmp_link_local_mcast_reports", .data = &init_net.ipv4.sysctl_igmp_llm_reports,@@ -980,6 +999,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE }, +#endif #endif { .procname = "tcp_congestion_control",@@ -1152,6 +1172,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_tfo_blackhole_detect_timeout, .extra1 = SYSCTL_ZERO, }, +#if IS_ENABLED(CONFIG_IPV4) #ifdef CONFIG_IP_ROUTE_MULTIPATH { .procname = "fib_multipath_use_neigh",@@ -1187,6 +1208,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_fib_multipath_hash_seed, }, +#endif #endif { .procname = "ip_unprivileged_port_start",@@ -1561,6 +1583,7 @@ static const struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE }, +#if IS_ENABLED (CONFIG_IPV4 ) { .procname = "fib_notify_on_flag_change", .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change,@@ -1570,6 +1593,7 @@ static const struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, +#endif { .procname = "tcp_plb_enabled", .data = &init_net.ipv4.sysctl_tcp_plb_enabled,Signature · 1 line
2.55.0
PATCH 13/13 net: ipv4: make CONFIG_IPV4 boolean
In reply to Fernando Fernandez ManceraChange CONFIG_IPV4 from hidden 'def_bool y' into an exposed boolean. This allows users to explicitly disable IPv4 via Kconfig to build IPv6-only. The default is kept at 'INET' to prevent breaking existing configurations.
--- net/ipv4/Kconfig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/ipv4/Kconfig +9 -1
@@ -3,7 +3,15 @@ # IP configuration # config IPV4 - def_bool y + bool "The IPv4 protocol" if IPV6 + default INET + help + Support for IP version 4 (IPv4). + + Disabling this option compiles the kernel networking stack without + IPv4 support, resulting in a IPv6-only system. + + If unsure, say Y. config IP_MULTICAST bool "IP: multicasting"
Signature · 1 line
2.55.0
Jakub Kicinski
maintainerQuoted 3 lines · On Thu, 10 Sep 2026 16:48:25 +0200 Fernando Fernandez Mancera wrote:
The primary goal of this patch series is to enable the compilation of an IPv6-only kernel by decoupling the core networking infrastructure from the IPv4 protocol.
Could you useful to know for example how many of the recent CVEs were IPv4 specific, if you have enough token budget to get such data?
High level, I don't have must to say beyond what you already know - the code movement may be too painful for backports. There are too many ifdefs (as Stan pointed out).
sparse also complains about patch 9.
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Thu, 10 Sep 2026 16:48:25 +0200 Fernando Fernandez Mancera wrote:
The primary goal of this patch series is to enable the compilation of an IPv6-only kernel by decoupling the core networking infrastructure from the IPv4 protocol.
Could you useful to know for example how many of the recent CVEs were IPv4 specific, if you have enough token budget to get such data?
Hi Jakub I will include the numbers in the v2 cover letter but in essence:
0.3% (32) of the released CVEs since 2025. FWIW, this only includes strictly IPv4-only code. The percentage is also stable over time if we extend the search up to 2020, 0.3% (57) of the released CVEs.
Quoted 4 lines
High level, I don't have must to say beyond what you already know - the code movement may be too painful for backports. There are too many ifdefs (as Stan pointed out).
Yes, the code movement is the biggest pain. Regarding the ifdefs, they are being reduced greatly in the v2 as I have decided to rely on DCE (Dead Code Elimination) to avoid using them. The code looks much better this way.
Quoted 1 line
sparse also complains about patch 9.
It should be fixed too, thanks!
Willem de Bruijn
maintainerQuoted 21 lines · Fernando Fernandez Mancera
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Thu, 10 Sep 2026 16:48:25 +0200 Fernando Fernandez Mancera wrote:
The primary goal of this patch series is to enable the compilation of an IPv6-only kernel by decoupling the core networking infrastructure from the IPv4 protocol.
Could you useful to know for example how many of the recent CVEs were IPv4 specific, if you have enough token budget to get such data?
Hi Jakub I will include the numbers in the v2 cover letter but in essence:
0.3% (32) of the released CVEs since 2025. FWIW, this only includes strictly IPv4-only code. The percentage is also stable over time if we extend the search up to 2020, 0.3% (57) of the released CVEs.
Quoted 4 lines
High level, I don't have must to say beyond what you already know - the code movement may be too painful for backports. There are too many ifdefs (as Stan pointed out).
Quoted 4 lines
Yes, the code movement is the biggest pain. Regarding the ifdefs, they are being reduced greatly in the v2 as I have decided to rely on DCE (Dead Code Elimination) to avoid using them. The code looks much better this way.
On code movement: are the large code block movements into separate ipv4 files needed, or could those just as well stay in place, behind an if enabled check?
Quoted 22 lines · Willem de Bruijn
Quoted 21 lines · Fernando Fernandez Mancera
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Thu, 10 Sep 2026 16:48:25 +0200 Fernando Fernandez Mancera wrote:
The primary goal of this patch series is to enable the compilation of an IPv6-only kernel by decoupling the core networking infrastructure from the IPv4 protocol.
Could you useful to know for example how many of the recent CVEs were IPv4 specific, if you have enough token budget to get such data?
Hi Jakub I will include the numbers in the v2 cover letter but in essence:
0.3% (32) of the released CVEs since 2025. FWIW, this only includes strictly IPv4-only code. The percentage is also stable over time if we extend the search up to 2020, 0.3% (57) of the released CVEs.
Quoted 4 lines
High level, I don't have must to say beyond what you already know - the code movement may be too painful for backports. There are too many ifdefs (as Stan pointed out).
Quoted 8 lines
Quoted 4 lines
Yes, the code movement is the biggest pain. Regarding the ifdefs, they are being reduced greatly in the v2 as I have decided to rely on DCE (Dead Code Elimination) to avoid using them. The code looks much better this way.
On code movement: are the large code block movements into separate ipv4 files needed, or could those just as well stay in place, behind an if enabled check?
It depends. Most of it could be guarded with ifdefs but that would IMHO make the code ugly and quite confusing. That code is 100% IPv4-only so it should be moved out..
In addition, this happened in the past too, e.g net/ipv4/tcp_ipv4.c was splitted from net/ipv4/tcp.c even before this series.
Of course, I trust maintainers' taste here so if you all insist that it is much better to put ifdefs.. so be it! But in my opinion, this make completes sense (while acknowledging the pain it might introduce for backports). FWIW, the code does not change.. so finding the function in the other file should be rather easy.
Thanks,
Fernando.