Page MenuHomeFreeBSD

Add IPv4/IPv6 rtentry prefix accessors.
ClosedPublic

Authored by melifaro on Nov 29 2020, 11:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 30 2024, 10:42 AM
Unknown Object (File)
Apr 30 2024, 10:42 AM
Unknown Object (File)
Apr 30 2024, 10:42 AM
Unknown Object (File)
Apr 30 2024, 10:41 AM
Unknown Object (File)
Apr 30 2024, 10:41 AM
Unknown Object (File)
Apr 30 2024, 7:09 AM
Unknown Object (File)
Dec 23 2023, 2:17 AM
Unknown Object (File)
Sep 13 2023, 10:52 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.