From owner-svn-src-all@FreeBSD.ORG Wed May 6 16:43:45 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 977ADDFD; Wed, 6 May 2015 16:43:45 +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 85CBB1E3B; Wed, 6 May 2015 16:43:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t46GhjIL000720; Wed, 6 May 2015 16:43:45 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t46GhjFE000719; Wed, 6 May 2015 16:43:45 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201505061643.t46GhjFE000719@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 6 May 2015 16:43:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282559 - 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.20 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: Wed, 06 May 2015 16:43:45 -0000 Author: glebius Date: Wed May 6 16:43:44 2015 New Revision: 282559 URL: https://svnweb.freebsd.org/changeset/base/282559 Log: Printing interface names: o Restore historical behaviour of appending '*' if interface is down, and we have enough space to print it (usually we don't). [1] o Do not truncate interface names when printing in encoded format. o Report interface flags into encoded format. PR: 199873 [1] Sponsored by: Nginx, Inc. Modified: head/usr.bin/netstat/if.c Modified: head/usr.bin/netstat/if.c ============================================================================== --- head/usr.bin/netstat/if.c Wed May 6 16:25:20 2015 (r282558) +++ head/usr.bin/netstat/if.c Wed May 6 16:43:44 2015 (r282559) @@ -315,7 +315,7 @@ intpr(int interval, void (*pfunc)(char * for (ifa = ifap; ifa; ifa = ifa->ifa_next) { bool network = false, link = false; - char *name; + char *name, *xname, buf[IFNAMSIZ+1]; if (interface != NULL && strcmp(ifa->ifa_name, interface) != 0) continue; @@ -341,10 +341,20 @@ intpr(int interval, void (*pfunc)(char * xo_open_instance("interface"); + if ((ifa->ifa_flags & IFF_UP) == 0) { + xname = stpcpy(buf, name); + *xname++ = '*'; + *xname = '\0'; + xname = buf; + } else + xname = name; + if (Wflag) - xo_emit("{tk:name/%-7.7s}", name); + xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%7.7s}", + name, ifa->ifa_flags, xname); else - xo_emit("{tk:name/%-5.5s}", name); + xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%5.5s}", + name, ifa->ifa_flags, xname); #define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu) show_stat("lu", 6, "mtu", IFA_MTU(ifa), IFA_MTU(ifa));