Page MenuHomeFreeBSD

IfAPI: Add some more accessors
ClosedPublic

Authored by jhibbits on Jan 25 2023, 9:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 1:33 AM
Unknown Object (File)
Dec 12 2023, 4:15 PM
Unknown Object (File)
Dec 5 2023, 1:59 PM
Unknown Object (File)
Dec 3 2023, 5:04 AM
Unknown Object (File)
Nov 20 2023, 7:55 PM
Unknown Object (File)
Sep 28 2023, 3:32 PM
Unknown Object (File)
Sep 11 2023, 5:47 AM
Unknown Object (File)
Aug 1 2023, 3:23 PM
Subscribers

Details

Summary
  • if_setreassignfn for wireguard.
  • if_getinputfn() and if_getstartfn() for various drivers. Use the function descriptor typedefs for these and the setters.
  • vlantrunk accessor. This is used by VLAN_CAPABILITIES() used by several drivers, as well as directly by mxge(4).
  • if_pcp member accessor, used by cxgbe.
  • accessors for netmap adapter.

Sponsored by: Juniper Networks, Inc.

Diff Detail

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

Event Timeline

sys/net/if.c
4775

Nit: ‘const if_t’ for all accessors?

sys/net/if.c
4775

Thought about it, but 'const if_t' and 'if_t' mean the same thing, really. The 'const' goes on the pointer, not on the struct. The const makes no difference.

sys/net/if.c
4775

I agree - it's certainly true for the drivers part, where there is no visibility over the struct ifnet internals.
For the netstack situation may look a bit different. Personally I think it would make sense to use available accessors there as well - at least for consistency. Then, there will be situations where 'const ifnet *ifp' will be passed to the function which then need to access one of the fields. The programmer will have to either do field access directly, or do the typecast. Both approaches doesn't look fancy to me. Finally, apart from helping the compiler to enforce read-only boundaries, it can also signal the intent to the human.
What do you think?

No objection from me. Don't you mind that later we come up with a kobj(9) or a kobj-like (see r281151 of projects/ifnet) for all these various softcs?

This revision is now accepted and ready to land.Jan 31 2023, 4:51 PM

Do you have by chance any plans on merging accessors to 13/ to ease other merges?

No objection from me. Don't you mind that later we come up with a kobj(9) or a kobj-like (see r281151 of projects/ifnet) for all these various softcs?

I hope we do come up with a better API than this. These accessors just decouple the precise layout, but that's it. For Juniper this is sufficient, but it's far from ideal for the general case.

Do you have by chance any plans on merging accessors to 13/ to ease other merges?

I hadn't planned for it, but I don't see a problem with MFC'ing after a couple months of soak to complete the process.

This revision was automatically updated to reflect the committed changes.