Project

General

Profile

Actions

Bug #12342

closed

bandwidth display badly formatted in flowstat, dlstat, and dladm

Added by Peter Tribble almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

The output from flowstat -h looks like:

FLOW         START         END           RBYTES   OBYTES   BANDWIDTH
znic0flow    18:43:51      18:44:11      1422     38066    0.015 Mbps
znic0flow    18:44:11      18:44:31      1320     38000    0.015 Mbps
znic0flow    18:44:31      18:44:51      83979    1058232      4.266 Mbp
znic0flow    18:44:51      18:45:11      221124   2470940      9.972 Mbp

There are 2 problems here: the first is that the bandwidth numbers don't line up; the second isthat "Mbps" is truncated to "Mbp".

The number formatting is done by dladm_bw2str() in libdladm. It changes the format (specifically, left padding) depending on the size of the numbers, which is unhelpful. It would be better to use the same format string whether or not it's a leading zero.

The string from dladm_bw2str() is formatted as 5.3, so takes up 9 characters. Add 1 for the space, 4 for MBps and 1 for the terminating null, and the string needs to be sized to take 15 character. It's only 14, which explains why the "s" gets cut off.

The same code and bug appears in dlstat and the show-usage command of dladm.

The other use of dladm_bw2str() is to display the maxbw property in flowadm and dladm. As that property has a minimum value of 1200K, it will never have a leading zero so is unaffected by the problem described here.

Actions

Also available in: Atom PDF