Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-10]: src/usr.bin/netstat Pull up following revision(s) (requested...
details: https://anonhg.NetBSD.org/src/rev/4253e2c2fe71
branches: netbsd-10
changeset: 373009:4253e2c2fe71
user: martin <martin%NetBSD.org@localhost>
date: Thu Jan 12 12:07:23 2023 +0000
description:
Pull up following revision(s) (requested by mrg in ticket #42):
usr.bin/netstat/if.c: revision 1.109
if not given an interface to monitor by default, pick the one
with the most bytes in/out the first time and keep using it.
in addition to picking the most likely intersting interface,
this actually fixes a bug where interfaces coming/going in
the middle of eg, "netstat -b -w 1", may end up showing the
data for another interface on any output line (including the
the header declaring the interface!)
diffstat:
usr.bin/netstat/if.c | 30 ++++++++++++++----------------
1 files changed, 14 insertions(+), 16 deletions(-)
diffs (56 lines):
diff -r 1d5ccb62ed6a -r 4253e2c2fe71 usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c Thu Jan 12 12:05:20 2023 +0000
+++ b/usr.bin/netstat/if.c Thu Jan 12 12:07:23 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.108 2022/12/12 05:09:33 msaitoh Exp $ */
+/* $NetBSD: if.c,v 1.108.2.1 2023/01/12 12:07:23 martin Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: if.c,v 1.108 2022/12/12 05:09:33 msaitoh Exp $");
+__RCSID("$NetBSD: if.c,v 1.108.2.1 2023/01/12 12:07:23 martin Exp $");
#endif
#endif /* not lint */
@@ -1171,7 +1171,11 @@
if_data_ext_get(name, &dext);
- if (interface != NULL && !strcmp(name, interface)) {
+ if ((interface != NULL && !strcmp(name, interface)) ||
+ (interface == NULL &&
+ ((ip_cur.ift_ib + ip_cur.ift_ob) == 0 ||
+ (ip_cur.ift_ib + ip_cur.ift_ob <
+ ifd->ifi_ibytes + ifd->ifi_obytes)))) {
strlcpy(ip_cur.ift_name, name,
sizeof(ip_cur.ift_name));
ip_cur.ift_ip = ifd->ifi_ipackets;
@@ -1197,17 +1201,11 @@
break;
}
}
- if (interface == NULL) {
- strlcpy(ip_cur.ift_name, name,
- sizeof(ip_cur.ift_name));
- ip_cur.ift_ip = ifd->ifi_ipackets;
- ip_cur.ift_ib = ifd->ifi_ibytes;
- ip_cur.ift_ie = ifd->ifi_ierrors;
- ip_cur.ift_op = ifd->ifi_opackets;
- ip_cur.ift_ob = ifd->ifi_obytes;
- ip_cur.ift_oe = ifd->ifi_oerrors;
- ip_cur.ift_co = ifd->ifi_collisions;
- ip_cur.ift_iq = ifd->ifi_iqdrops;
- ip_cur.ift_oq = dext.ifi_oqdrops;
- }
+
+ /*
+ * If we picked an interface, be sure to keep using it for the rest
+ * of this instance.
+ */
+ if (interface == NULL)
+ interface = ip_cur.ift_name;
}
Home |
Main Index |
Thread Index |
Old Index