From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZOS3d-0003y2-UT for mharc-grub-devel@gnu.org; Sun, 09 Aug 2015 10:58:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOS3a-0003wT-Ep for grub-devel@gnu.org; Sun, 09 Aug 2015 10:58:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOS3U-0006Ym-OZ for grub-devel@gnu.org; Sun, 09 Aug 2015 10:58:38 -0400 Received: from mail-lb0-x232.google.com ([2a00:1450:4010:c04::232]:32931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOS3U-0006YL-CB for grub-devel@gnu.org; Sun, 09 Aug 2015 10:58:32 -0400 Received: by lbbyj8 with SMTP id yj8so83209921lbb.0 for ; Sun, 09 Aug 2015 07:58:31 -0700 (PDT) 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=zgT/xsmB5LcQ12ixsRjT/YKrhK4mHdbgxMTX+4seNk8=; b=xB1jSMbgs8EQUxJjOzwNMRKioX0Ow9aNj/pWLSud9WgqfhBFXAZLKEik9EGgFDsbI0 NSoGk7I5eBSkTO0+lDomA7JjZSwJM7wEbpNFA1mkkGx91Uru3by7LCAeS6Tt8ZcqfAgc ulfSWDpvYImxcwgi0a1ooaw6N6JB9ZYU7COnSxOstvNKyGyCiSFxvhiKvyDknK+pVVpd p8Uw7PBmzivpZDo2TSkFWgYH8uSQWVXhHl5PGz38ca9VprgYNzl9OvhyqFqJwHKkbxaI hT9riBE02FcHGPDNf58+mCCqt62MUVdSCCXgCoAvX1bHNTVYyHelX4qNBVPzwys5kOTx p1Fg== X-Received: by 10.112.63.169 with SMTP id h9mr16653555lbs.104.1439132311441; Sun, 09 Aug 2015 07:58:31 -0700 (PDT) Received: from opensuse.site (ppp91-76-6-204.pppoe.mtu-net.ru. [91.76.6.204]) by smtp.gmail.com with ESMTPSA id lm3sm2726169lac.18.2015.08.09.07.58.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Aug 2015 07:58:30 -0700 (PDT) Date: Sun, 9 Aug 2015 17:58:28 +0300 From: Andrei Borzenkov To: Josef Bacik Subject: Re: [PATCH 3/3] net: fix ipv6 routing Message-ID: <20150809175828.73d61027@opensuse.site> In-Reply-To: <1438799799-32097-3-git-send-email-jbacik@fb.com> References: <1438799799-32097-1-git-send-email-jbacik@fb.com> <1438799799-32097-3-git-send-email-jbacik@fb.com> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.28; 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:c04::232 Cc: grub-devel@gnu.org, mchang@suse.com 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: Sun, 09 Aug 2015 14:58:40 -0000 =D0=92 Wed, 5 Aug 2015 14:36:39 -0400 Josef Bacik =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > Currently we cannot talk to ipv6 addresses outside of our local link area > because we don't setup our routes properly nor do we talk to the router > properly. Currently net_ipv6_autoconf adds routes for the local link pre= fix and > ties it to the global link device. This isn't helpful at all, we complet= ely > drop the router part of the router advertisement. So instead create a "d= efault > route" flag in routes and create a new route with the local link prefix a= nd the > router source address. >=20 Note that RA does not always mean default route. You need to check router lifetime to decide whether to use it as default route. > The second part of this problem is that the routing code thinks in ipv4 t= erms, > so it expects to find a route to the address we're looking for in our rou= ting > table. If we find a gateway then we just look for which interface matche= s the > network for the gateway. This doesn't work for ipv6 since the router giv= es us > its local link address, so the gateway will find the local link interface, > instead of the global interface. So to deal with this do a few things >=20 I am afraid it cannot be solved on routing table level. We need to bite the bullet and add notion of interface zone and associate each link local IPv6 address with interface it comes from (or sent to). This automatically solves also the problem in your other patch as well as this one by eliminating need to (attempt to) route link local in the first place - it is simply sent to interface it is associated with. It also means we probably need to support IPv6%scope notation for addresses. > 1) Create a new "default route" flag for any router advertisements we get= when > doing the ipv6 autoconf stuff. Then we create a normal gateway route wit= h the > default route flag set. >=20 > 2) When looking for routes keep track of any default routes we find, and = if we > don't find an exact route that matches we use the default route, which wi= ll set > the gateway to the router, and then we will find the local link interface= that > matches this router. >=20 > 3) Translate the local link interface to the global link interface. We b= uild > the ip packets based on the address on the interface, and this needs to h= ave the > global address, not the local one. So loop through our interfaces until = we find > a global address with the same hwaddress as the local link interface and = use > that instead. This way we get the right addresses on our IP packets. >=20 If I read RFC6724 correctly, we actually must prefer link-local source address when speaking with link-local destination. > With this patch I can now do net_ipv6_autoconf and immediately talk to ip= v6 > addresses outside of my local network. Thanks, >=20 > Signed-off-by: Josef Bacik > --- > grub-core/net/bootp.c | 2 +- > grub-core/net/drivers/ieee1275/ofnet.c | 2 +- > grub-core/net/icmp6.c | 50 ++++++++++------------ > grub-core/net/net.c | 76 +++++++++++++++++++++-------= ------ > include/grub/net.h | 28 ++++++++++++- > 5 files changed, 99 insertions(+), 59 deletions(-) >=20 ... > diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c > index 7953e68..fad04a9 100644 > --- a/grub-core/net/icmp6.c > +++ b/grub-core/net/icmp6.c > @@ -373,7 +373,10 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, > if (ohdr->type =3D=3D OPTION_PREFIX && ohdr->len =3D=3D 4) > { > struct prefix_option *opt =3D (struct prefix_option *) ptr; > + struct grub_net_route *route; > struct grub_net_slaac_mac_list *slaac; > + > + grub_net_network_level_netaddress_t netaddr; > if (!(opt->flags & FLAG_SLAAC) > || (grub_be_to_cpu64 (opt->prefix[0]) >> 48) =3D=3D 0xfe80 > || (grub_be_to_cpu32 (opt->preferred_lifetime) > @@ -391,18 +394,12 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *n= b, > for (slaac =3D card->slaac_list; slaac; slaac =3D slaac->next) > { > grub_net_network_level_address_t addr; > - grub_net_network_level_netaddress_t netaddr; > - > if (slaac->address.type > !=3D GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET) > continue; > addr.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; > addr.ipv6[0] =3D opt->prefix[0]; > addr.ipv6[1] =3D grub_net_ipv6_get_id (&slaac->address); > - netaddr.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; > - netaddr.ipv6.base[0] =3D opt->prefix[0]; > - netaddr.ipv6.base[1] =3D 0; > - netaddr.ipv6.masksize =3D 64; > =20 > FOR_NET_NETWORK_LEVEL_INTERFACES (inf) > { > @@ -410,29 +407,28 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *n= b, > && grub_net_addr_cmp (&inf->address, &addr) =3D=3D 0) > break; > } > - /* Update lease time if needed here once we have > - lease times. */ > - if (inf) > - continue; > + if (!inf) > + slaac->slaac_counter++; > + } > =20 > - grub_dprintf ("net", "creating slaac\n"); > + netaddr.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; > + netaddr.ipv6.base[0] =3D opt->prefix[0]; > + netaddr.ipv6.base[1] =3D 0; > + netaddr.ipv6.masksize =3D 64; > =20 > - { > - char *name; > - name =3D grub_xasprintf ("%s:%d", > - slaac->name, slaac->slaac_counter++); > - if (!name) > - { > - grub_errno =3D GRUB_ERR_NONE; > - continue; > - } > - inf =3D grub_net_add_addr (name,=20 > - card, &addr, > - &slaac->address, 0); > - grub_net_add_route (name, netaddr, inf); > - grub_free (name); > - } > - } This kills SLAAC. Where global addresses now come from? You probably get them from DHCPv6 but it does not mean we should drop SLAAC. > + FOR_NET_ROUTES(route) > + { > + if (!grub_memcmp(&route->gw, source, sizeof (route->gw))) > + break; > + } > + /* Update lease time if needed here once we have > + lease times. */ > + if (route) > + continue; > + > + grub_dprintf ("net", "creating default route\n"); > + > + grub_net_add_route_gw ("default6", netaddr, *source, 1); > } > } > if (ptr !=3D nb->tail)