[PATCH 0/6] usb: gadget: Revert deferred network allocation in f_ncm

Kuen-Han Tsai posted 6 patches 1 month, 1 week ago
drivers/usb/gadget/function/f_ncm.c            | 111 ++++++++--------
drivers/usb/gadget/function/u_ether.c          |  45 -------
drivers/usb/gadget/function/u_ether.h          |  30 -----
drivers/usb/gadget/function/u_ether_configfs.h | 168 -------------------------
drivers/usb/gadget/function/u_ncm.h            |   5 +-
drivers/usb/gadget/legacy/ncm.c                |  13 +-
6 files changed, 64 insertions(+), 308 deletions(-)
[PATCH 0/6] usb: gadget: Revert deferred network allocation in f_ncm
Posted by Kuen-Han Tsai 1 month, 1 week ago
This series reverts the recent changes to the f_ncm gadget function that
deferred the allocation of the net_device to the bind() phase.

The deferred allocation causes a regression for userspace tools during
network setup (such as the postmarketOS DHCP daemon). By moving the
allocation out of alloc_inst, configfs returns the name pattern "usb%d"
instead of the actual interface name (e.g., "usb0") when userspace reads
the 'ifname' attribute.

Investigating a fix for this naming issue revealed a deeper
architectural flaw introduced by the series. Deferring the allocation to
bind() means that a single function instance will spawn multiple network
devices if it is symlinked to multiple USB configurations.

Because all configurations tied to the same function instance are
architecturally designed to share a single network device, and configfs
only exposes a single 'ifname' attribute per instance, this 1-to-many
bug cannot be safely patched.

To restore the correct 1:1 mapping and resolve the userspace
regressions, this series reverts the changes in reverse order, returning
the net_device allocation back to the instance level (alloc_inst).

Reported-by: David Heidelberg <david@ixit.cz>
Link: https://lore.kernel.org/linux-usb/70b558ea-a12e-4170-9b8e-c951131249af@ixit.cz/
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
Kuen-Han Tsai (6):
      Revert "usb: gadget: f_ncm: Fix atomic context locking issue"
      Revert "usb: legacy: ncm: Fix NPE in gncm_bind"
      Revert "usb: gadget: f_ncm: align net_device lifecycle with bind/unbind"
      Revert "usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device"
      Revert "usb: gadget: u_ether: use <linux/hex.h> header file"
      Revert "usb: gadget: u_ether: add gether_opts for config caching"

 drivers/usb/gadget/function/f_ncm.c            | 111 ++++++++--------
 drivers/usb/gadget/function/u_ether.c          |  45 -------
 drivers/usb/gadget/function/u_ether.h          |  30 -----
 drivers/usb/gadget/function/u_ether_configfs.h | 168 -------------------------
 drivers/usb/gadget/function/u_ncm.h            |   5 +-
 drivers/usb/gadget/legacy/ncm.c                |  13 +-
 6 files changed, 64 insertions(+), 308 deletions(-)
---
base-commit: 1be3b77de4eb89af8ae2fd6610546be778e25589
change-id: 20260304-f-ncm-revert-490a66ae8da0

Best regards,
-- 
Kuen-Han Tsai <khtsai@google.com>