Page MenuHomeFreeBSD

Add IPv4/IPv6 rtentry prefix accessors.
ClosedPublic

Authored by melifaro on Nov 29 2020, 11:25 PM.
Tags
None
Referenced Files
F106130207: D27416.diff
Wed, Dec 25, 9:53 PM
Unknown Object (File)
Thu, Dec 12, 6:41 PM
Unknown Object (File)
Sun, Dec 8, 7:29 AM
Unknown Object (File)
Oct 20 2024, 3:09 AM
Unknown Object (File)
Sep 17 2024, 12:57 PM
Unknown Object (File)
Sep 8 2024, 9:18 PM
Unknown Object (File)
Aug 18 2024, 5:19 PM
Unknown Object (File)
Aug 17 2024, 10:46 AM
Subscribers

Details

Summary

Multiple consumers like ipfw, netflow or new route lookup algorithms need to get the prefix data out of struct rtentry.
Instead of providing direct access to the rtentry, create IPv4/IPv6 accessors to abstract struct rtentry internals and avoid including internal routing headers for external consumers.

While here, move struct route_nhop_data to the public header, so external customers can actually use lookup functions returning rt&nhop data.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

melifaro added a reviewer: network.

Do I understand correctly, that dst contains an explicit bitmask, which is assumed to be continuous?

sys/net/route.h
458–461 ↗(On Diff #80134)
#ifdef INET

otherwise the prototype is not linkable.

462–465 ↗(On Diff #80134)
#ifdef INET6

dito

sys/net/route/route_ctl.c
313 ↗(On Diff #80134)

inet6_get_plen() ?

sys/net/route/route_ctl.c
270 ↗(On Diff #80134)

Returning the mask, not the bitcount?

313 ↗(On Diff #80134)

inet6_get_plen() ?

This seems to be correct, the INET part is wrong, isn't it?

In D27416#612562, @lutz_donnerhacke.de wrote:

Do I understand correctly, that dst contains an explicit bitmask, which is assumed to be continuous?

Yes. Also, given we have proper multipath routing in tree, I'm going to forbid non-continuous netmasks, so we cleanup at least some parts of the legacy in 13.

This revision is now accepted and ready to land.Dec 1 2020, 7:47 AM

Add scopeid to the IPv4/IPv6 accessor functions.
Add flags/rt_nhop accessor.

This revision now requires review to proceed.Dec 2 2020, 10:38 PM

Using the accessor functions and given the fact, that only continuous netmasks are allowed (not yet), the route-prefix could be shrinked by storing the prefix length instead of the mask.
The accessor function can then return the mask from a static netmask table.

In D27416#613471, @lutz_donnerhacke.de wrote:

Using the accessor functions and given the fact, that only continuous netmasks are allowed (not yet), the route-prefix could be shrinked by storing the prefix length instead of the mask.
The accessor function can then return the mask from a static netmask table.

Yes, sure. There are multiple ways of proceeding further. Prefix length can indeed be stored inside the radix mask as well, speeding up these calls. We need to be accurate with mask-only use case performance, as rtsock will use netmasks for quite a long time.
Anyway, the first step here is actually isolating access to the relevant rtentry fields.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 3 2020, 10:24 PM
This revision was automatically updated to reflect the committed changes.