summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Tribble <peter.tribble@gmail.com>2020-02-27 10:05:51 +0000
committerPeter Tribble <peter.tribble@gmail.com>2020-03-04 07:34:59 +0000
commit3d349c3119b5b6e21daba1ce004cf4625b25d67f (patch)
tree1e2477b9303b449f3996efffdfc9b70e33a2d40c
parent9dc2843d4266243e87f5d9de7a90b86235a6da08 (diff)
downloadillumos-joyent-3d349c3119b5b6e21daba1ce004cf4625b25d67f.tar.gz
12342 bandwidth display badly formatted in flowstat, dlstat, and dladm
Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r--usr/src/cmd/dladm/dladm.c9
-rw-r--r--usr/src/cmd/dlstat/dlstat.c26
-rw-r--r--usr/src/cmd/flowstat/flowstat.c16
-rw-r--r--usr/src/lib/libdladm/common/libdladm.c44
4 files changed, 52 insertions, 43 deletions
diff --git a/usr/src/cmd/dladm/dladm.c b/usr/src/cmd/dladm/dladm.c
index 85ddea3c38..adb04d1d12 100644
--- a/usr/src/cmd/dladm/dladm.c
+++ b/usr/src/cmd/dladm/dladm.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc.
+ * Copyright 2020 Peter Tribble.
*/
#include <stdio.h>
@@ -1117,7 +1118,7 @@ typedef struct usage_fields_buf_s {
char usage_rbytes[10];
char usage_opackets[9];
char usage_obytes[10];
- char usage_bandwidth[14];
+ char usage_bandwidth[15];
} usage_fields_buf_t;
static const ofmt_field_t usage_fields[] = {
@@ -1133,7 +1134,7 @@ static const ofmt_field_t usage_fields[] = {
offsetof(usage_fields_buf_t, usage_opackets), print_default_cb},
{ "OBYTES", 11,
offsetof(usage_fields_buf_t, usage_obytes), print_default_cb},
-{ "BANDWIDTH", 15,
+{ "BANDWIDTH", 16,
offsetof(usage_fields_buf_t, usage_bandwidth), print_default_cb},
{ NULL, 0, 0, NULL}}
;
@@ -1149,7 +1150,7 @@ typedef struct usage_l_fields_buf_s {
char usage_l_etime[13];
char usage_l_rbytes[8];
char usage_l_obytes[8];
- char usage_l_bandwidth[14];
+ char usage_l_bandwidth[15];
} usage_l_fields_buf_t;
static const ofmt_field_t usage_l_fields[] = {
@@ -1164,7 +1165,7 @@ static const ofmt_field_t usage_l_fields[] = {
offsetof(usage_l_fields_buf_t, usage_l_rbytes), print_default_cb},
{ "OBYTES", 9,
offsetof(usage_l_fields_buf_t, usage_l_obytes), print_default_cb},
-{ "BANDWIDTH", 15,
+{ "BANDWIDTH", 16,
offsetof(usage_l_fields_buf_t, usage_l_bandwidth), print_default_cb},
{ NULL, 0, 0, NULL}}
;
diff --git a/usr/src/cmd/dlstat/dlstat.c b/usr/src/cmd/dlstat/dlstat.c
index 63e844a895..915c2196d1 100644
--- a/usr/src/cmd/dlstat/dlstat.c
+++ b/usr/src/cmd/dlstat/dlstat.c
@@ -27,6 +27,10 @@
* Copyright 2017 Joyent, Inc.
*/
+/*
+ * Copyright 2020 Peter Tribble.
+ */
+
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
@@ -414,7 +418,7 @@ typedef struct history_fields_buf_s {
char h_rbytes[10];
char h_opackets[9];
char h_obytes[10];
- char h_bandwidth[14];
+ char h_bandwidth[15];
} history_fields_buf_t;
static ofmt_field_t history_fields[] = {
@@ -430,7 +434,7 @@ static ofmt_field_t history_fields[] = {
offsetof(history_fields_buf_t, h_opackets), print_default_cb},
{ "OBYTES", 11,
offsetof(history_fields_buf_t, h_obytes), print_default_cb},
-{ "BANDWIDTH", 15,
+{ "BANDWIDTH", 16,
offsetof(history_fields_buf_t, h_bandwidth), print_default_cb},
{ NULL, 0, 0, NULL}};
@@ -443,7 +447,7 @@ typedef struct history_l_fields_buf_s {
char hl_etime[13];
char hl_rbytes[8];
char hl_obytes[8];
- char hl_bandwidth[14];
+ char hl_bandwidth[15];
} history_l_fields_buf_t;
static ofmt_field_t history_l_fields[] = {
@@ -458,7 +462,7 @@ static ofmt_field_t history_l_fields[] = {
offsetof(history_l_fields_buf_t, hl_rbytes), print_default_cb},
{ "OBYTES", 9,
offsetof(history_l_fields_buf_t, hl_obytes), print_default_cb},
-{ "BANDWIDTH", 15,
+{ "BANDWIDTH", 16,
offsetof(history_l_fields_buf_t, hl_bandwidth), print_default_cb},
{ NULL, 0, 0, NULL}}
;
@@ -566,7 +570,7 @@ show_history_time(dladm_usage_t *history, void *arg)
{
show_history_state_t *state = arg;
char buf[DLADM_STRSIZE];
- history_l_fields_buf_t ubuf;
+ history_l_fields_buf_t ubuf;
time_t time;
double bw;
dladm_status_t status;
@@ -751,7 +755,7 @@ do_show_history(int argc, char *argv[], const char *use)
die("show-link -h requires a file");
if (optind == (argc-1)) {
- uint32_t flags;
+ uint32_t flags;
resource = argv[optind];
if (!state.hs_showall &&
@@ -1494,7 +1498,7 @@ static int
show_queried_stats(dladm_handle_t dh, datalink_id_t linkid, void *arg)
{
show_state_t *state = arg;
- int i;
+ int i;
dladm_stat_chain_t *diff_stat;
char linkname[DLPI_LINKNAME_MAX];
@@ -1639,7 +1643,7 @@ do_show(int argc, char *argv[], const char *use)
ofmt_handle_t ofmt;
ofmt_status_t oferr;
uint_t ofmtflags = OFMT_RIGHTJUST;
- ofmt_field_t *oftemplate;
+ ofmt_field_t *oftemplate;
bzero(&state, sizeof (state));
opterr = 0;
@@ -1840,7 +1844,7 @@ do_show_phys(int argc, char *argv[], const char *use)
ofmt_handle_t ofmt;
ofmt_status_t oferr;
uint_t ofmtflags = OFMT_RIGHTJUST;
- ofmt_field_t *oftemplate;
+ ofmt_field_t *oftemplate;
bzero(&state, sizeof (state));
opterr = 0;
@@ -2022,7 +2026,7 @@ do_show_link(int argc, char *argv[], const char *use)
ofmt_handle_t ofmt;
ofmt_status_t oferr;
uint_t ofmtflags = OFMT_RIGHTJUST;
- ofmt_field_t *oftemplate;
+ ofmt_field_t *oftemplate;
bzero(&state, sizeof (state));
opterr = 0;
@@ -2227,7 +2231,7 @@ do_show_aggr(int argc, char *argv[], const char *use)
ofmt_handle_t ofmt;
ofmt_status_t oferr;
uint_t ofmtflags = OFMT_RIGHTJUST;
- ofmt_field_t *oftemplate;
+ ofmt_field_t *oftemplate;
bzero(&state, sizeof (state));
opterr = 0;
diff --git a/usr/src/cmd/flowstat/flowstat.c b/usr/src/cmd/flowstat/flowstat.c
index edfc844a94..23e973c8a2 100644
--- a/usr/src/cmd/flowstat/flowstat.c
+++ b/usr/src/cmd/flowstat/flowstat.c
@@ -31,6 +31,10 @@
* Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
*/
+/*
+ * Copyright 2020 Peter Tribble.
+ */
+
#include <stdio.h>
#include <locale.h>
#include <stdarg.h>
@@ -139,7 +143,7 @@ typedef struct history_fields_buf_s {
char history_rbytes[10];
char history_opackets[9];
char history_obytes[10];
- char history_bandwidth[14];
+ char history_bandwidth[15];
} history_fields_buf_t;
static ofmt_field_t history_fields[] = {
@@ -156,7 +160,7 @@ static ofmt_field_t history_fields[] = {
offsetof(history_fields_buf_t, history_opackets), print_default_cb},
{ "OBYTES", 11,
offsetof(history_fields_buf_t, history_obytes), print_default_cb},
-{ "BANDWIDTH", 15,
+{ "BANDWIDTH", 16,
offsetof(history_fields_buf_t, history_bandwidth), print_default_cb},
NULL_OFMT}
;
@@ -167,7 +171,7 @@ typedef struct history_l_fields_buf_s {
char history_l_etime[13];
char history_l_rbytes[8];
char history_l_obytes[8];
- char history_l_bandwidth[14];
+ char history_l_bandwidth[15];
} history_l_fields_buf_t;
static ofmt_field_t history_l_fields[] = {
@@ -182,7 +186,7 @@ static ofmt_field_t history_l_fields[] = {
offsetof(history_l_fields_buf_t, history_l_rbytes), print_default_cb},
{ "OBYTES", 9,
offsetof(history_l_fields_buf_t, history_l_obytes), print_default_cb},
-{ "BANDWIDTH", 15,
+{ "BANDWIDTH", 16,
offsetof(history_l_fields_buf_t, history_l_bandwidth),
print_default_cb},
NULL_OFMT}
@@ -544,7 +548,7 @@ dump_all_flow_stats(dladm_flow_attr_t *attrp, void *arg, datalink_id_t linkid,
int
main(int argc, char *argv[])
{
- dladm_status_t status;
+ dladm_status_t status;
int option;
boolean_t r_arg = B_FALSE;
boolean_t t_arg = B_FALSE;
@@ -782,7 +786,7 @@ show_history_time(dladm_usage_t *history, void *arg)
{
show_history_state_t *state = (show_history_state_t *)arg;
char buf[DLADM_STRSIZE];
- history_l_fields_buf_t ubuf;
+ history_l_fields_buf_t ubuf;
time_t time;
double bw;
dladm_flow_attr_t attr;
diff --git a/usr/src/lib/libdladm/common/libdladm.c b/usr/src/lib/libdladm/common/libdladm.c
index 81d3fb2990..d62f59218b 100644
--- a/usr/src/lib/libdladm/common/libdladm.c
+++ b/usr/src/lib/libdladm/common/libdladm.c
@@ -26,6 +26,10 @@
* Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
*/
+/*
+ * Copyright 2020 Peter Tribble.
+ */
+
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
@@ -66,23 +70,23 @@ static media_type_t media_type_table[] = {
{ DL_HDLC, "HDLC" },
{ DL_CHAR, "SyncCharacter" },
{ DL_CTCA, "CTCA" },
- { DL_FDDI, "FDDI" },
- { DL_FC, "FiberChannel" },
- { DL_ATM, "ATM" },
- { DL_IPATM, "ATM(ClassicIP)" },
- { DL_X25, "X.25" },
- { DL_IPX25, "X.25(ClassicIP)" },
- { DL_ISDN, "ISDN" },
- { DL_HIPPI, "HIPPI" },
- { DL_100VG, "100BaseVGEthernet" },
- { DL_100VGTPR, "100BaseVGTokenRing" },
- { DL_ETH_CSMA, "IEEE802.3" },
- { DL_100BT, "100BaseT" },
- { DL_FRAME, "FrameRelay" },
- { DL_MPFRAME, "MPFrameRelay" },
- { DL_ASYNC, "AsyncCharacter" },
- { DL_IPNET, "IPNET" },
- { DL_OTHER, "Other" }
+ { DL_FDDI, "FDDI" },
+ { DL_FC, "FiberChannel" },
+ { DL_ATM, "ATM" },
+ { DL_IPATM, "ATM(ClassicIP)" },
+ { DL_X25, "X.25" },
+ { DL_IPX25, "X.25(ClassicIP)" },
+ { DL_ISDN, "ISDN" },
+ { DL_HIPPI, "HIPPI" },
+ { DL_100VG, "100BaseVGEthernet" },
+ { DL_100VGTPR, "100BaseVGTokenRing" },
+ { DL_ETH_CSMA, "IEEE802.3" },
+ { DL_100BT, "100BaseT" },
+ { DL_FRAME, "FrameRelay" },
+ { DL_MPFRAME, "MPFrameRelay" },
+ { DL_ASYNC, "AsyncCharacter" },
+ { DL_IPNET, "IPNET" },
+ { DL_OTHER, "Other" }
};
#define MEDIATYPECOUNT (sizeof (media_type_table) / sizeof (media_type_t))
@@ -575,11 +579,7 @@ dladm_bw2str(int64_t bw, char *buf)
kbps = (bw%1000000)/1000;
mbps = bw/1000000;
if (kbps != 0) {
- if (mbps == 0)
- (void) snprintf(buf, DLADM_STRSIZE, "0.%03u", kbps);
- else
- (void) snprintf(buf, DLADM_STRSIZE, "%5u.%03u", mbps,
- kbps);
+ (void) snprintf(buf, DLADM_STRSIZE, "%5u.%03u", mbps, kbps);
} else {
(void) snprintf(buf, DLADM_STRSIZE, "%5u", mbps);
}