mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +02:00
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>
This commit is contained in:
committed by
Tom Rini
parent
09005c2fb2
commit
6de98b60ba
23
net/net.c
23
net/net.c
@@ -24,7 +24,7 @@
|
||||
* - name of bootfile
|
||||
* Next step: ARP
|
||||
*
|
||||
* LINK_LOCAL:
|
||||
* LINKLOCAL:
|
||||
*
|
||||
* Prerequisites: - own ethernet address
|
||||
* We want: - own IP address
|
||||
@@ -124,6 +124,7 @@
|
||||
#include "wol.h"
|
||||
#endif
|
||||
#include "dhcpv6.h"
|
||||
#include "net_rand.h"
|
||||
|
||||
/** BOOTP EXTENTIONS **/
|
||||
|
||||
@@ -350,6 +351,8 @@ void net_auto_load(void)
|
||||
|
||||
static int net_init_loop(void)
|
||||
{
|
||||
static bool first_call = true;
|
||||
|
||||
if (eth_get_dev()) {
|
||||
memcpy(net_ethaddr, eth_get_ethaddr(), 6);
|
||||
|
||||
@@ -369,6 +372,12 @@ static int net_init_loop(void)
|
||||
*/
|
||||
return -ENONET;
|
||||
|
||||
if (IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY))
|
||||
if (first_call && use_ip6) {
|
||||
first_call = false;
|
||||
srand_mac(); /* This is for rand used in ip6_send_rs. */
|
||||
net_loop(RS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -587,6 +596,10 @@ restart:
|
||||
ncsi_probe_packages();
|
||||
break;
|
||||
#endif
|
||||
case RS:
|
||||
if (IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY))
|
||||
ip6_send_rs();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -684,7 +697,13 @@ restart:
|
||||
x = time_handler;
|
||||
time_handler = (thand_f *)0;
|
||||
(*x)();
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY))
|
||||
if (time_handler && protocol == RS)
|
||||
if (!ip6_is_unspecified_addr(&net_gateway6) &&
|
||||
net_prefix_length != 0) {
|
||||
net_set_state(NETLOOP_SUCCESS);
|
||||
net_set_timeout_handler(0, NULL);
|
||||
}
|
||||
|
||||
if (net_state == NETLOOP_FAIL)
|
||||
ret = net_start_again();
|
||||
|
Reference in New Issue
Block a user