From 456b7a93418939408dbedc100658b7b995c87a8b Mon Sep 17 00:00:00 2001 From: hrs Date: Sat, 17 Nov 2012 20:19:00 +0000 Subject: Fill sin6_scope_id in sockaddr_in6 before passing it from the kernel to userland via routing socket or sysctl. This eliminates the following KAME-specific sin6_scope_id handling routine from each userland utility: sin6.sin6_scope_id = ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]); This behavior can be controlled by net.inet6.ip6.deembed_scopeid. This is set to 1 by default (sin6_scope_id will be filled in the kernel). Reviewed by: bz --- usr.bin/netstat/route.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'usr.bin') diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 270f6bd..dd91330 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -637,6 +637,12 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags) { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; + /* + * The sa6->sin6_scope_id must be filled here because + * this sockaddr is extracted from kmem(4) directly + * and has KAME-specific embedded scope id in + * sa6->sin6_addr.s6_addr[2]. + */ in6_fillscopeid(sa6); if (flags & RTF_HOST) -- cgit v1.1