From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757330AbbICUDm (ORCPT ); Thu, 3 Sep 2015 16:03:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46295 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbbICUDk (ORCPT ); Thu, 3 Sep 2015 16:03:40 -0400 Subject: Re: [PATCH] RDMA/cma: fix IPv6 address resolution To: Spencer Baugh , Roland Dreier , Sean Hefty , Hal Rosenstock , "open list:INFINIBAND SUBSYSTEM" , open list References: <1439493550-5958-1-git-send-email-sbaugh@catern.com> Cc: Joern Engel , Spencer Baugh From: Doug Ledford Openpgp: id=AE6B1BDA122B23B4265B1274B826A3330E572FDD; url=pgp.mit.edu Organization: Red Hat, Inc. Message-ID: <55E8A79B.8070201@redhat.com> Date: Thu, 3 Sep 2015 16:03:39 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1439493550-5958-1-git-send-email-sbaugh@catern.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nigXu8Tg9rqeMCbsnQsMwCXTc6O7NKlKb" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nigXu8Tg9rqeMCbsnQsMwCXTc6O7NKlKb Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 08/13/2015 03:19 PM, Spencer Baugh wrote: > Resolving a link-local IPv6 address with an unspecified source address > was broken by commit 5462eddd7a, which prevented the IPv6 stack from > learning the scope id of the link-local IPv6 address, causing random > failures as the IP stack chose a random link to resolve the address on.= >=20 > This commit 5462eddd7a made us bail out of cma_check_linklocal early if= > the address passed in was not an IPv6 link-local address. On the addres= s > resolution path, the address passed in is the source address; if the > source address is the unspecified address, which is not link-local, we > will bail out early. >=20 > This is mostly correct, but if the destination address is a link-local > address, then we will be following a link-local route, and we'll need t= o > tell the IPv6 stack what the scope id of the destination address is. > This used to be done by last line of cma_check_linklocal, which is > skipped when bailing out early: >=20 > dev_addr->bound_dev_if =3D sin6->sin6_scope_id; >=20 > (In cma_bind_addr, the sin6_scope_id of the source address is set to th= e > sin6_scope_id of the destination address, so this is correct) > This line is required in turn for the following line, L279 of > addr6_resolve, to actually inform the IPv6 stack of the scope id: >=20 > fl6.flowi6_oif =3D addr->bound_dev_if; >=20 > Since we can only know we are in this failure case when we have access > to both the source IPv6 address and destination IPv6 address, we have t= o > deal with this further up the stack. So detect this failure case in > cma_bind_addr, and set bound_dev_if to the destination address scope id= > to correct it. >=20 > Signed-off-by: Spencer Baugh > --- > drivers/infiniband/core/cma.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cm= a.c > index 6a6b60a..3b71154 100644 > --- a/drivers/infiniband/core/cma.c > +++ b/drivers/infiniband/core/cma.c > @@ -2188,8 +2188,11 @@ static int cma_bind_addr(struct rdma_cm_id *id, = struct sockaddr *src_addr, > src_addr =3D (struct sockaddr *) &id->route.addr.src_addr; > src_addr->sa_family =3D dst_addr->sa_family; > if (dst_addr->sa_family =3D=3D AF_INET6) { > - ((struct sockaddr_in6 *) src_addr)->sin6_scope_id =3D > - ((struct sockaddr_in6 *) dst_addr)->sin6_scope_id; > + struct sockaddr_in6 *src_addr6 =3D (struct sockaddr_in6 *) src_addr= ; > + struct sockaddr_in6 *dst_addr6 =3D (struct sockaddr_in6 *) dst_addr= ; > + src_addr6->sin6_scope_id =3D dst_addr6->sin6_scope_id; > + if (ipv6_addr_type(&dst_addr6->sin6_addr) & IPV6_ADDR_LINKLOCAL) > + id->route.addr.dev_addr.bound_dev_if =3D dst_addr6->sin6_scope_id;= > } else if (dst_addr->sa_family =3D=3D AF_IB) { > ((struct sockaddr_ib *) src_addr)->sib_pkey =3D > ((struct sockaddr_ib *) dst_addr)->sib_pkey; >=20 Thanks, applied. --=20 Doug Ledford GPG KeyID: 0E572FDD --nigXu8Tg9rqeMCbsnQsMwCXTc6O7NKlKb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJV6KebAAoJELgmozMOVy/diSgQALF4kuOTUOuHw2deSzvwVV2M AovZuKSApqfJXWyZqqCDZHUPpH+msn0Hqnrm3qJDNDKF3kuVVDCR/ulKNVbZ/uNh 6wcTq7DGUBFu4wm5nXi/XM1hOP6tF9gkNjoV69PiYcFmxz+iOd8ESC2GYNsoqSJD A5Uwoi4EsXpWiG44s0N/4fePk0pHHqqhz+06C64ZF9ujO4O5fVPw+oKw+apsR+g5 tnpttrZL3NWVo2bLIM/QnY3n50qOMjjK3pBXt5YRg0VhEcvGJBnrcSkWCNRdFOXH hJ7w3bQELuMTwJCO0Iy07/ecSYC9/cm7zaDB/TJCLDfcZGU4LrghdY44oT+jNu4e r4SOuwI1l6kYn7r2HaOKnFixjQDJowvFQQk821DcM+9R45fcgohDQIANKhABeAUF ydMROuUDr0WIotGUQkwH6jZQLL9MGdzUy1bmMekBfXFhHdxMdKeDS1XcnTD62WXp giXoNw+tFvMm8NX5HTCLweXMOHcQCDPaFRRuKjjmAZwdexcbU9HJL6d0Es5+ypd2 ZPhYILnkIv/ZwM9CvbqW+VleQ1H7+T37UZOuQEAA4xkHqHGbuzDgOmUnG0d47Wtz iAFfNNJfoV2d4rzrXpQDhUrLxo1LUYz7YuGi4Bl9PJxL+UpamUZKzFHoa3AGgwpI hlyJiCzbyWOOM2RaD/aU =ZG0D -----END PGP SIGNATURE----- --nigXu8Tg9rqeMCbsnQsMwCXTc6O7NKlKb--