From owner-freebsd-hackers@freebsd.org Thu Aug 10 08:24:24 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69903DCB5E4 for ; Thu, 10 Aug 2017 08:24:24 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [IPv6:2a02:6b8:0:801:2::107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Yandex CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06D1A76CAE for ; Thu, 10 Aug 2017 08:24:24 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from mxback10g.mail.yandex.net (mxback10g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:171]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 65FCB43440; Thu, 10 Aug 2017 11:22:33 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback10g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id p9sIcsaaCU-MXd0BoMI; Thu, 10 Aug 2017 11:22:33 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1502353353; bh=R8LEycLOhpDbAw7fvmKJ+KInmJLX1pLIQFO3qcI3HL8=; h=Subject:To:References:From:Message-ID:Date:In-Reply-To; b=UKaoOPo6d7bYjcKNPQ0H3c603ZsXVkFJlXkzQN+i65Uux/ktS4SZSTt3UJuLYrjbQ mjz2fXMJvDEAK5i8NvP+k17cyDykCJoAYgPK38OtQSEaf+y2jkY4QF3pbUrNNiKErT WHHMMSe7IHKzRUQOQ33ktvNiPs71WBIOlFZlkyls= Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id rlhkmxPDAd-MWpeBYoV; Thu, 10 Aug 2017 11:22:32 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1502353352; bh=R8LEycLOhpDbAw7fvmKJ+KInmJLX1pLIQFO3qcI3HL8=; h=Subject:To:References:From:Message-ID:Date:In-Reply-To; b=tD4yoksx46y/lVUBeyL1qUN/Zv+ty9CS7VndULBmleTLANyvbS5uE5in9WlxL0P5M V5pDsDgD3z8wACahuUf6MZg2EPUAIF90ypaVGLiRuvXqt9kWBoidWXs9kQ8dbXBzYa 56FTPXSp4f/ibjI7BYM79czAVG/s4/pZ+1SjwWVQ= Authentication-Results: smtp2p.mail.yandex.net; dkim=pass header.i=@yandex.ru Subject: Re: `ifconfig` patch to resolve IPv6 scope names To: raichoo , freebsd-hackers@freebsd.org References: From: "Andrey V. Elsukov" Openpgp: id=E6591E1B41DA1516F0C9BC0001C5EA0410C8A17A Message-ID: <8ebce8ed-5b3f-2b59-5b37-f6af7f3d4c2b@yandex.ru> Date: Thu, 10 Aug 2017 11:19:19 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dlhXvmALTLSlcj8h0Ho4SVQd1IMOASOiO" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2017 08:24:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dlhXvmALTLSlcj8h0Ho4SVQd1IMOASOiO Content-Type: multipart/mixed; boundary="7s8lKON7xeJw9LRXGHvk0R9ah0rlBdigS"; protected-headers="v1" From: "Andrey V. Elsukov" To: raichoo , freebsd-hackers@freebsd.org Message-ID: <8ebce8ed-5b3f-2b59-5b37-f6af7f3d4c2b@yandex.ru> Subject: Re: `ifconfig` patch to resolve IPv6 scope names References: In-Reply-To: --7s8lKON7xeJw9LRXGHvk0R9ah0rlBdigS Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 09.08.2017 23:18, raichoo via freebsd-hackers wrote: > Hi, >=20 > I've made a trivial patch that resolves IPv6 scope names (according to > rfc4291). > I thought this might be handy, so one does not have to memorize what id= > refers > to which scope. And it's a nice opportunity to get my feet wet I guess = :) >=20 > This is my first patch and I have no idea what's the best way to contri= bute > to the > project (probably I didn't look hard enough or in the wrong places). >=20 > Feedback and pointers appreciated. >=20 > Kind regards, > raichoo >=20 > diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c > index e93d94355e..165b2cc90a 100644 > --- a/sbin/ifconfig/af_inet6.c > +++ b/sbin/ifconfig/af_inet6.c > @@ -268,10 +268,32 @@ in6_status(int s __unused, const struct ifaddrs *= ifa) > if ((flags6 & IN6_IFF_PREFER_SOURCE) !=3D 0) > printf("prefer_source "); >=20 > - if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) > + if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) { > printf("scopeid 0x%x ", > ((struct sockaddr_in6 > *)(ifa->ifa_addr))->sin6_scope_id); >=20 > + switch (((struct sockaddr_in6 > *)(ifa->ifa_addr))->sin6_scope_id) { > + case 0x1: > + printf("interface-local "); > + break; > + case 0x2: > + printf("link-local "); > + break; Hi, the patch is wrong. sin6_scope_id does not describe the scope, it is scope zone id. To determine the scope, you should use an address. --=20 WBR, Andrey V. Elsukov --7s8lKON7xeJw9LRXGHvk0R9ah0rlBdigS-- --dlhXvmALTLSlcj8h0Ho4SVQd1IMOASOiO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlmMFwcACgkQAcXqBBDI oXp+YQf/doemcn3dkEcg5lgvEz/vn4lQBkTzRzFDv5E5+vPNtThMmMrQWC5EyBbQ lbrBto1J7zOQ8s3v1LBcY3Xj8iu6XoMttUL9NEXN4c158H5NU0oRBdlmEJK0zZed fEDLscT9hEcFrF6HRJQGVOsq9HrTC8aQUS/tx9Nl0bUzuTKYbyaJ9sx8cS98MCJZ Wq0hTNwdVx1ExErZ1Dwd4C36znxVOs8l3vb3GAlr2cF3jukDp8eIeOvMibOgfo/E dMZz72lH135JwtT206c9znj4LmG2uDk1dBJ9j33eW914SJAAfl2HajAADcRvCuvr a5O8idsX3SReQUX7Ncl8zXD/uD0Cbg== =xMRa -----END PGP SIGNATURE----- --dlhXvmALTLSlcj8h0Ho4SVQd1IMOASOiO--