Commit graph

1,484,663 commits

Author SHA1 Message Date
Arthur Crepin Leblond
323767fa31 w5100: detect carrier state using link status bit and optional interrupt
Detect the carrier state on the w5500 Ethernet controller using the
Link Status bit from the PHY Configuration register (PHYCFGR).

On w5100/w5200, which lack this register, get_link() is not implemented
and the carrier state is not reported (netif_carrier_(on|off) is not
called).

For the w5500, add an optional interrupt, wired to the LINKLED pin of
the device, to detect link status changes with a read of the PHYCFGR
register and update of the carrier state with netif_carrier_(on|off).
If this interrupt is not set in the DT binding, get_link() is not
implemented and the carrier state is not reported
(netif_carrier_(on|off) is not called).
The interrupt handler and the PHYCFGR register readings are
synchronized using a mutex.

A few changes are also brought for the bring-up/teardown
synchronization:

 - The net device is registered last in the probe() function so no
   operation can be performed before the probing is finished
 - The net device is unregistered first in remove()
 - dev_name is now used instead of netdev_name
 - w5100_stop() calls cancel_work_sync() and flush_work() to make sure
   there is no race condition or unfinished work
 - w5100_suspend() calls w5100_stop()
 - w5100_resume() calls w5100_open()
 - The main irq is not automatically enabled in w5100_probe() but in
   w5100_open() and disabled in w5100_stop()

Commit dacf281771 ("w5100: remove unused gpio link detection")
dropped the link_gpio/link_irq handling on the grounds that no
devicetree user passed a "link" gpio at the time and that it used the
old gpio interface.
This isn't a plain revert of that removal: link detection is now done
using a second interrupt rather than a gpio with a documented DT
binding.

Set the WIZNET entry as DRIVER and add drivers/net/ethernet/wiznet in
MAINTAINERS file.

Signed-off-by: Arthur Crepin Leblond <arthur@marmottus.net>
Fixes: dacf281771 ("w5100: remove unused gpio link detection")
Link: https://patch.msgid.link/20260924-wiznet-link-gpio-v11-3-42a332517b30@marmottus.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 17:31:21 -07:00
Arthur Crepin Leblond
50c4bbaa0d dt-bindings: net: wiznet,w5100: add link status interrupt
Add an optional link status interrupt which can be connected to the
LINKLED pin on the device to detect link status changes. This second
interrupt is only supported on wiznet,w5500.

Signed-off-by: Arthur Crepin Leblond <arthur@marmottus.net>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20260924-wiznet-link-gpio-v11-2-42a332517b30@marmottus.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 17:31:21 -07:00
Arthur Crepin Leblond
be15d99d8e dt-bindings: net: wiznet,w5100: convert to DT schema
Convert the Wiznet w5x00 SPI Ethernet controller binding from
plain text to DT schema.

Change the trigger type from edge-falling to low to match the driver
implementation.

Add wiznet,w5100.yaml entry in MAINTAINERS.

Signed-off-by: Arthur Crepin Leblond <arthur@marmottus.net>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260924-wiznet-link-gpio-v11-1-42a332517b30@marmottus.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 17:31:21 -07:00
Nicolai Buchwitz
a58cdf56b6 net: bcmgenet: complete Tx NAPI after one reclaim pass
After reclaiming, the Tx poll asks to be polled again. That extra poll
finds nothing to do and does not reduce the interrupt rate.

Complete the NAPI and unmask the ring interrupt right after the reclaim.

On a CM4 this raises 60 byte pktgen Tx from about 187k to 224k pps and
saves about 5% of one core at TCP line rate.

Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260928121454.901306-1-nb@tipi-net.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 17:23:22 -07:00
Peng Fan
679950fede net: dsa: use regmap_assign_bits() for conditional set/clear
Replace if/else blocks using regmap_set_bits()/regmap_clear_bits() with
the simpler regmap_assign_bits() calls in the lantiq gswip, mt7530 and
qca8k drivers.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20260924083538.461887-1-peng.fan@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 16:55:55 -07:00
Jiayuan Chen
883c308be4 selftests/net: check auto-selected port with reuse options
Use IP_LOCAL_PORT_RANGE to limit a socket to 8 ports, bind 8 sockets
to port 0 and check they get 8 distinct ports and the 9th bind fails
with EADDRINUSE. Run it for the four combinations of reuse options on
the sockets:

  none                         (existing test)
  SO_REUSEPORT
  SO_REUSEADDR
  SO_REUSEADDR + SO_REUSEPORT

TCP passes all four. Before the udp fix UDP only passes the first
one: the scan hands out a port already taken by a socket with the
same reuse options, so fewer than 8 distinct ports come back and the
9th bind succeeds.

  # ./ip_local_port_range.sh

Before:

  ok 13 ip_local_port_range.ip4_udp.exhaust_8_port_range
  not ok 14 ip_local_port_range.ip4_udp.exhaust_8_port_range_reuseport
  not ok 15 ip_local_port_range.ip4_udp.exhaust_8_port_range_reuseaddr
  not ok 16 ip_local_port_range.ip4_udp.exhaust_8_port_range_reuseaddr_reuseport
  ok 49 ip_local_port_range.ip6_udp.exhaust_8_port_range
  not ok 50 ip_local_port_range.ip6_udp.exhaust_8_port_range_reuseport
  not ok 51 ip_local_port_range.ip6_udp.exhaust_8_port_range_reuseaddr
  not ok 52 ip_local_port_range.ip6_udp.exhaust_8_port_range_reuseaddr_reuseport

After:

  ok 13 ip_local_port_range.ip4_udp.exhaust_8_port_range
  ok 14 ip_local_port_range.ip4_udp.exhaust_8_port_range_reuseport
  ok 15 ip_local_port_range.ip4_udp.exhaust_8_port_range_reuseaddr
  ok 16 ip_local_port_range.ip4_udp.exhaust_8_port_range_reuseaddr_reuseport
  ok 49 ip_local_port_range.ip6_udp.exhaust_8_port_range
  ok 50 ip_local_port_range.ip6_udp.exhaust_8_port_range_reuseport
  ok 51 ip_local_port_range.ip6_udp.exhaust_8_port_range_reuseaddr
  ok 52 ip_local_port_range.ip6_udp.exhaust_8_port_range_reuseaddr_reuseport

Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260928023145.301855-2-jiayuan.chen@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 16:47:31 -07:00
Jiayuan Chen
20d020a075 udp: fix auto-selected port colliding with an existing SO_REUSEPORT socket
Observed with two independent servers in the same process:

  fd1 = socket(AF_INET, SOCK_DGRAM, 0);
  setsockopt(fd1, SOL_SOCKET, SO_REUSEPORT, ...);
  bind(fd1, port 0);          /* got 40000 */

  fd2 = socket(AF_INET, SOCK_DGRAM, 0);
  setsockopt(fd2, SOL_SOCKET, SO_REUSEPORT, ...);
  bind(fd2, port 0);          /* got 40000 as well */

Both sockets end up on the same port and join the same reuseport
group, so each of them takes part of the other's datagrams. The same
port sharing happens with SO_REUSEADDR, without the reuseport group.

udp_lib_lport_inuse() keeps the reuse rules when it scans for a free
port: a socket with SO_REUSEADDR set, or one with SO_REUSEPORT and
the same uid, is not a conflict, so its port is never marked in the
bitmap and the scan can hand it out again. Those rules only make
sense when the user asks for a specific port. bind(0) wants a free
port and has no way to know whose port it lands on.

TCP already does this: inet_csk_find_open_port() passes relax=false
and reuseport_ok=false, so the scan treats every port in use as a
conflict whatever options the sockets have. Commit aacd9289af
("tcp: bind() use stronger condition for bind_conflict") did it for
SO_REUSEADDR and commit 0643ee4fd1 ("inet: Fix get port to handle
zero port number with soreuseport set") for SO_REUSEPORT.

Do the same for UDP: ignore both options during a scan, keep them
for an explicit port.

This changes bind(0) for SO_REUSEADDR sockets once the port range is
full: it used to share a port and now fails with EADDRINUSE, like
TCP. Sharing a port on purpose when the range is full is a feature,
TCP has net.ipv4.ip_autobind_reuse for it, off by default. UDP can
get the same knob later, this patch only fixes the scan.

Fixes: ba418fa357 ("soreuseport: UDP/IPv4 implementation")
Cc: stable+noautosel@kernel.org # bind() behaviour change
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260928023145.301855-1-jiayuan.chen@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 16:47:31 -07:00
Matvey Valigura
f10883b37d usb: atm: use request_firmware_direct() for firmware probing
When disconnecting a device while firmware is not present on the system,
usbatm_usb_disconnect() waits for the heavy_init thread to finish:
    wait_for_completion(&instance->thread_exited);

If CONFIG_FW_LOADER_USER_HELPER_FALLBACK is enabled, missing firmware
causes request_firmware() to fall back to sysfs/udevd. This creates a
circular dependency during disconnect:
1. usb_disconnect() holds device_lock(&udev->dev).
2. usbatm_usb_disconnect() waits for instance->thread to exit.
3. instance->thread waits for request_firmware() sysfs fallback.
4. udevd receives the firmware uevent and attempts to read sysfs
   attributes (e.g. serial), blocking on device_lock(&udev->dev).

Furthermore, the fallback wait uses wait_for_completion_killable_timeout(),
which ignores the non-fatal SIGTERM signal sent by usbatm_usb_disconnect().
Because speedtch and cxacru probe multiple candidate firmware files
sequentially, each file stalls for the 60-second fallback timeout,
triggering hung task timeouts (>120s) reported by syzbot.

Switch to request_firmware_direct() to probe firmware files directly from
the filesystem without falling back to user-mode helper.

Cc: stable+noautosel@kernel.org # untested fix to a driver init path race
Reported-by: syzbot+9ca2c9f85bd8b5e46516@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9ca2c9f85bd8b5e46516
Signed-off-by: Matvey Valigura <valigurasm@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260924050654.15347-1-valigurasm@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 16:43:43 -07:00
Jakub Kicinski
fb476e8de0 Merge branch 'ionic-shared' of https://github.com/abhijitG-xlnx/linux
Pull shared branch with RDMA:
 - net: ionic: Fetch qid allocation and SRQ capability from firmware

Link: https://lore.kernel.org/20260925082802.2675902-1-abhijit.gangurde@amd.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29 16:21:37 -07:00
Paolo Abeni
6e23f90f2b Merge branch 'net-consolidate-devmem-net_iov-freelist-and-dma-handling'
Stanislav Fomichev says:

====================
net: consolidate devmem net_iov freelist and DMA handling

Follow up on the recently merged devmem gen_pool removal by consolidating
devmem's net_iov freelist and DMA-address handling.

- move devmem freelist to index-based approach with push/pop helpers
- switch devmem to public memory-provider helpers and reject DMA
  addresses that cannot be represented
- decode stored DMA addresses for TX on 32-bit systems with 64-bit
  dma_addr_t
====================

Link: https://patch.msgid.link/20260925201522.254717-1-sdf@fomichev.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:41:35 +02:00
Stanislav Fomichev
5c729e6c71 net: devmem: decode DMA addresses for TX
On 32-bit architectures where dma_addr_t is wider than unsigned long,
page_pool_set_dma_addr_netmem() stores page-aligned DMA addresses shifted
by PAGE_SHIFT. The net_iov branch of __skb_frag_dma_map() adds byte offsets
to the encoded value, so the NIC is programmed with an invalid DMA address.
This can trigger an IOMMU fault or DMA from unintended memory.

Consolidate DMA address encoding, decoding, and representability checks in
netmem helpers. Use the common decoder from the page pool and net_iov TX
paths so both interpret stored addresses consistently.

Reviewed-by: Mina Almasry <almasrymina@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260925201522.254717-4-sdf@fomichev.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:41:31 +02:00
Stanislav Fomichev
5bdeb89ec5 net: devmem: use memory provider helpers for net_iovs
Use public memory-provider helpers for DMA address storage and page-pool
association instead of open-coding page_pool state and accounting.

Zero the net_iov array because net_mp_niov_set_page_pool() ORs
PP_SIGNATURE into pp_magic. Reject DMA addresses that cannot be
represented in net_iov metadata.

Reviewed-by: Mina Almasry <almasrymina@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260925201522.254717-3-sdf@fomichev.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:41:26 +02:00
Stanislav Fomichev
1cf2f913b3 net: netmem: move to index based freelist
Move devmem's freelist to an index-based approach similar to io_uring.
This halves the memory requirements for the freelist.

Reviewed-by: Mina Almasry <almasrymina@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260925201522.254717-2-sdf@fomichev.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:41:26 +02:00
Rob Herring (Arm)
63f028c4dd dt-bindings: net: Document Marvell PHY "marvell,reg-init"
The Marvell PHY driver consumes marvell,reg-init as one or more
<page register mask value> tuples. Define the property so dtbs_check
validates the existing board descriptions.

Existing users have no compatible or just "ethernet-phy-ieee802.3-c22"
so this has to go into the generic ethernet-phy.yaml schema. Marking it
deprecated both for that reason and because opaque register
initialization values are discouraged in DT.

Assisted-by: LLM
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20260925140410.1157036-2-robh@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:35:27 +02:00
Willem de Bruijn
ee1972def6 net: downgrade BUG_ON EIOCBQUEUED in sock_sendmsg_nosec
sock_sendmsg_nosec() runs in syscall context but calls BUG_ON() if
proto_ops->sendmsg() returns -EIOCBQUEUED. Crashing the kernel on an
unexpected return value is dangerous for production workloads.

This risk is real: any signed integer overflow in a sendmsg handler
that returns 0xfffffdef (-529, -EIOCBQUEUED) triggers this BUG_ON. In
one month, two such bugs were reported in PF_PACKET, reachable by
a local user with CAP_NET_RAW in a user namespace:
- Commit 73e594c19b ("af_packet: Don't cast tpacket_hdr.tp_len to int
  in tpacket_parse_header().")
- In review ("net/packet: prevent TX_RING byte count overflow")
  https://lore.kernel.org/netdev/20260925124829.6595-1-ilkka.lappetelainen@gmail.com/

Replace the BUG_ON with DEBUG_NET_WARN_ON_ONCE() to retain debug and
syzbot coverage, and return -EIO so that -EIOCBQUEUED does not leak to
userspace or trigger the BUG_ON(ret == -EIOCBQUEUED) in VFS callers of
sock_write_iter() such as new_sync_write().

Failing gracefully is safe because the original reason for the BUG_ON
is gone. It was added in commit 599bd19bdc ("fs: don't allow to complete
sync iocbs through aio_complete") and commit d8725c86ae ("get rid of the
size argument of sock_sendmsg()") to prevent an async completion from
corrupting a caller's on-stack kiocb. Commit 1b78414047 ("net: Remove
iocb argument from sendmsg and recvmsg") removed that on-stack kiocb.
More recently commit fcc77d33a3 ("net: Remove support for AIO on
sockets") removed socket AIO support entirely.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260928020420.3097018-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:31:24 +02:00
Chengfeng Ye
2a5043c8b7 net: pktgen: return bool from __pktgen_NN_threads()
Callers of __pktgen_NN_threads() only check whether a pktgen_dev was
found. Returning the pointer exposes it outside the helper even though
neither caller uses the object itself.

Return bool instead and keep the pktgen_dev pointer internal to the
helper.

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
Reviewed-by: Ivy Lopez <skunkolee@gmail.com>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260927135406.3969970-1-nicoyip.dev@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 15:24:40 +02:00
Paolo Abeni
62d7b9186c Merge branch 'netlink-specs-enum-alignment-fixes'
Asbjørn Sloth Tønnesen says:

====================
netlink: specs: enum alignment fixes

This series fixes misalignment issues in YNL-defined enums or flags.

v1: https://lore.kernel.org/20260911214148.1184806-1-ast@fiberby.net

While this is not a direct continuation, the rt-link changes was
previously posted as part of another RFC:
https://lore.kernel.org/20260910221733.1021864-1-ast@fiberby.net
====================

Link: https://patch.msgid.link/20260925213918.204767-1-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:50 +02:00
Asbjørn Sloth Tønnesen
8450becb88 netlink: specs: fix incorrect name-prefixes
Fix two invalid name-prefixes in the specs:

- It's PHY_UPSTREAM_MAC, not PHY_UPSTREAMMAC.
- It's PHY_UPSTREAM_PHY, not PHY_UPSTREAMPHY.
- It's OVPN_MODE_P2P, not OVPN_MODEP2P.
- It's OVPN_MODE_MP, not OVPN_MODEMP.

CC: Andrew Lunn <andrew@lunn.ch>
CC: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-10-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:47 +02:00
Asbjørn Sloth Tønnesen
5fd016f357 netlink: specs: tc: fix typo in cls-flags
Fix a typo in the naming of a cls-flags constant.

The correct name for TCA_CLS_FLAGS_NOT_IN_HW is "not-in-hw",
not "not-in-nw".

CC: Jamal Hadi Salim <jhs@mojatatu.com>
CC: "Jonas Köppeler" <j.koeppeler@tu-berlin.de>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-9-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:47 +02:00
Asbjørn Sloth Tønnesen
479ecf856c netlink: specs: nl80211: fix naming of enum members
Use the correct naming for enum members:

- In feature-flags, it's NL80211_FEATURE_ND_RANDOM_MAC_ADDR,
  so "nd-random-mac-addr", not "no-random-mac-addr".

- In commands, it's NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
  so "unexpected-4addr-frame", not "unexpected-4-addr-frame".

CC: Joe Damato <joe@dama.to>
CC: Shaikh Kamaluddin <shaikhkamal2012@gmail.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-8-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:47 +02:00
Asbjørn Sloth Tønnesen
a9a9845734 netlink: specs: ethtool: re-align module-fw-flash-status
Correct the values for enum ethtool_module_fw_flash_status:

- ETHTOOL_MODULE_FW_FLASH_STATUS_STARTED is 1, not 0.
- ETHTOOL_MODULE_FW_FLASH_STATUS_IN_PROGRESS is 2, not 1.
- ETHTOOL_MODULE_FW_FLASH_STATUS_COMPLETED is 3, not 2.
- ETHTOOL_MODULE_FW_FLASH_STATUS_ERROR is 4, not 3.

Re-align the YNL spec by explicitly setting the first value to 1.

CC: Andrew Lunn <andrew@lunn.ch>
CC: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-7-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:47 +02:00
Asbjørn Sloth Tønnesen
fe6a71dc0f netlink: specs: ethtool: re-align c33-pse-ext-state
enum ethtool_c33_pse_ext_state is misaligned with YNL:

- ETHTOOL_C33_PSE_EXT_STATE_OVLD_DETECTED is 6.
- ETHTOOL_C33_PSE_EXT_STATE_PD_DLL_POWER_TYPE is 7 (not in YNL).
- ETHTOOL_C33_PSE_EXT_STATE_POWER_NOT_AVAILABLE is 8, not 7.
- ETHTOOL_C33_PSE_EXT_STATE_SHORT_DETECTED is 9, not 8.

In commit c8149739af ("netlink: specs: Expand the PSE netlink command
with C33 new features") the PD_DLL_POWER_TYPE enum member was skipped,
leading incorrect values for power-not-available and short-detected.

As PD_DLL_POWER_TYPE is not used, then skip it, but set the value for
power-not-available to 8.

CC: Andrew Lunn <andrew@lunn.ch>
CC: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-6-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:46 +02:00
Asbjørn Sloth Tønnesen
bef8442f5f netlink: specs: devlink: fix resource-scope type
The correct type for resource-scope is flags, not enum:

- DEVLINK_RESOURCE_SCOPE_DEV is _BITUL(0) aka. 1, not 0.
- DEVLINK_RESOURCE_SCOPE_PORT is _BITUL(1) aka. 2, not 1.

This patch also removes "enum-as-flags", as it is now redundant,
these changes does not change the generated policy.

Before this patch, this generated devlink-user.c function call:
devlink_resource_scope_str(DEVLINK_RESOURCE_SCOPE_DEV) returned "port",
not "dev", as it didn't use ffs() to convert the value.

CC: Jiri Pirko <jiri@resnulli.us>
CC: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-5-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:46 +02:00
Asbjørn Sloth Tønnesen
306df818cc netlink: specs: rt-link: fix ifinfo-flags names
Correct the names of `enum net_device_flags` constants:

- IFF_POINTOPOINT should be "pointopoint", not "point-to-point".
- IFF_NOTRAILERS should be "notrailers", not "no-trailers".
- IFF_NOARP should be "noarp", not "no-arp".
- IFF_ALLMULTI should be "allmulti", not "all-multi".
- IFF_AUTOMEDIA should be "automedia", not "auto-media".

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-4-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:46 +02:00
Asbjørn Sloth Tønnesen
621524a737 netlink: specs: rt-link: re-align ifla-inet6-stats
YNL enum ifla-inet6-stats got misaligned with C, as two commits
reordered the enum.

In commit b4a11b2033 ("net: fix IPSTATS_MIB_OUTPKGS increment in
OutForwDatagrams."), IPSTATS_MIB_OUTPKTS was renamed to _OUTREQUESTS
and a new _OUTPKTS was as the last entry.

In commit 652e2c7778 ("net: reorganize IP MIB values (II)"), the
IPSTATS_MIB_* enum was reorganized for data locality.

Neither of these commits updated the YNL spec.

This changed uAPI, as IPSTATS_MIB_* is used as indicies in an u64 array,
exported as IFLA_INET6_STATS by inet6_fill_ifla6_stats_attrs().

This patch updates ifla-inet6-stats to reflect both of these commits.
Next time we want to reorganize these counters we should properly apply
mapping as to maintain the current order on the netlink side.

While touching these entries, also remove the dash from ect{0,1}-pkts,
so that they align with the C naming.

This pre-existing issue was identified by Sashiko during review of
commit 2b0aecb7b2 ("netlink: specs: rt-link: add accept-ra-min-lft").

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260831093458.472180-1-ast%40fiberby.net
CC: Heng Guo <heng.guo@windriver.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-3-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:46 +02:00
Asbjørn Sloth Tønnesen
e769837e4e netlink: specs: rt-link: re-align IPv4 devconf
The YNL "ipv4-devconf" enum is misaligned with the IPV4_DEVCONF_* enum.

IPV4_DEVCONF_* starts at 1, ipv4-devconf starts at 0.

$ git grep -B3 -A1 IPV4_DEVCONF_FORWARDING include/
inc../uapi/linux/ip.h-/* index values for the variables in ipv4_devconf */
inc../uapi/linux/ip.h-enum
inc../uapi/linux/ip.h-{
inc../uapi/linux/ip.h:        IPV4_DEVCONF_FORWARDING=1,
inc../uapi/linux/ip.h-        IPV4_DEVCONF_MC_FORWARDING,

Re-align the YNL spec by explicitly setting the first value to 1.

This misalignment has been present since the spec was added in
commit b2f63d904e ("doc/netlink: Add spec for rt link messages").

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/20260925213918.204767-2-ast@fiberby.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:26:46 +02:00
Jakub Kicinski
e542bad8d5 selftests: net: add test for netdev instance lock ordering on unregister
Dismantle two netns holding a dummy and a netkit pair registered in
opposite order. unregister_netdevice_many_notify() takes the instance
locks of all the devices at once, nesting the two kinds of devices one
way for the first netns and the other way for the second. With lockdep
enabled this used to trigger a circular locking report.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260926041832.1649675-2-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:14:20 +02:00
Jakub Kicinski
b6f74dff6d net: use two lockdep classes for the netdev instance lock
netdev_lockdep_set_classes() puts dev->lock in a separate lockdep class,
by type (netkit vs dummy etc), with the intent of keeping the instance
locks of individual devices as independent from each other as possible.
In practice it does the opposite. lockdep only calls the cmp_fn for locks
of the same class, so netdev_lock_cmp_fn() never gets a say when devices
from different classes are nested. Instead lockdep records a dependency
between the classes, and reports a circular locking problem as soon as
the nesting happens the other way round, e.g. when devices are unregistered
in a batch.

  ======================================================
  WARNING: possible circular locking dependency detected
  7.3.0-rc3+ #26 Not tainted
  ------------------------------------------------------
  kworker/u256:1/326 is trying to acquire lock:
  ff110000104fce28 (&dev_instance_lock_key#6){+.+.}-{4:4}, at:
  unregister_netdevice_many_notify+0x1141/0x1c30

  but task is already holding lock:
  ff110000127f2e28 (&dev_instance_lock_key#7){+.+.}-{4:4}, at:
  unregister_netdevice_many_notify+0x1141/0x1c30

  -> #1 (&dev_instance_lock_key#7){+.+.}-{4:4}:
         __lock_acquire+0x767/0xd60
         lock_acquire.part.0+0xd0/0x260
         __mutex_lock+0x17d/0x1f20
         unregister_netdevice_many_notify+0x1141/0x1c30
         default_device_exit_batch+0x3ee/0x520
         ops_undo_list+0x2cc/0x8a0
         cleanup_net+0x442/0x9c0
         process_one_work+0x951/0x1ab0
         worker_thread+0x5a6/0xd10
         kthread+0x339/0x430
         ret_from_fork+0x4a4/0x6f0
         ret_from_fork_asm+0x1a/0x30

  -> #0 (&dev_instance_lock_key#6){+.+.}-{4:4}:
         check_prev_add+0xeb/0xe60
         validate_chain+0x598/0x900
         __lock_acquire+0x767/0xd60
         lock_acquire.part.0+0xd0/0x260
         __mutex_lock+0x17d/0x1f20
         unregister_netdevice_many_notify+0x1141/0x1c30
         default_device_exit_batch+0x3ee/0x520
         ops_undo_list+0x2cc/0x8a0
         cleanup_net+0x442/0x9c0
         process_one_work+0x951/0x1ab0
         worker_thread+0x5a6/0xd10
         kthread+0x339/0x430
         ret_from_fork+0x4a4/0x6f0
         ret_from_fork_asm+0x1a/0x30

   Possible unsafe locking scenario:

         CPU0                    CPU1
         ----                    ----
    lock(&dev_instance_lock_key#7);
                                 lock(&dev_instance_lock_key#6);
                                 lock(&dev_instance_lock_key#7);
    lock(&dev_instance_lock_key#6);

   *** DEADLOCK ***

  locks held by kworker/u256:1/326: 6, last CPU#6:
   #0: ff11000001c2b540 ((wq_completion)netns){+.+.}-{0:0}, at:
  process_one_work+0x117c/0x1ab0
   #1: ffa0000001a3fd18 (net_cleanup_work){+.+.}-{0:0}, at:
  process_one_work+0x8ce/0x1ab0
   #2: ffffffff98f53288 (pernet_ops_rwsem){++++}-{4:4}, at:
  cleanup_net+0xc1/0x9c0
   #3: ffffffff98f6ede0 (rtnl_mutex){+.+.}-{4:4}, at:
  default_device_exit_batch+0x92/0x520
   #4: ff1100001321ae28 (&dev_instance_lock_key#7){+.+.}-{4:4}, at:
  unregister_netdevice_many_notify+0x1141/0x1c30

We can't put all devices in the same class, that'd be too permissive.
netdev_nl_queue_create_doit() and netdev_nl_bind_tx_doit() lock
a virtual device (netkit) before a physical device, without rtnl_lock.
We can never allow locking in the opposite order even under rtnl_lock.
cmp_fn cannot enforce this sort of rule: lockdep keys its chain cache on
the sequence of lock classes, so with a single class both orders hash
to the same chain and only whichever happens first is validated.

netdev_lock_cmp_fn() itself has another source of false-negatives.
lockdep calls it from within __lock_acquire(), with the recursion counter
already raised, so lock_is_held_type() always returns LOCK_STATE_UNKNOWN,
which means lockdep_rtnl_is_held() always returns true / held.
Use rtnl_is_locked(), which looks at the mutex directly and does
work from that context. We may still miss a bad case if some other
process is holding the lock, not us, but that's better than the
100% false negative rate of lockdep_rtnl_is_held().

One last thing, lockdep compares the address of the cmp function,
so it can't be a static inline - that would work similarly to having
separate classes, again. Move it to a source file.

Tested by nesting two instance locks from a module, one scenario per boot
since the first splat turns debug_locks off:

  first       second      rtnl      reported
  -----------------------------------------------------------
  virt->virt              no        recursive locking
  virt->virt              yes       -
  virt->phys              no        -
  virt->phys              yes       -
  phys->virt              no        - (records the edge)
  phys->virt              yes       - (records the edge)
  phys->phys              no        recursive locking
  phys->phys              yes       -
  virt->phys  phys->virt  no, no    circular dependency
  virt->phys  phys->virt  no, yes   circular dependency
  virt->phys  phys->virt  yes, no   circular dependency
  virt->phys  phys->virt  yes, yes  circular dependency
  phys->virt  virt->phys  no, no    circular dependency
  phys->virt  virt->phys  yes, yes  circular dependency
  virt->virt  virt->virt  yes, no   recursive locking
  phys->phys  phys->phys  yes, no   recursive locking

(netkit and dummy stood in for the virtual devices, virtio_net and
netdevsim for the physical ones.)

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260926041832.1649675-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 13:14:20 +02:00
Paolo Abeni
09c188c249 Merge branch 'eth-mpnic-initial-support-for-meta-platforms-nic'
Daniel Zahka says:

====================
eth: mpnic: initial support for Meta Platforms NIC

Meta Platforms NIC is the second-generation NIC from Meta. There are
quite a few high-level similarities to fbnic, but all of the CSRs and
descriptors have been reshuffled, and new features have been added.
Since the device is sufficiently different from fbnic, and the design of
our FW is minimal, we have decided a separate driver is appropriate.

Major new features compared to fbnic will take a while to land. This
series includes only the bare-bones Tx/Rx datapath.

Our high-level patch sequence and plan for the upcoming series is:
 1. Core datapath (this series)
 2. Basic offloads, RSS, and counters
 3. Firmware mailbox support
 4. Base ethtool operations

This patch series was prepared in part with these LLM prompts:
https://github.com/kuba-moo/ai-prompts/blob/main/driver-upstreaming-prompts.md

The prompts were used to distill our fully-featured OOT driver into this
minimal Tx/Rx capable upstream driver. We then performed human review on
the output to create this posting. Jakub has made the prompts public in
case people would like to take a look.

v1: https://lore.kernel.org/r/20260922-linux-mpnic-v1-0-236844f53072@gmail.com

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
====================

Link: https://patch.msgid.link/20260924-linux-mpnic-v2-0-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:36:40 +02:00
Daniel Zahka
a9a9bb5416 eth: mpnic: add basic Rx handling
A frame arrives as a run of completion descriptors: one header
address/length descriptor, one address/length descriptor per payload
page, and a metadata descriptor that closes the frame. The frame is
assembled in an xdp_buff as the descriptors come in and handed to the
stack when the metadata descriptor arrives.

A page holds several frames, so rather than taking a reference per
frame the driver takes a batch of references when it starts handing the
page out and returns whatever is left over once the device moves on to
the next one. Payload fragments that turn out to be contiguous within
one page are merged so that a frame spread over a page does not eat one
skb fragment slot per descriptor.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-8-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:59 +02:00
Daniel Zahka
4b26e9cdad eth: mpnic: implement Rx queue allocation and cleanup
The Rx side of a queue triad is a header queue, a payload queue and a
completion queue. With HDS not active yet, frames are split between the
two buffer queues at a fixed header boundary: everything up to 1536
bytes lands in the header page, the rest goes to the payload page. Small
frames therefore never touch the payload queue, and several of them
share one header page.

The device is set to leave headroom and tailroom for XDP and
skb_shared_info respectively.

Both queues draw from one page pool per triad and post buffer
descriptors to the device in batches.

Even though we do not support XDP yet, use the XDP APIs for tracking
pre-skb buffers. The XDP buffer handling helpers save us from
reimplementing the same logic in the driver.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-7-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Daniel Zahka
1b8d005bd3 eth: mpnic: add a netdevice and basic Tx handling
Register the network interface and let it transmit skbs.

The typical TWQ descriptor sequence for an skb is: 1 primary metadata,
followed by 0 or more non-last address + length (A/L) descriptors,
terminated by an always present last A/L descriptor.

The device does not write a Tx completion unless it is requested in the
primary metadata desc. The xmit path sets this bit when the stack does
not report netdev_xmit_more(). This can create a problem if the last
packet in a burst is dropped by the driver. To deal with that case, the
driver latches the last metadata for which a completion was not
requested, and uses this to request a completion and flush queued
packets when one is dropped.

There is no link state yet, so carrier follows the administrative
state.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-6-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Daniel Zahka
bd7ce2b2af eth: mpnic: start and stop the Tx HW queues
Point the hardware at the descriptor rings and provide functions for
turning the Tx queues on and off.

Teardown has to wait for the DMA engines to go idle before the ring
memory can be freed: disabling a queue only stops the device picking up
new work, it does not tell us that the work already fetched has been
retired. Each block exposes an idle bitmap per queue, and every one of
the four blocks a packet passes through on its way out has to report
idle before the descriptors are safe to free.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-5-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Daniel Zahka
3d4e4ad43a eth: mpnic: implement Tx queue allocation and cleanup
Queues come in triads of two work queues and one completion queue. The
Tx triad only uses the first work queue for now, the second one will be
used for the XDP ring later.

Add the ring structures, the per NAPI vector allocation of triads,
descriptor memory and interrupts, and the completion processing. The
completion queue does not report one entry per packet, it reports a
work queue head, so a single completion can release many packets.

Nothing enables the queues in hardware or submits anything to them yet,
that comes with the next two changes.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-4-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Daniel Zahka
2cf67a2692 eth: mpnic: allocate MSI-X vectors
Request one vector for FW generated interrupts and then one vector per
CPU to use for the completion queues. Nothing requests a handler yet,
that comes with the NAPI vectors.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-3-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Mohsin Bashir
cda700bcb2 eth: mpnic: add register init for the device
Perform one time register initialization during mpnic_probe(). These CSR
settings are either static configs that only need to be set once, or
pulses for zeroizing on chip SRAMs, which also only need to be done
once.

This initialization is idempotent and does not require any matching
deinitialization in the remove path. We can unbind and re-bind the
driver and perform the same initialization without problems.

Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com>
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-2-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Daniel Zahka
3251a68930 eth: mpnic: add scaffolding for Meta Platforms NIC
MPNIC is the next network interface controller designed by Meta. Create
a bare PCI driver for it. Subsequent changes will flesh it out.

Registers live in BAR0 and are addressed as an array of 32 bit words,
which is why the CSR indices are a quarter of the byte offset. Most of
the register file is only accessible as 64 bit, so that is the only
accessor added here.

If a read returns all ones, a second read to an unused register with
reset value 0 is performed to determine if the device is gone. If the
device is gone, the mapped BAR0 pointer is cleared, so no further
accesses reach the bus.

For now, if mpnic_mmio_err() clears mpd->uc_addr0, nothing will
reassign it. The user will have to unbind and rebind the driver. Future
series will reset uc_addr0 from pci error handlers.

In addition to being used as a 0 value reference CSR, MPNIC_BDQ_SPARE is
also used to perform write flushes, because it can be read without
producing side effects.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260924-linux-mpnic-v2-1-4badc9b58b9e@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 10:35:58 +02:00
Kuniyuki Iwashima
c66d93e687 ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED.
The FIB6_EXCEPTION_BUCKET_FLUSHED logic has been dead since added.

Commit 0346ec2f08 ("ipv6: Prevent rt6_insert_exception() for
dying fib6_info.") restored the original race protection in
rt6_insert_exception() by reusing fib6_info.fib6_destroying.

The flag now prevents two races for per-cpu and exception routes.

Let's remove FIB6_EXCEPTION_BUCKET_FLUSHED and set fib6_destroying
in fib6_purge_rt().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260926033355.3295550-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 19:34:26 -07:00
Nicolai Buchwitz
67da300938 net: ethtool: reject an out of range hwtstamp provider index
A provider index of 0xFFFFFFFF picks a provider on hardware that has
none. phc_index is an int where -1 means no PHC, and the u32 from user
space ends up as -1, so the two match.

TSINFO_GET uses -1 for "no provider requested" and answers with the
default provider instead of an error.

Reject the value in the netlink policy, which covers every comparison
site.

Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://patch.msgid.link/20260925135237.3432266-2-nb@tipi-net.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 19:28:44 -07:00
Jakub Kicinski
0a1a3898ab netfilter pull request 26-09-28
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEjF9xRqF1emXiQiqU1w0aZmrPKyEFAmq5lC0ACgkQ1w0aZmrP
 KyH/+A//XlfAsuJFsBE0sGf4zSuPw96RvjG9hjlbCahoMHSwwON46bl3frT+W9Zr
 YNEIJMdEqqGEQ+bGQcafLlX3ayknzhN7cTe+VoBOR12/6WeewSG/1l3JusWgb91b
 snDGU/tWaXn0ZmumpziiDWlgNapRkLlxCr7ZzqBNJowNZU/RNd/dtqiMdBz8osX7
 eOtL947O2EIjNZ0+Y5AI6uHwQimEIdzPYIi50WpyxcLYLC/AEEJFhDTafwq5NTP/
 tCzYODr2ybWXeC90yxFsLNQai+1Tyo7tq0BP1dcMg80i/kgOnVtAQqRt0E6BYaEP
 Rwbfhh+onCbdRV0DpsuyL6uy3pnJ21uj48hWuquHgGnuP6yrc2EMTreLmt0szorH
 nngUoqBNKheTqC8L+VSfjV6/+tDhwLTaH4knlasbZizWC//GjlBfK7c7499ApHrS
 Icm9pVwKYtFFRARe8wT2H3AKO3u3DaVNXBDypviCnEuvAXRuIi4nwu/aMVVeD9cs
 04uTCFqMvUv+rX3oJN13hhC88fyH4R25sMt/XIZQxel/ZwjZrcZYz8FoFi5ePdfF
 X/tBDloygOt2tB3YRnHdPxm/SYOZTQoUlD9SmtwvSYnGD0V3TFmCFILAeNPc4SrZ
 rR/H5yDV47JxXGst9xd5AJlMNhr6ZrbCqbqC6GhWPnXFXC01lvg=
 =RZ9z
 -----END PGP SIGNATURE-----

Merge tag 'nf-next-26-09-28' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next

Pablo Neira Ayuso says:

====================
Netfilter updates for net-next

The following patchset contains Netfilter updates for net-next. The
fixes included in this batch are deemed to handle correctness issues
present in the Netfilter tree:

1) TCP sequence tracking is not reset inconditionally by synproxy when
   recycling an entry, sashiko reports the zero offset case skips it.
   Add a new function to inconditionally reset TCP sequence tracking.
   From Fernando F. Mancera.

2) Update documentation to reflect that the default maximum number of
   expectations (nf_conntrack_expect_max) is nf_conntrack_buckets / 64.
   From Shaojie Sun.

3) Remove useless break; after return in nft_osf, from Linkui Xiao.

4) Fix typos in comments in the netfilter tree, from Hemanth Selam.

5) Remove a few conntrack error stats duplicated updates,
   from Phil Sutter.

6) Do not bump invalid and drop conntrack error stats when packet is
   dropped, this is another duplicate. also From Phil.

7) Set on netns pointer before registering the flowtable, this is
   a requirement by the next patch, not fixing an existing issue.
   From Qingfang Deng.

8) Remove unnecessary workqueue work flush for all of the existing
   netns when device is gone. Also from Qingfang Deng.

9) Rework-fix nfnetlink_hook to correctly deal with large netlink
   dumps. Use sequence numbers to detect interference with hook
   updates while netlink dump is ongoing. From Phil Sutter.

10) Fix ctnetlink dump filtering by the IPv6 address, this has
    only work correctly for IPv4 this far, from Piotr Kubik.

11) ctnetlink filtering by zone is supported, but the ctnetlink
    dump filtering infrastructure was never updated to include a
    flag from userspace, update it to fill this gap.
    From Ilya Maximets.

* tag 'nf-next-26-09-28' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next:
  netfilter: conntrack: make filtering by zone discoverable
  netfilter: ctnetlink: fix inverted IPv6 address match in dump filter
  netfilter: nfnetlink: Fix for interrupted hook dumps
  netfilter: flowtable: check namespace before iterating flows
  net/sched: act_ct: set net pointer before publishing flowtable
  netfilter: conntrack: Untangle drop and invalid counters
  netfilter: conntrack: Untangle insert_failed counter from others
  netfilter: fix several typos in comments
  netfilter: osf: remove unreachable break in nf_osf_ttl()
  netfilter: conntrack: fix nf_conntrack_expect_max default value in documentation
  netfilter: synproxy: fix reset of ct seqadj when reopening a connection
====================

Link: https://patch.msgid.link/20260927223436.269024-1-pablo@netfilter.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 19:14:55 -07:00
Jakub Kicinski
c20d84c6de tools: ynl-gen-c: keep the type values of a nest in spec order
Family._load_nested_set_nest() collects the type-value names of a
nest-type-value attribute into a set and Struct.set_inherited() renders
them sorted, while TypeNestTypeValue._attr_get() passes them to the
parse helper in the order the spec lists them.  For nlctrl's

  type-value: [policy-id, attr-id]

that makes the generated helper take (attr_id, policy_id) and the caller
pass (policy_id, attr_id).  Both are __u32 so nothing complains, and
every C YNL user of the nlctrl policy dump gets the two swapped.

Two attributes nesting the same attribute set with the type values in
a different order now fail set_inherited() instead of comparing equal.
No spec does that today, but better safe than sorry.

Nesting an attribute set which is also used as a sub-message gets its own
check: it used to be caught by the list-versus-set type mismatch, which
the ordering fix removes, and without it the generator emits a call
to the sub-message parser with the selector argument missing.
Again, no spec does this today.

nlctrl is the only spec affected, discovered by an LLM scan of the spec.

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20260924223245.530132-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 18:12:06 -07:00
Jakub Kicinski
bd8e2c16f1 Merge branch 'vsock-receive-queue-hint-for-io_uring'
David Carlier says:

====================
vsock: receive queue hint for io_uring

AF_VSOCK stream receives never fill msghdr.msg_inq. io_uring initialises the
hint to -1 and treats that as "unknown", so it cannot set
IORING_CQE_F_SOCK_NONEMPTY, and it speculatively retries a multishot receive
after every completion, including when the queue is already empty.

Patch 1 fills the hint at the common exit of __vsock_connectible_recvmsg(),
reusing vsock_stream_has_data(), the transport callback that SIOCINQ already
uses. Following tcp_inq_hint(), it reports a terminal hint of 1 once the
connection is finished, so the caller still performs the receive that
observes EOF. Patch 2 adds selftest coverage.

Numbers come from a ping-pong over vsock loopback using io_uring multishot
receive, 4 KiB messages, the queue drained between messages, with kernel
receives counted by a kprobe. The baseline is the same tree with patch 1
reverted:

  entries per delivered message   1.97 -> 1.00       (5000 messages)
  receiver CPU time, median       1.640s -> 1.587s   (-3.2%)
  receiver wall time, median      3.260s -> 3.183s   (-2.4%)

Timing is 25 runs of 50000 messages per kernel; CPU gives Mann-Whitney
p=0.006, wall time does not separate from noise (p=0.12), as expected for a
latency-bound workload.

The hint is gated to SOCK_STREAM; seqpacket is untouched. SO_INQ and SCM_INQ
are deliberately left out: they need their own per-socket state and
ancillary-message semantics, and a byte-count contract would have to account
for transports reporting less than the whole queue. That can follow.

Testing: built and run under virtme-ng on loopback, where the new cases pass
and vsock_test still passes 41 of 41 with a clean dmesg. Other transports
were reviewed but not tested. Hyper-V reports the current packet rather than
the whole queue and can return -EIO; an undercount only understates what is
readable, and a negative result reports -1, the same "unknown" value io_uring
presets.
====================

Link: https://patch.msgid.link/20260923184008.153541-1-devnexen@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:27:12 -07:00
David Carlier
c116f78f94 vsock/test: cover receive queue hints
Add io_uring receive tests checking IORING_CQE_F_SOCK_NONEMPTY across a
partial receive, draining while the peer stays connected, EOF, a
nonblocking receive on an empty queue, a zero-length request, and a
multishot receive with provided buffers.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20260923184008.153541-3-devnexen@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:27:09 -07:00
David Carlier
608e7f8496 vsock: report pending receive data to io_uring
AF_VSOCK stream receives never fill msghdr.msg_inq, so io_uring cannot set
IORING_CQE_F_SOCK_NONEMPTY and retries a multishot receive even after the
queue has been drained.

Fill the hint at the common receive exit using the transport callback that
SIOCINQ already uses, and report 1 once the connection is finished so the
caller performs the receive which observes EOF, as TCP does after a FIN.

A vsock loopback ping-pong with io_uring multishot receive drops entries
into __vsock_connectible_recvmsg from 1.97 to 1.00 per delivered message,
and receiver CPU time by about 3% (25 runs of 50000 messages, p=0.006).

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20260923184008.153541-2-devnexen@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:27:09 -07:00
Jakub Kicinski
df2d695617 Merge branch 'net-mlx5-preparations-for-nested-e-switch'
Tariq Toukan says:

====================
net/mlx5: Preparations for nested E-switch

This series by Shay has two intertwined goals. The first is to remove
the compile-time MLX5_MAX_PORTS sizing from the LAG and eswitch/TC
datapaths so that structures scale with the actual number of ports/peers
rather than a fixed maximum. The second is a set of small,
self-contained fixes that prepare the eswitch and LAG code for a VF/SF
acting as a nested e-switch manager - a mode new FW will allow, where a
VF/SF has its own eswitch and the VFs/SFs can be grouped by MPESW.

No functional change is intended for existing configurations.
====================

Link: https://patch.msgid.link/20260923103830.1183-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:17:51 -07:00
Shay Drory
a5bfbdfebd net/mlx5: E-switch, disable host functions for a non PF e-switch manager
mlx5_esw_host_functions_enabled() only treated host functions as
disabled for an ECPF manager.

To support a non PF acting as an e-switch manager, add a check for a non
PF e-switch manager that treats host functions as disabled. This will
avoid allocating a host-PF vport in mlx5_esw_vports_init().

With host functions disabled for non PF, its e-switch is the expected
manager + uplink only.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260923103830.1183-14-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:17:14 -07:00
Shay Drory
dd655b1e93 net/mlx5: E-switch, correct stale VF/PF wording in esw-allowed comments
mlx5_esw_hold() and mlx5_eswitch_unblock_ipsec() bail out on
!mlx5_esw_allowed(), and their comments explained that as "a VF has no
eswitch" / "core dev is not a PF". New FW will let a VF act as a nested
e-switch manager - such a VF has an eswitch and passes
mlx5_esw_allowed() - so that equivalence no longer holds. Reword the
comments to describe the actual condition, the device is not an e-switch
manager, with no functional change.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260923103830.1183-13-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:17:14 -07:00
Shay Drory
66b25da0cf net/mlx5: LAG, drop stale esw_shared_ingress_acl gate from shared FDB
The shared-FDB support check still requires the esw_shared_ingress_acl
capability. That capability backed the merged uplink ingress ACL, where
the slave uplink's ingress-ACL root was pointed at the master's
(esw_set_uplink_slave_ingress_root()). That handling was removed in
commit 82e86a6c71 ("net/mlx5: E-switch, remove special uplink ingress
ACL handling") once both uplinks were tagged with the same reserved
metadata (MLX5_ESW_METADATA_RSVD_UPLINK) - a single FDB rule then
matches traffic from either uplink, with no shared ingress ACL involved.

The capability check was left behind and has been dead since: the driver
programs no shared ingress ACL, yet the check still keeps otherwise
shared-FDB-capable devices out of shared FDB. Drop it.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260923103830.1183-12-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:17:14 -07:00
Shay Drory
c51ea6db00 net/mlx5: LAG, don't print port mapping to debugfs in MPESW mode
The mapping debugfs file dumps the LAG virtual-to-physical port mapping.
In MPESW mode the LAG does not own that mapping - port selection is
driven by user steering rules, not by the LAG - so the dumped values are
meaningless.

Treat MPESW as if LAG is inactive and don't print anything to the user.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260923103830.1183-11-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:17:14 -07:00
Shay Drory
d451adde02 net/mlx5: E-switch, derive manager vport from device capability
mlx5_eswitch_manager_vport() hardcoded the e-switch manager vport as
either the ECPF or the host PF. Read esw_manager_vport_number from the
e-switch capability when esw_manager_vport_number_valid is set, so the
manager vport can be a VF - a prerequisite for VFs acting as e-switch
managers. Keep the previous mapping as fallback when the capability does
not report a number.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260923103830.1183-10-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-28 17:17:14 -07:00