@@ -60,16 +60,23 @@ def flags2str(flags):
6060
6161
6262def show_config (device ):
63- ipaddr = ethtool .get_ipaddr (device )
64- netmask = ethtool .get_netmask (device )
63+ try :
64+ ipaddr = ethtool .get_ipaddr (device )
65+ netmask = ethtool .get_netmask (device )
66+ broadcast = ethtool .get_broadcast (device )
67+ except (IOError , OSError ):
68+ ipaddr , netmask , broadcast = None , None , None
6569 flags = ethtool .get_flags (device )
6670 print ('%s' % device )
6771 if not (flags & ethtool .IFF_LOOPBACK ):
6872 print ('\t HWaddr %s' % ethtool .get_hwaddr (device ))
69- print ('\t inet addr:%s' % ipaddr )
70- if not (flags & (ethtool .IFF_LOOPBACK | ethtool .IFF_POINTOPOINT )):
71- print ('\t Bcast:%s' % ethtool .get_broadcast (device ))
72- print ('\t Mask:%s' % netmask )
73+ if ipaddr is not None :
74+ print ('\t inet addr:%s' % ipaddr )
75+ if broadcast is not None and \
76+ not (flags & (ethtool .IFF_LOOPBACK | ethtool .IFF_POINTOPOINT )):
77+ print ('\t Bcast:%s' % broadcast )
78+ if netmask is not None :
79+ print ('\t Mask:%s' % netmask )
7380 for info in ethtool .get_interfaces_info (device ):
7481 for addr in info .get_ipv6_addresses ():
7582 print ('\t inet6 addr: %s/%s Scope: %s'
0 commit comments