Many routers have long router advertisment interval configured by
default. The Neighbor Discovery protocol (RFC4861) has defined default
MaxRtrAdvInterval value as 600 seconds and
MinRtrAdvInterval as 0.33*MaxRtrAdvInterval. This makes
net_ipv6_autoconf fails more often than not as currently it passively
listens the RA message to perfom address autoconfiguration.
This patch tries to send router solicitation to overcome the problem of
long RA interval.
v2:
use cpu_to_be macro for network byte order conversion
add missing error handling
The structure size used in grub_netbuff_pull to get the pointer to
option header is apparently wrong, which leads to subsequent range check
failed and therefore not responding to any neighbor solicit message in my
testing.
* include/grub/net.h (grub_net_poll_cards): New argument stop_condition.
All users updated.
* grub-core/net/arp.c (have_pending): New var.
(pending_req): Likewise.
(grub_net_arp_send_request): Fill pending_req and use have_pending as
stop indicator.
(grub_net_arp_receive): Set have_pending.
* grub-core/net/dns.c (recv_data): New field stop.
(recv_hook): Set stop.
(grub_net_dns_lookup): Init stop and use as stop condition.
* grub-core/net/http.c (http_establish): Use headers_recv as stop
condition.
* grub-core/net/net.c (grub_net_poll_cards): New argument
stop_condition. Stop when it goes true.
* grub-core/net/tcp.c (grub_net_tcp_open): Use `established' as stop
indicator.
* grub-core/net/tftp.c (tftp_open): Use `have_oack' as stop indicator.