svn commit: r282559 - head/usr.bin/netstat
Gleb Smirnoff
glebius at FreeBSD.org
Wed May 6 16:43:45 UTC 2015
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));
More information about the svn-src-all
mailing list