From owner-freebsd-hackers@freebsd.org Fri Aug 11 11:15:53 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 6A62EDC6DA2 for ; Fri, 11 Aug 2017 11:15:53 +0000 (UTC) (envelope-from se@freebsd.org) Received: from mailout04.t-online.de (mailout04.t-online.de [194.25.134.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailout00.t-online.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 186756D70F for ; Fri, 11 Aug 2017 11:15:52 +0000 (UTC) (envelope-from se@freebsd.org) Received: from fwd38.aul.t-online.de (fwd38.aul.t-online.de [172.20.26.138]) by mailout04.t-online.de (Postfix) with SMTP id 661E941B1CBE; Fri, 11 Aug 2017 13:15:50 +0200 (CEST) Received: from Stefans-MBP-2.fritz.box (r4M5JcZBYhCi1mJr2F0SXFDwG++GWfPWYXxtfssYBUcgFajDcoDU+vF-JNcZ2hqwKX@[84.154.108.129]) by fwd38.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1dg7us-23dAPI0; Fri, 11 Aug 2017 13:15:46 +0200 Subject: Re: `ifconfig` patch to resolve IPv6 scope names To: "Andrey V. Elsukov" , raichoo Cc: freebsd-hackers@freebsd.org References: <8ebce8ed-5b3f-2b59-5b37-f6af7f3d4c2b@yandex.ru> <92290fd6-fa7f-5d62-732a-1353af612297@yandex.ru> From: Stefan Esser Message-ID: <2cb5043d-57cb-d0a8-0432-caf72069afe6@freebsd.org> Date: Fri, 11 Aug 2017 13:15:46 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <92290fd6-fa7f-5d62-732a-1353af612297@yandex.ru> Content-Type: text/plain; charset=windows-1252 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-ID: r4M5JcZBYhCi1mJr2F0SXFDwG++GWfPWYXxtfssYBUcgFajDcoDU+vF-JNcZ2hqwKX X-TOI-MSGID: 87b06505-3726-4c42-83ee-8554b842210c 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: Fri, 11 Aug 2017 11:15:53 -0000 Am 11.08.17 um 11:58 schrieb Andrey V. Elsukov: > On 10.08.2017 23:02, raichoo via freebsd-hackers wrote: >> Oh boy, should have read more code before posting that ^^. >> >> Thanks a lot for your feedback :) >> >> I've modified that patch to make it use the macros defined in in6.h. I'm >> also quite >> aware that this patch might be rejected since it might break script >> depending on `ifconfig` >> output. But it's a useful little learning experience anyway :) >> >> Kind regards, >> raichoo >> >> Here's the new iteration: >> >> diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c >> index e93d94355e..e1d44395c9 100644 >> --- a/sbin/ifconfig/af_inet6.c >> +++ b/sbin/ifconfig/af_inet6.c >> @@ -167,6 +167,35 @@ setip6eui64(const char *cmd, int dummy __unused, int s, >> } >> >> static void >> +in6_addr_scope(const struct in6_addr *addr) >> +{ >> + if (IN6_IS_ADDR_LINKLOCAL(addr)) >> + printf("link-local "); >> + else if (IN6_IS_ADDR_SITELOCAL(addr)) >> + printf("site-local "); >> + else if (IN6_IS_ADDR_MULTICAST(addr)) { >> + printf("multicast "); >> + switch (__IPV6_ADDR_MC_SCOPE(addr)) { >> + case __IPV6_ADDR_SCOPE_NODELOCAL: >> + printf("node-local "); >> + break; >> + case __IPV6_ADDR_SCOPE_LINKLOCAL: >> + printf("link-local "); >> + break; >> + case __IPV6_ADDR_SCOPE_SITELOCAL: >> + printf("site-local "); >> + break; >> + case __IPV6_ADDR_SCOPE_ORGLOCAL: >> + printf("organization-local "); >> + break; >> + case __IPV6_ADDR_SCOPE_GLOBAL: >> + printf("global "); >> + break; >> + } >> + } >> +} > > Hi, > > I'm not sure how it is useful configuring multicast addresses on the > interface. I think there are only four possible useful cases: > 1. loopback address should be marked as link-local > 2. link-local addresses should be marked as link-local > 3. site-local addresses should be marked as site-local > 4. all other non multicast addresses should be marked as global > > Also, AFAIR, the site-local scope was deprecated a long time ago. Yes, but I think printing this extra information is still useful, at least for an less experienced user who does not have memorized the different scope types. It doesn't matter, if a (possible) configuration makes sense, this patch just reports what's already configured ... If a site-local address is in use, it will be immediately obvious, and thus it makes sense to include it in the scope list, even if it should never be reported ;-) I'd like to see this patch committed ... Regards, STefan