File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -83,14 +83,18 @@ def retrieve_interface_info(mtu_and_indexes)
8383
8484 def extract_mac_address ( interface )
8585 mac = get_bonded_interface_mac ( interface . name )
86- if mac . nil?
87- if Socket . const_defined? :PF_LINK
88- mac = interface . addr &.getnameinfo &.first #sometimes it returns localhost, ip but mac also
89- elsif Socket . const_defined? :PF_PACKET
90- return if interface . addr . nil? || interface . addr . inspect_sockaddr . nil?
91-
92- mac = interface . addr &.inspect_sockaddr [ /hwaddr=([\h :]+)/ , 1 ]
86+ begin
87+ if mac . nil?
88+ if Socket . const_defined? :PF_LINK
89+ mac = interface . addr &.getnameinfo &.first #sometimes it returns localhost, ip but mac also
90+ elsif Socket . const_defined? :PF_PACKET
91+ return if interface . addr . nil? || interface . addr . inspect_sockaddr . nil?
92+
93+ mac = interface . addr &.inspect_sockaddr [ /hwaddr=([\h :]+)/ , 1 ]
94+ end
9395 end
96+ rescue StandardError => e
97+ log . debug ( "Could not read mac, got #{ e } " )
9498 end
9599 mac if !mac . nil? && mac != '00:00:00:00:00:00' && mac =~ /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
96100 end
You can’t perform that action at this time.
0 commit comments