Page MenuHomeFreeBSD

ng_device: add kqueue support
ClosedPublic

Authored by quentin.thebault_defenso.fr on Sep 15 2025, 3:58 AM.
Tags
None
Referenced Files
F138391028: D52541.diff
Mon, Dec 1, 4:52 PM
Unknown Object (File)
Mon, Dec 1, 9:15 AM
Unknown Object (File)
Sun, Nov 30, 9:06 PM
Unknown Object (File)
Sat, Nov 29, 2:33 AM
Unknown Object (File)
Fri, Nov 28, 4:05 PM
Unknown Object (File)
Thu, Nov 27, 7:23 PM
Unknown Object (File)
Thu, Nov 27, 9:26 AM
Unknown Object (File)
Thu, Nov 27, 6:13 AM

Details

Summary

Signed-off-by: Quentin Thébault <quentin.thebault@defenso.fr>
Sponsored by: Defenso

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added inline comments.
sys/netgraph/ng_device.c
156

Indentation here looks wrong.

337

Why do you need to lock earlier here?

537–538

You are missing braces here...

547

Same here.

676

Please fix the indentation in these functions. See the style(9) manual page.

Fix braces, indentation, restore original lock and set VNET

The VNET fix in ngdwrite was necessary to avoid a panic in
ng_ID2noderef (ng_base.c) when the ng_device is connected to
an ng_bridge node.

sys/netgraph/ng_device.c
241

These must be destroyed before the mutex they use.

381

To be destroyed before mutex.

Clean up device destruction

  • Fix order of knlist_destroy() and mtx_destroy()
  • Call knlist_clear() before knlist_destroy()
  • Add NGDF_DYING flag to send off the reader properly
  • Reverted unnecessary mtx changes in ngdread()
sys/netgraph/ng_device.c
534

We do not hold the ngd_mtx here, so this check is racy. Presumably we should check immediately before going to sleep below?

589
635

This is kind of misleading, as it reports only the number of bytes for the first packet in the queue, but we may have many packets available to read. The queue doesn't store the total number of bytes though, and probably we don't really want to traverse the whole queue to calculate the true number. I suggest adding a comment here explaining that.

Move ENXIO check behind mutex and add or fix comments

This revision is now accepted and ready to land.Oct 22 2025, 12:44 PM

Thanks a lot for your help!

Could you please mail me git format-patch-generated patches to apply to the tree? Or submit them as a pull request on github. Then I'll push them to main.

This revision was automatically updated to reflect the committed changes.