Bug #9053
closed
dladm show-phys -P speaks gibberish
Added by Robert Mustacchi over 4 years ago.
Updated over 4 years ago.
Category:
cmd - userland programs
Description
dladm show-phys -P can speak giberish when fields are specified:
[root@haswell ~]# dladm show-phys -o link,speed,speed,speed -P
LINK SPEED SPEED SPEED
igb0 0E��������AE� 0E��������AE� 0E��������AE�
igb2 0E��������AE� 0E��������AE� 0E��������AE�
igb1 0E��������AE� 0E��������AE� 0E��������AE�
igb3 0E��������AE� 0E��������AE� 0E��������AE�
The root cause of this is that we are only initializing fields that are valid for the mode (whether using -P or not). This means that the rest of the structure is stack garbage!
I've opted to fix this by zeroing the structure, which libofmt will then handle correct as the field not being present. The alternative idea I had was to go through and actually limit the valid fields to those that made sense. I have opted to not do that because I was afraid that this might end up breaking things unintentionally that were used to using those fields.
With the fix, we see that this works for lots of different fields whether parsable or not:
[root@haswell ~]# /var/tmp/dladm show-phys -o link,speed,speed,speed -P
LINK SPEED SPEED SPEED
igb0 -- -- --
igb2 -- -- --
igb1 -- -- --
igb3 -- -- --
[root@haswell ~]# /var/tmp/dladm show-phys -o link,speed,speed,speed -P -p
igb0:::
igb2:::
igb1:::
igb3:::
[root@haswell ~]# /var/tmp/dladm show-phys -o link,speed,speed,speed,duplex,media,device,flags -P
LINK SPEED SPEED SPEED DUPLEX MEDIA DEVICE FLAGS
igb0 -- -- -- -- Ethernet igb0 -----
igb2 -- -- -- -- Ethernet igb2 -----
igb1 -- -- -- -- Ethernet igb1 -----
igb3 -- -- -- -- Ethernet igb3 -----
- Status changed from New to Closed
git commit d96b2a3f9d5053d3cd23e2b07b41c272faa5d52a
commit d96b2a3f9d5053d3cd23e2b07b41c272faa5d52a
Author: Robert Mustacchi <rm@joyent.com>
Date: 2018-02-18T17:58:36.000Z
9053 dladm show-phys -P speaks gibberish
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Approved by: Richard Lowe <richlowe@richlowe.net>
Also available in: Atom
PDF