diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-01-16 17:42:53 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-01-16 17:42:53 +0000 |
commit | c495ed86015923c81f1f98afef6d127ffa5efd0d (patch) | |
tree | a62f192af60096aa6a5089cd3818682304f41ef9 /usr.bin | |
parent | 1c9c87b63c6d17bf997a781d8357ebb4c1d9f24d (diff) |
Unle recover the scope_id from a possible embedded scope if the scope_id
is not initalized. Do not reset the scope_id if it was already set.
OK bluhm@ florian@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/if.c | 5 | ||||
-rw-r--r-- | usr.bin/netstat/show.c | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index f4c6ebd3c1b..1f8d0dec39e 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.76 2019/06/28 13:35:02 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.77 2021/01/16 17:42:52 claudio Exp $ */ /* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */ /* @@ -231,7 +231,8 @@ print_addr(struct sockaddr *sa, struct sockaddr **rtinfo, struct if_data *ifd) case AF_INET6: sin6 = (struct sockaddr_in6 *)sa; #ifdef __KAME__ - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && + sin6->sin6_scope_id == 0) { sin6->sin6_scope_id = ntohs(*(u_int16_t *) &sin6->sin6_addr.s6_addr[2]); diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c index 156559002b2..8949c00deec 100644 --- a/usr.bin/netstat/show.c +++ b/usr.bin/netstat/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.56 2020/09/15 20:28:27 pamela Exp $ */ +/* $OpenBSD: show.c,v 1.57 2021/01/16 17:42:52 claudio Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -341,9 +341,10 @@ p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width) * XXX: This is a special workaround for KAME kernels. * sin6_scope_id field of SA should be set in the future. */ - if (IN6_IS_ADDR_LINKLOCAL(in6) || + if ((IN6_IS_ADDR_LINKLOCAL(in6) || IN6_IS_ADDR_MC_LINKLOCAL(in6) || - IN6_IS_ADDR_MC_INTFACELOCAL(in6)) { + IN6_IS_ADDR_MC_INTFACELOCAL(in6)) && + sa6->sin6_scope_id == 0) { /* XXX: override is ok? */ sa6->sin6_scope_id = (u_int32_t)ntohs(*(u_short *) &in6->s6_addr[2]); |