[PATCH v3 0/9] net/memif: lifecycle fixes and unit test
Sriram Yagnaraman
sriram.yagnaraman at ericsson.com
Fri Oct 16 16:15:48 CEST 2026
This series fixes a set of error-path and lifecycle bugs in the memif
PMD and adds a unit test for the driver.
The first eight patches are fixes:
- guard eth_memif_tx() against an empty burst (nb_pkts == 0);
- close file descriptor 0 instead of leaking it;
- do not close the EAL-owned memseg fd in zero-copy mode;
- free the MAC address allocated during probe on failure;
- unwind a partially-created device on create failure;
- refuse connections on a stopped server so it does not come up on a
stopped port;
- disconnect on close so a stopped server's control channel is not
leaked, and make memif_disconnect() safe on a never-started device;
- fix eth_memif_tx_zc() returning 65535 on an invalid interrupt fd.
The last patch adds a memif PMD unit test (app/test, memif_pmd_autotest):
a server/client vdev pair over a loopback socket covering dev_info, link
state, stats, single-segment loopback (slow and fast path), multi-segment
loopback across a ring wrap, stop/start reconnect, empty Tx burst, close
without stop, and a stopped server refusing a peer.
Verified: memif_pmd_autotest passes 11/11; each commit builds with
-Dwerror=true; check-git-log and checkpatch are clean.
Thanks to Stephen Hemminger and the ai-code-review bot for the reviews
that shaped this series.
v3:
- Rebase on main, picking up rte_intr_fd_close() from
d9191f684c ("interrupts: add helpers to close FD"): patch 2 keeps
only the owned-fd ">= 0" fixes not superseded by that helper, and
patch 7 keeps the NULL-queue guards above the rte_intr_fd_close()
calls.
- New patch 6: refuse connections on a stopped server. The started-
then-stopped case is the actual trigger for the control-channel
leak; dev_stop now sets ETH_MEMIF_FLAG_DISABLED. (v2 patch 6/7
described this as never-started, which was wrong.)
- Patch 7 (disconnect on close): reword to the real trigger and keep
the close-time disconnect as a backstop.
- Patch 3 (memseg fd): also stop closing the EAL-owned fd in
memif_connect(), not only memif_free_regions().
- Test: new test_memif_stopped_server_rejects_peer covering patch 6
(fails without it); reword close-without-stop to what it actually
covers (the NULL-queue skip); verify the full fast-path payload.
v2:
- P1: correct Fixes tag (Tx fast path, not original driver); move the
empty-burst check after the ring == NULL block.
- P2: split the memseg-fd change into its own patch rather than
widening the check to ">= 0".
- P4 (MAC leak): document the secondary -1 -> -ENOMEM change.
- P5 (unwind): add Fixes: multi-process support.
- New patch: fix eth_memif_tx_zc() bogus Tx count on invalid fd.
- Test: add to MAINTAINERS; return TEST_FAILED (not SKIPPED) on probe
failure; add a default-bsize pair to cover the Tx fast path; set
ring size via rsize and fix the stale comments.
Sriram Yagnaraman (9):
net/memif: guard against empty Tx burst
net/memif: close file descriptor zero
net/memif: do not close EAL-owned memseg file descriptor
net/memif: fix MAC address leak on probe failure
net/memif: unwind partial device on create failure
net/memif: refuse connection on stopped device
net/memif: disconnect on device close
net/memif: fix bogus Tx count on invalid interrupt FD
test/memif: add memif PMD unit test
MAINTAINERS | 1 +
app/test/meson.build | 1 +
app/test/test_pmd_memif.c | 751 ++++++++++++++++++++++++++++++
drivers/net/memif/memif_socket.c | 10 +-
drivers/net/memif/rte_eth_memif.c | 76 ++-
5 files changed, 812 insertions(+), 27 deletions(-)
create mode 100644 app/test/test_pmd_memif.c
--
2.43.7
More information about the dev
mailing list