Page MenuHomeFreeBSD

Convert rtentry field accesses into nhop field accesses.
ClosedPublic

Authored by melifaro on Apr 21 2020, 8:17 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 6:34 PM
Unknown Object (File)
Sun, Apr 14, 6:30 PM
Unknown Object (File)
Feb 20 2024, 6:09 PM
Unknown Object (File)
Feb 15 2024, 9:09 PM
Unknown Object (File)
Feb 1 2024, 1:46 AM
Unknown Object (File)
Dec 21 2023, 12:52 AM
Unknown Object (File)
Dec 20 2023, 7:13 AM
Unknown Object (File)
Dec 11 2023, 2:25 AM
Subscribers

Details

Summary

Convert rtentry field accesses into nhop field accesses.

One of the goals of the new routing KPI defined in r359823 is to entirely hide`struct rtentry` from the consumers. It will allow to improve routing subsystem internals and deliver more features much faster.
This change is one of the ongoing changes to eliminate direct struct rtentry field accesses.

This particular change is mostly mechanical.
The only notable difference is AF_LINK gateway encoding.

AF_LINK gw is used in routing stack for operations with interface routes, and host loopback routes.
In the former case it just indicates _some_ non-NULL gateway, as the interface is the same as in rt_ifp in kernel and rtm_ifindex in rtsock reporting.
In the latter case the interface index inside gateway is used by the IPv6 datapath to verify address scope for link-local interfaces.

Kernel uses struct sockaddr_dl for this type of gateway. This structure allows for specifying rich interface data, such as mac address and interface name. However, this results in large structure size - 52 bytes.
Routing stack fiils in only 2 fields - sdl_index and sdl_type, which reside in the first 8 bytes of the structure.

In the new KPI, struct nhop_object tries to be cache-efficient, hence embodies gateway address inside the structure. In the AF_LINK case it stores stortened version of the structure - struct sockaddr_dl_short, which occupies 16 bytes, With the nexhop changes, the data inside AF_LINK gateway is not used in the kernel, the only potential concern is userland.

The only two userland difference are shrinked sockaddr_dl structure and better rtsock structure alignment: 16 bytes vs 52.
This should not lead to any issues in the rtsock consumers.

old
got message of size 240 on Thu Apr 16 03:12:13 2020
RTM_ADD: Add Route: len 240, pid: 0, seq 0, errno 0, flags:<UP,DONE,PINNED>
locks:  inits:
sockaddrs: <DST,GATEWAY,NETMASK>
 10.0.0.0 link#5 255.255.255.0
new
got message of size 200 on Sun Apr 19 09:46:32 2020
RTM_ADD: Add Route: len 200, pid: 0, seq 0, errno 0, flags:<UP,DONE,PINNED>
locks:  inits:
sockaddrs: <DST,GATEWAY,NETMASK>
 10.0.0.0 link#5 255.255.255.0

More or less detailed overview on how rtsock messages are used by the routing daemons to reconstruct the kernel view, can be found in D22974 .
Short summary:

  • bird/quagga/frr uses RTM_NEWADDR and ignores prefix route addition messages.
  • quagga/frr ignores routes without gateway
Test Plan
kyua test -k /usr/tests/sys/net/routing/Kyuafile
test_rtsock_l3:rtm_add_v4_gu_ifa_ordered_success  ->  passed  [0.130s]
test_rtsock_l3:rtm_add_v4_gw_direct_success  ->  passed  [0.115s]
test_rtsock_l3:rtm_add_v4_temporal1_success  ->  passed  [0.136s]
test_rtsock_l3:rtm_add_v6_gu_gw_gu_direct_success  ->  passed  [0.117s]
test_rtsock_l3:rtm_add_v6_gu_ifa_hostroute_success  ->  passed  [0.115s]
test_rtsock_l3:rtm_add_v6_gu_ifa_ordered_success  ->  passed  [0.117s]
test_rtsock_l3:rtm_add_v6_gu_ifa_prefixroute_success  ->  passed  [0.119s]
test_rtsock_l3:rtm_add_v6_temporal1_success  ->  passed  [0.118s]
test_rtsock_l3:rtm_change_v4_gw_success  ->  passed  [0.124s]
test_rtsock_l3:rtm_change_v4_mtu_success  ->  passed  [0.117s]
test_rtsock_l3:rtm_change_v6_gw_success  ->  passed  [0.132s]
test_rtsock_l3:rtm_change_v6_mtu_success  ->  passed  [0.117s]
test_rtsock_l3:rtm_del_v4_gu_ifa_prefixroute_success  ->  passed  [0.118s]
test_rtsock_l3:rtm_del_v4_prefix_nogw_success  ->  passed  [0.120s]
test_rtsock_l3:rtm_del_v6_gu_ifa_hostroute_success  ->  passed  [0.125s]
test_rtsock_l3:rtm_del_v6_gu_ifa_prefixroute_success  ->  passed  [0.117s]
test_rtsock_l3:rtm_del_v6_gu_prefix_nogw_success  ->  passed  [0.116s]
test_rtsock_l3:rtm_get_v4_empty_dst_failure  ->  passed  [0.002s]
test_rtsock_l3:rtm_get_v4_exact_success  ->  passed  [0.142s]
test_rtsock_l3:rtm_get_v4_hostbits_failure  ->  passed  [0.117s]
test_rtsock_l3:rtm_get_v4_lpm_success  ->  passed  [0.120s]
test_rtsock_lladdr:rtm_add_v4_gu_lle_success  ->  passed  [0.118s]
test_rtsock_lladdr:rtm_add_v6_gu_lle_success  ->  passed  [0.118s]
test_rtsock_lladdr:rtm_add_v6_ll_lle_success  ->  passed  [0.113s]
test_rtsock_lladdr:rtm_del_v4_gu_lle_success  ->  passed  [0.116s]
test_rtsock_lladdr:rtm_del_v6_gu_lle_success  ->  passed  [0.113s]
test_rtsock_lladdr:rtm_del_v6_ll_lle_success  ->  passed  [0.112s]

Results file id is usr_tests_sys_net_routing.20200423-073157-018615
Results saved to /home/melifaro/.kyua/store/results.usr_tests_sys_net_routing.20200423-073157-018615.db

27/27 passed (0 failed)
divert:ipdivert_ip_input_local_success  ->  passed  [0.325s]
divert:ipdivert_ip_output_remote_success  ->  passed  [0.405s]
forward:fwd_ip_icmp_gw_fast_success  ->  passed  [0.372s]
forward:fwd_ip_icmp_gw_slow_success  ->  passed  [0.380s]
forward:fwd_ip_icmp_iface_fast_success  ->  passed  [0.398s]
forward:fwd_ip_icmp_iface_slow_success  ->  passed  [0.379s]
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.012s]
output:output_raw_success  ->  passed  [0.059s]
output:output_tcp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.012s]
output:output_tcp_setup_success  ->  passed  [0.104s]
output:output_udp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.012s]
output:output_udp_setup_success  ->  passed  [1.219s]
redirect:valid_redirect  ->  passed  [0.371s]
so_reuseport_lb_test:basic_ipv4  ->  passed  [0.501s]
so_reuseport_lb_test:basic_ipv6  ->  passed  [0.497s]
socket_afinet:socket_afinet  ->  passed  [0.002s]
socket_afinet:socket_afinet_bind_ok  ->  passed  [0.002s]
socket_afinet:socket_afinet_bind_zero  ->  passed  [0.002s]
divert:ipdivert_ip6_output_remote_success  ->  passed  [2.409s]
forward6:fwd_ip6_gu_icmp_gw_gu_fast_success  ->  passed  [1.812s]
forward6:fwd_ip6_gu_icmp_gw_gu_slow_success  ->  passed  [2.230s]
forward6:fwd_ip6_gu_icmp_gw_ll_fast_success  ->  passed  [1.881s]
forward6:fwd_ip6_gu_icmp_gw_ll_slow_success  ->  passed  [2.464s]
forward6:fwd_ip6_gu_icmp_iface_fast_success  ->  passed  [2.087s]
forward6:fwd_ip6_gu_icmp_iface_slow_success  ->  passed  [2.263s]
mld:mldraw01  ->  passed  [3.419s]
output6:output6_raw_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.013s]
output6:output6_raw_success  ->  passed  [1.766s]
output6:output6_tcp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.012s]
output6:output6_tcp_setup_success  ->  passed  [1.370s]
output6:output6_udp_flowid_mpath_success  ->  skipped: This test requires ROUTE_MPATH enabled  [0.012s]
output6:output6_udp_setup_success  ->  passed  [2.867s]
redirect:valid_redirect  ->  passed  [2.401s]
scapyi386:scapyi386  ->  passed  [3.433s]

Diff Detail

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

Event Timeline

melifaro retitled this revision from <<Replace this line with your revision title> Convert rtentry field accesses into nhop field accesses. to Convert rtentry field accesses into nhop field accesses..Apr 21 2020, 8:58 AM
melifaro edited the summary of this revision. (Show Details)
melifaro added a reviewer: network.
melifaro edited the test plan for this revision. (Show Details)
This revision was not accepted when it landed; it landed in state Needs Review.Apr 23 2020, 8:04 AM
This revision was automatically updated to reflect the committed changes.