`ifconfig` patch to resolve IPv6 scope names

Andrey V. Elsukov bu7cher at yandex.ru
Fri Aug 11 10:02:06 UTC 2017


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.

-- 
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/20170811/1611c69c/attachment.sig>


More information about the freebsd-hackers mailing list