net: ipv6: Add support for default gateway discovery.
authorEhsan Mohandesi <emohandesi@linux.microsoft.com>
Sat, 22 Apr 2023 00:08:21 +0000 (17:08 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 5 May 2023 21:58:52 +0000 (17:58 -0400)
commit6de98b60ba89fb96a3adada11a5b5406f3b3786b
tree37713f86715e19599874069861547f09037528b0
parent09005c2fb288decb4010f062fdc87d0b82e57584
net: ipv6: Add support for default gateway discovery.

In IPv6, the default gateway and prefix length are determined by receiving
a router advertisement as defined in -
https://www.rfc-editor.org/rfc/rfc4861.

Add support for sending router solicitation (RS) and processing router
advertisements (RA).

If the RA has prefix info option and following conditions are met, then
gatewayip6 and net_prefix_length of ip6addr env variables are initialized.
These are later consumed by IPv6 code for non-local destination IP.

- "Router Lifetime" != 0
- Prefix is NOT link-local prefix (0xfe80::/10)
- L flag is 1
- "Valid Lifetime" != 0

Timing Parameters:
- MAX_RTR_SOLICITATION_DELAY (0-1s)
- RTR_SOLICITATION_INTERVAL (4s) (min retransmit delay)
- MAX_RTR_SOLICITATIONS (3 RS transmissions)

The functionality is enabled by CONFIG_IPV6_ROUTER_DISCOVERY and invoked
automatically from net_init_loop().

Signed-off-by: Ehsan Mohandesi <emohandesi@linux.microsoft.com>
Tested-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>Reviewed-by:
Tested-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Tested-by: Sergei Antonov <saproj@gmail.com>
Reviewed-by: Sergei Antonov <saproj@gmail.com>
cmd/Kconfig
include/ndisc.h
include/net.h
include/net6.h
net/ndisc.c
net/net.c
net/net6.c