From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Xpgcn-00068i-5A for mharc-grub-devel@gnu.org; Sat, 15 Nov 2014 11:55:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xpgcg-00068b-58 for grub-devel@gnu.org; Sat, 15 Nov 2014 11:54:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xpgca-00035L-ER for grub-devel@gnu.org; Sat, 15 Nov 2014 11:54:54 -0500 Received: from mail-la0-x230.google.com ([2a00:1450:4010:c03::230]:59394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpgcZ-00034x-Qy for grub-devel@gnu.org; Sat, 15 Nov 2014 11:54:48 -0500 Received: by mail-la0-f48.google.com with SMTP id s18so2649524lam.35 for ; Sat, 15 Nov 2014 08:54:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=dNDKioxTLJws299mT/lNLg7kjTpfeStD8n3XGzjnat8=; b=BkvpgcmAS7AJFSvHf7BwRKwpboil9O+cjId9Dgy8RcQATsII/5xXPnIQRWG39qUTFR RnPi6Qb1c7iA+9u6b4iOeu1azW9teG1rKYIpXmB9e5elsZM9UZayMl/QhbGJzgUzQrHp /qovoG9EX9/6ZV3Fa7gCpfXTzdjAObFa1xTO1XOZ/GEqmVuciUZ6jw0yQxygRk4zou/x oyEIflE1orKNUZ2wZQ2gavXJcbi4aWGqNTGynfiUkrPJPfpg68zyOcrJt9QYcl03pT1v U1l2JjstyP69bzOaz86k7ebk/ZR+sIMTIA2FeNVTCZ6Fiqo+zzOJaPO1rlWJluxIdlja kcvw== X-Received: by 10.152.7.193 with SMTP id l1mr14584685laa.57.1416070486327; Sat, 15 Nov 2014 08:54:46 -0800 (PST) Received: from opensuse.site (ppp91-76-139-38.pppoe.mtu-net.ru. [91.76.139.38]) by mx.google.com with ESMTPSA id ee6sm9011311lad.45.2014.11.15.08.54.43 for (version=SSLv3 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Nov 2014 08:54:44 -0800 (PST) Date: Sat, 15 Nov 2014 19:54:42 +0300 From: Andrei Borzenkov To: Michael Chang Subject: Re: [PATCH] send router solicitation for ipv6 address autoconf Message-ID: <20141115195442.66f0e786@opensuse.site> In-Reply-To: <1415871743-17879-1-git-send-email-mchang@suse.com> References: <1415871743-17879-1-git-send-email-mchang@suse.com> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.24; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::230 Cc: grub-devel@gnu.org X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Nov 2014 16:55:00 -0000 =D0=92 Thu, 13 Nov 2014 17:42:23 +0800 Michael Chang =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > 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. >=20 > This patch tries to send router solicitation to overcome the problem of > long RA interval. > --- > grub-core/net/icmp6.c | 81 +++++++++++++++++++++++++++++++++++++++++++= ++++++ > grub-core/net/net.c | 4 ++- > include/grub/net/ip.h | 2 + > 3 files changed, 86 insertions(+), 1 deletions(-) >=20 > diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c > index 796d549..87b264f 100644 > --- a/grub-core/net/icmp6.c > +++ b/grub-core/net/icmp6.c > @@ -72,6 +72,11 @@ struct neighbour_advertise > grub_uint64_t target[2]; > } GRUB_PACKED; > =20 > +struct router_solicit > +{ > + grub_uint32_t reserved; > +} GRUB_PACKED; > + > enum > { > FLAG_SLAAC =3D 0x40 > @@ -81,6 +86,7 @@ enum > { > ICMP6_ECHO =3D 128, > ICMP6_ECHO_REPLY =3D 129, > + ICMP6_ROUTER_SOLICIT =3D 133, > ICMP6_ROUTER_ADVERTISE =3D 134, > ICMP6_NEIGHBOUR_SOLICIT =3D 135, > ICMP6_NEIGHBOUR_ADVERTISE =3D 136, > @@ -533,3 +539,78 @@ grub_net_icmp6_send_request (struct grub_net_network= _level_interface *inf, > grub_netbuff_free (nb); > return err; > } > + > +grub_err_t > +grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interf= ace *inf) > +{ > + struct grub_net_buff *nb; > + grub_err_t err =3D GRUB_ERR_NONE; > + grub_net_network_level_address_t multicast; > + grub_net_link_level_address_t ll_multicast; > + struct option_header *ohdr; > + struct router_solicit *sol; > + struct icmp_header *icmphr; > + > + multicast.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; > + multicast.ipv6[0] =3D grub_be_to_cpu64_compile_time (0xff02ULL << 48); > + multicast.ipv6[1] =3D grub_be_to_cpu64_compile_time (0x02ULL); > + Could you use cpu_to_be variant; it makes it less confusing (that is what we do here). > + err =3D grub_net_link_layer_resolve (inf, &multicast, &ll_multicast); > + if (err) > + return err; > + > + nb =3D grub_netbuff_alloc (sizeof (struct router_solicit) > + + sizeof (struct option_header) > + + 6 > + + sizeof (struct icmp_header) > + + GRUB_NET_OUR_IPV6_HEADER_SIZE > + + GRUB_NET_MAX_LINK_HEADER_SIZE); > + if (!nb) > + return grub_errno; > + err =3D grub_netbuff_reserve (nb, > + sizeof (struct router_solicit) > + + sizeof (struct option_header) > + + 6 > + + sizeof (struct icmp_header) > + + GRUB_NET_OUR_IPV6_HEADER_SIZE > + + GRUB_NET_MAX_LINK_HEADER_SIZE); > + Error check? Otherwise personally I'm fine with it. > + err =3D grub_netbuff_push (nb, 6); > + if (err) > + goto fail; > + > + grub_memcpy (nb->data, inf->hwaddress.mac, 6); > + > + err =3D grub_netbuff_push (nb, sizeof (*ohdr)); > + if (err) > + goto fail; > + > + ohdr =3D (struct option_header *) nb->data; > + ohdr->type =3D OPTION_SOURCE_LINK_LAYER_ADDRESS; > + ohdr->len =3D 1; > + > + err =3D grub_netbuff_push (nb, sizeof (*sol)); =20 > + if (err) > + goto fail; > + > + sol =3D (struct router_solicit *) nb->data; > + sol->reserved =3D 0; > + > + err =3D grub_netbuff_push (nb, sizeof (*icmphr)); > + if (err) > + goto fail; > + > + icmphr =3D (struct icmp_header *) nb->data; > + icmphr->type =3D ICMP6_ROUTER_SOLICIT; > + icmphr->code =3D 0; > + icmphr->checksum =3D 0; > + icmphr->checksum =3D grub_net_ip_transport_checksum (nb, > + GRUB_NET_IP_ICMPV6, > + &inf->address, > + &multicast); > + err =3D grub_net_send_ip_packet (inf, &multicast, &ll_multicast, nb, > + GRUB_NET_IP_ICMPV6); > + fail: > + grub_netbuff_free (nb); > + return err; > +} > diff --git a/grub-core/net/net.c b/grub-core/net/net.c > index 82af3a0..21a4e94 100644 > --- a/grub-core/net/net.c > +++ b/grub-core/net/net.c > @@ -380,12 +380,14 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __= attribute__ ((unused)), > =20 > for (interval =3D 200; interval < 10000; interval *=3D 2) > { > - /* FIXME: send router solicitation. */ > int done =3D 1; > for (j =3D 0; j < ncards; j++) > { > if (slaacs[j]->slaac_counter) > continue; > + err =3D grub_net_icmp6_send_router_solicit (ifaces[j]); > + if (err) > + err =3D GRUB_ERR_NONE; > done =3D 0; > } > if (done) > diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h > index 7a8e614..dcceaa5 100644 > --- a/include/grub/net/ip.h > +++ b/include/grub/net/ip.h > @@ -92,4 +92,6 @@ grub_err_t > grub_net_icmp6_send_request (struct grub_net_network_level_interface *in= f, > const grub_net_network_level_address_t *proto_addr); > =20 > +grub_err_t > +grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interf= ace *inf); > #endif=20