Bug #12342
closedbandwidth display badly formatted in flowstat, dlstat, and dladm
100%
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.
Updated by Peter Tribble almost 3 years ago
Testing:
Testing:
That the following are fixed:
flowstat -h -f /var/log/net.log znic0flow
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 Mbps znic0flow 18:44:51 18:45:11 221124 2470940 9.972 Mbps
and likewise for the other variants:
flowstat -h -f /var/log/net.log
dlstat show-link -h -f /var/log/net.log e1000g0
dlstat show-link -h -f /var/log/net.log
dladm show-usage -f /var/log/net.log e1000g0
dladm show-usage -f /var/log/net.log
Furthermore, verified that the following are unchanged:
flowadm show-flowprop
dladm show-linkprop -p maxbw
Updated by Electric Monk almost 3 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
git commit 3d349c3119b5b6e21daba1ce004cf4625b25d67f
commit 3d349c3119b5b6e21daba1ce004cf4625b25d67f Author: Peter Tribble <peter.tribble@gmail.com> Date: 2020-03-04T07:34:59.000Z 12342 bandwidth display badly formatted in flowstat, dlstat, and dladm Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Robert Mustacchi <rm@fingolfin.org>