From owner-svn-src-all@FreeBSD.ORG Thu May 15 19:26:21 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4C9BBF15; Thu, 15 May 2014 19:26:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A2B82ADC; Thu, 15 May 2014 19:26:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4FJQLCv060325; Thu, 15 May 2014 19:26:21 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4FJQLeM060324; Thu, 15 May 2014 19:26:21 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201405151926.s4FJQLeM060324@svn.freebsd.org> From: Hiroki Sato Date: Thu, 15 May 2014 19:26:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266177 - head/usr.bin/netstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 May 2014 19:26:21 -0000 Author: hrs Date: Thu May 15 19:26:20 2014 New Revision: 266177 URL: http://svnweb.freebsd.org/changeset/base/266177 Log: - Do not override sin6_scope_id in LLA when it is already set to non-zero. This fixes destination list in output of netstat -r. - Plug a memory leak. - Add RTM_VERSION check. - Minor style fixes. Modified: head/usr.bin/netstat/route.c Modified: head/usr.bin/netstat/route.c ============================================================================== --- head/usr.bin/netstat/route.c Thu May 15 19:19:57 2014 (r266176) +++ head/usr.bin/netstat/route.c Thu May 15 19:26:20 2014 (r266177) @@ -586,8 +586,9 @@ p_rtable_sysctl(int fibnum, int af) mib[4] = NET_RT_DUMP; mib[5] = 0; mib[6] = fibnum; - if (sysctl(mib, 7, NULL, &needed, NULL, 0) < 0) { - err(1, "sysctl: net.route.0.%d.dump.%d estimate", af, fibnum); + if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0) { + err(EX_OSERR, "sysctl: net.route.0.%d.dump.%d estimate", af, + fibnum); } if ((buf = malloc(needed)) == 0) { @@ -599,6 +600,8 @@ p_rtable_sysctl(int fibnum, int af) lim = buf + needed; for (next = buf; next < lim; next += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)next; + if (rtm->rtm_version != RTM_VERSION) + continue; /* * Peek inside header to determine AF */ @@ -611,6 +614,7 @@ p_rtable_sysctl(int fibnum, int af) } p_rtentry_sysctl(rtm); } + free(buf); } static void @@ -971,9 +975,9 @@ in6_fillscopeid(struct sockaddr_in6 *sa6 if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr) || IN6_IS_ADDR_MC_NODELOCAL(&sa6->sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&sa6->sin6_addr)) { - /* XXX: override is ok? */ - sa6->sin6_scope_id = - ntohs(*(u_int16_t *)&sa6->sin6_addr.s6_addr[2]); + if (sa6->sin6_scope_id == 0) + sa6->sin6_scope_id = + ntohs(*(u_int16_t *)&sa6->sin6_addr.s6_addr[2]); sa6->sin6_addr.s6_addr[2] = sa6->sin6_addr.s6_addr[3] = 0; } #endif