Page MenuHomeFreeBSD

Allow address lookups in rn_match().
Needs ReviewPublic

Authored by melifaro on Jan 6 2020, 9:45 AM.

Details

Reviewers
bz
Group Reviewers
network
Summary

Radix is build around using "sockaddr-like structures", which requires callers to fill in these structures during lookups. This, in turn, leads to the next-order function signatures build around sockaddrs. Sometimes this is useful, however in many cases sockaddrs are not used by the certain subsystem internally.
Lastly, there are quite a lot of alternative data structures providing LPM, that typically do not require using sockaddrs.

With that in mind, restructure rn_match() to accept both addresses and sockaddr-like structures as the lookup key. Convert the existing parts of fib(9) api to leverage these changes.

Once all customers of a routing are converted, rn_match() can be changed to accept key addresses as is.

Currently radix allows to use variable-length keys (such as phone numbers) by specifying the key (actually, the total SA) length in the first byte. However, all current uses of the radix by pf, ipfw, nfs and routing, rely on constant-sized keys where length is known in advance.
With that in mind:

  • split int rn_Off byte offset field of radix_node into int16_t rn_Off and int16_t rn_Salen, where the latter indicates total structure length, similar to sa_len field in struct sockaddr.
  • Fill in this field for root node by using additional argument in rn_inithead()
  • Convert rn_match() and its helper functions to use the total len value from the tree root node instead of a key.
  • Provide per-AF macro to pass a proper pointer to rn_match.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 28522
Build 26575: arc lint + arc unit

Event Timeline

melifaro created this revision.Jan 6 2020, 9:45 AM
melifaro edited the summary of this revision. (Show Details)Jan 6 2020, 9:46 AM
melifaro added a reviewer: network.
melifaro updated this revision to Diff 66456.Jan 7 2020, 8:15 PM

Use internal __containerof() macro.

bz added a reviewer: bz.Jan 10 2020, 3:02 PM

I'll be happy to have a look (probably next week and once the redirect stuff is in)