Page MenuHomeFreeBSD

ng_device: add kqueue support
Needs ReviewPublic

Authored by quentin.thebault_defenso.fr on Sep 15 2025, 3:58 AM.
Tags
None
Referenced Files
F132549621: D52541.id162787.diff
Fri, Oct 17, 9:44 PM
Unknown Object (File)
Fri, Oct 10, 2:32 PM
Unknown Object (File)
Fri, Oct 10, 4:20 AM
Unknown Object (File)
Thu, Oct 9, 10:06 PM
Unknown Object (File)
Thu, Oct 9, 10:06 PM
Unknown Object (File)
Thu, Oct 9, 10:06 PM
Unknown Object (File)
Thu, Oct 9, 10:06 PM
Unknown Object (File)
Thu, Oct 9, 10:06 PM

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 67297
Build 64180: arc lint + arc unit

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?

539–540

You are missing braces here...

544

Same here.

673

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?

586
632

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.