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.
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
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