Page MenuHomeFreeBSD

lacp: Sort port map by interface index
AcceptedPublic

Authored by gallatin on Wed, Dec 3, 5:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 9, 5:55 PM
Unknown Object (File)
Mon, Dec 8, 6:30 PM
Unknown Object (File)
Mon, Dec 8, 7:54 AM
Unknown Object (File)
Sun, Dec 7, 9:01 PM
Unknown Object (File)
Sun, Dec 7, 4:43 PM
Unknown Object (File)
Sun, Dec 7, 1:55 PM
Unknown Object (File)
Sun, Dec 7, 7:27 AM
Unknown Object (File)
Sun, Dec 7, 7:24 AM
Subscribers

Details

Summary

To make it easier to reason about system topology, keep the lacp port map sorted by interface index.

This makes it possible to carefully map applications to NIC queues by (ab)using the mbuf flowid to select egress NIC and queue in a predictable fashion.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/net/ieee8023ad_lacp.c
1046

I can understand that map[] members can be NULL pointers, but does qsort really ever passes NULL pointers to compar?

update based on Gleb's feedback

gallatin added inline comments.
sys/net/ieee8023ad_lacp.c
1046

Good catch.. It was a remnant of some debugging *before* I realized the map members could be null. Thanks for reminding me to remove it.

If pointers in the map[] can be NULL, then you removed too much, didn't you?

My understanding. First, qsort() itself never passes NULL pointer. Second, could a map[] entry within p->pm_count be NULL or not? The new code assumes it can't be. Then we also have a case with lacp_port that has NULL lp_ifp, which is covered.

gallatin marked an inline comment as done.

Remove more defensive debug code

My understanding. First, qsort() itself never passes NULL pointer. Second, could a map[] entry within p->pm_count be NULL or not? The new code assumes it can't be. Then we also have a case with lacp_port that has NULL lp_ifp, which is covered.

Sorry.. I did this months ago, and should have removed this defensive code at the time when I fixed the stupid bug I was chasing (reversed nmemb and count positions in calling qsort, if I recall correctly). It turns out all NULL checks are unneeded

  • the pm map is densely populated, so there will never be a null lacp_port pointer in the array (removed that in the previous patch)
  • the lp_ifp can't be null, as its populated as of port creation in lacp_port_creation

So I've simplified things. Thanks for making me look at this again.

This revision is now accepted and ready to land.Wed, Dec 3, 10:50 PM