Page MenuHomeFreeBSD

netlink: refactor KPI for generic Netlink modules
ClosedPublic

Authored by glebius on Feb 4 2025, 8:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 19, 9:13 AM
Unknown Object (File)
Wed, Mar 12, 3:23 PM
Unknown Object (File)
Wed, Mar 12, 10:49 AM
Unknown Object (File)
Sun, Mar 9, 12:06 PM
Unknown Object (File)
Sun, Mar 9, 8:23 AM
Unknown Object (File)
Thu, Mar 6, 6:34 PM
Unknown Object (File)
Tue, Mar 4, 7:36 AM
Unknown Object (File)
Sun, Mar 2, 4:09 AM

Details

Summary

Now that the family and group are completely private to netlink_generic.c,
provide a simple and robust KPI, that would require very simple guarantees
from both KPI and the module:

  • Strings are used only for family and group registration, that return ID: uint16_t genl_register_family(const char *name, ... uint32_t genl_register_group(uint16_t family, const char *name, ...
  • Once created families and groups are guaranteed to not disappear and be addressable by their ID.
  • All subsequent calls, including deregistration shall use ID.

Diff Detail

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

Event Timeline

There's a typo in the title ('generict').

sys/netlink/netlink_generic.c
98

I'm not sure if there are real-world implications, but it feels a little icky to do this check after we've already used family_id to access the families array.

Given that it's an assert it's probably fine.

Should we also assert that family_id - GENL_MIN_ID >= 0?

This revision is now accepted and ready to land.Feb 5 2025, 8:00 AM
glebius retitled this revision from netlink: refactor KPI for generict Netlink modules to netlink: refactor KPI for generic Netlink modules.Feb 5 2025, 5:06 PM
glebius marked an inline comment as done.
glebius added inline comments.
sys/netlink/netlink_generic.c
98

We did not access the families array yet, we just calculated the [potentially invalid] pointer. Since family_id is unsigned we already check for underflow.

This revision was automatically updated to reflect the committed changes.
glebius marked an inline comment as done.