`ifconfig` patch to resolve IPv6 scope names

Andrey V. Elsukov bu7cher at yandex.ru
Thu Aug 10 08:24:24 UTC 2017


On 09.08.2017 23:18, raichoo via freebsd-hackers wrote:
> Hi,
> 
> 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 :)
> 
> This is my first patch and I have no idea what's the best way to contribute
> to the
> project (probably I didn't look hard enough or in the wrong places).
> 
> Feedback and pointers appreciated.
> 
> Kind regards,
> raichoo
> 
> 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) != 0)
>                 printf("prefer_source ");
> 
> -       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);
> 
> +               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.

-- 
WBR, Andrey V. Elsukov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 553 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20170810/88d90caf/attachment.sig>


More information about the freebsd-hackers mailing list