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

Allow lookups by address in addition to sockaddr-lookups in system radix.

Problem statement

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.

Proposal

As the key length is fixed per address family, store it inside radix structure, similar to the key offset.

To continue allowing support for variable-length keys, add special rn_match_fixed() function that uses the in-radix stored offset and does *not* access any fields in the provided key beyond [offset; offset + key_length] interval.
This allows passing adjusted pointer to the IPv4/IPv6 address without filling the sockaddr structure.
Finally, convert the existing parts of fib(9) api to leverage these changes.

Test Plan

New tests (icmp-based, so raw ip, so ip[6]_output() uses fib46 functions for the lookup):

lpm:lpm_test1_success  ->  passed  [0.186s]
lpm:lpm_test2_success  ->  passed  [0.198s]
lpm6:lpm6_test1_success  ->  passed  [2.188s]
lpm6:lpm6_test2_success  ->  passed  [2.037s]

Common tests:

forward:fwd_ip_icmp_gw_fast_success  ->  passed  [0.344s]
forward:fwd_ip_icmp_gw_slow_success  ->  passed  [0.364s]
forward:fwd_ip_icmp_iface_fast_success  ->  passed  [0.363s]
forward:fwd_ip_icmp_iface_slow_success  ->  passed  [0.410s]
ip_reass_test:ip_reass__large_fragment  ->  passed  [0.013s]
ip_reass_test:ip_reass__multiple_last_fragments  ->  passed  [0.029s]
ip_reass_test:ip_reass__zero_length_fragment  ->  passed  [0.013s]
output:output_raw_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output:output_raw_success  ->  passed  [0.059s]
output:output_tcp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output:output_tcp_setup_success  ->  passed  [0.089s]
output:output_udp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output:output_udp_setup_success  ->  passed  [1.114s]
redirect:valid_redirect  ->  passed  [0.346s]
so_reuseport_lb_test:basic_ipv4  ->  passed  [0.495s]
so_reuseport_lb_test:basic_ipv6  ->  passed  [0.502s]
socket_afinet:socket_afinet  ->  passed  [0.002s]
socket_afinet:socket_afinet_bind_ok  ->  passed  [0.002s]

forward6:fwd_ip6_gu_icmp_gw_gu_fast_success  ->  passed  [2.371s]
forward6:fwd_ip6_gu_icmp_gw_gu_slow_success  ->  passed  [1.582s]
forward6:fwd_ip6_gu_icmp_gw_ll_fast_success  ->  passed  [2.333s]
forward6:fwd_ip6_gu_icmp_gw_ll_slow_success  ->  passed  [2.381s]
forward6:fwd_ip6_gu_icmp_iface_fast_success  ->  passed  [2.471s]
forward6:fwd_ip6_gu_icmp_iface_slow_success  ->  passed  [1.845s]
mld:mldraw01  ->  passed  [3.341s]
output6:output6_raw_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output6:output6_raw_success  ->  passed  [1.785s]
output6:output6_tcp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output6:output6_tcp_setup_success  ->  passed  [1.972s]
output6:output6_udp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output6:output6_udp_setup_success  ->  passed  [3.019s]
redirect:valid_redirect  ->  passed  [2.397s]
scapyi386:scapyi386  ->  passed  [3.387s]

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 28501
Build 26558: 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)

I'm going to commit this on Friday 3 April if there are no objections.

melifaro updated this revision to Diff 70404.Apr 10 2020, 3:22 PM

Use less invasive approach by configuring lookup key length in

rn_setkeylen() and using special rn_match_fixed() function.

While here, constantify lookup key.

melifaro updated this revision to Diff 70405.Apr 10 2020, 3:24 PM

Add forgotten inline to rn_match_internal.

melifaro edited the test plan for this revision. (Show Details)Apr 10 2020, 3:42 PM
melifaro updated this revision to Diff 70406.Apr 10 2020, 3:42 PM

Update arguments for rn_setkeylen().

melifaro edited the summary of this revision. (Show Details)Apr 10 2020, 3:55 PM