From c6fd08c6edf7cd5747f13cc411bae6396da4a81c Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 23 Jun 2016 09:32:24 +0000 Subject: [PATCH] net.c: do not print sockaddr_in6.sin6_scope_id unnecessarily Prior to RFC2553, struct sockaddr_in6 had no sin6_scope_id field. As the kernel still accepts RFC2133 editions of struct sockaddr_in6, print sockaddr_in6.sin6_scope_id only when it is specified. * net.c (SIN6_MIN_LEN): New macro. (print_sockaddr_data_in6): Print sockaddr_in6.sin6_scope_id only when socket address length exceeds SIN6_MIN_LEN. --- net.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net.c b/net.c index 938b2126..16548837 100644 --- a/net.c +++ b/net.c @@ -145,6 +145,8 @@ print_ifindex(unsigned int ifindex) tprintf("%u", ifindex); } +#define SIN6_MIN_LEN offsetof(struct sockaddr_in6, sin6_scope_id) + static void print_sockaddr_data_in6(const void *const buf, const int addrlen) { @@ -157,6 +159,10 @@ print_sockaddr_data_in6(const void *const buf, const int addrlen) ", \"%s\", &sin6_addr), sin6_flowinfo=%u", ntohs(sa_in6->sin6_port), string_addr, sa_in6->sin6_flowinfo); + + if (addrlen <= (int) SIN6_MIN_LEN) + return; + tprints(", sin6_scope_id="); #if defined IN6_IS_ADDR_LINKLOCAL && defined IN6_IS_ADDR_MC_LINKLOCAL if (IN6_IS_ADDR_LINKLOCAL(&sa_in6->sin6_addr) -- 2.50.1