Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac address reporting is probably wrong on Linux #786

Closed
grrrrrrrrr opened this issue Mar 2, 2016 · 11 comments
Closed

Mac address reporting is probably wrong on Linux #786

grrrrrrrrr opened this issue Mar 2, 2016 · 11 comments

Comments

@grrrrrrrrr
Copy link

Hey,

I'm trying to update to v4.0.0 and I get test failures for the test_net_if_addrs_ips test. This is the assertion error:

FAIL: test_net_if_addrs_ips (psutil.tests.test_linux.TestSystemNetwork)

Traceback (most recent call last):
File "psutil/tests/test_linux.py", line 334, in test_net_if_addrs_ips
self.assertEqual(addr.address, get_mac_address(name))
AssertionError: '0b:6a:f2:c2' != '0b:6a:f2:c2:00:00'

In ifconfig, the offending HWaddr looks like this:

Link encap:UNSPEC HWaddr 0B-6A-F2-C2-00-00-00-00-00-00-00-00-00-00-00-00

I'm not sure what the value should be but to me it seems that the test function returning "0b:6a:f2:c2:00:00" might be correct? In any case, it would be good if the two functions agreed :)

@giampaolo
Copy link
Owner

Mmm I don't know much about IPv6 addresses but perhaps '0b:6a:f2:c2' and '0b:6a:f2:c2:00:00' are the same? In that case this would be a test issue.

@grrrrrrrrr
Copy link
Author

Note that this is a HW address, not IPv6. It's probably not a MAC address either (sorry, I'm not an expert here) - it has link encap: unspec, not ethernet, so it's a different class.

It's still a hardware address but the assumption that it's exactly 6 bytes is not valid.

Maybe the correct solution here is to ignore encap unspec addresses entirely?

@giampaolo
Copy link
Owner

Ah right sorry, it's a MAC address (I got confused). What about ifconfig -a? Does it fill the missing bits with null bytes? Can you paste the output?

@giampaolo
Copy link
Owner

I should have fixed this. Can you try latest GIT version?

@grrrrrrrrr
Copy link
Author

Thanks, impressively fast response!

Your commit fixed that one issue, I have another one though. Sorry, some of our machines have weird network setup:

psutil mac output:

eth0:00:1a:11:40:3a:e6
gre0:0a:6b:9b:d4:00:00
gretap0:00:00:00:00:00:00
ip6gre0:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
ip6tnl0:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
sixdecap0:0a:6b:9b:d4:00:00

ifconfig -a:

eth0 Link encap:Ethernet HWaddr 00:1a:11:40:3a:e6
gre0 Link encap:UNSPEC HWaddr 0A-6B-9B-D4-36-00-32-30-00-00-00-00-00-00-00-00
gretap0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
ip6gre0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
ip6tnl0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
sixdecap0 Link encap:UNSPEC HWaddr 0A-6B-9B-D4-00-00-32-30-00-00-00-00-00-00-00-00

so it seems like psutil loses information on gre0 and sixdecap0? in any case, the test function always gets exactly 6 bytes so the test passes for gre0 and sixdecap0 (even though psutil is probably wrong) but fails for ip6gre0 and ip6tnl0 where psutil agrees with ipconfig.

The other bug was much more important than this small issue here now, thanks for fixing that one!

@giampaolo
Copy link
Owner

Mmmm... but is that the actual ifconfig -a output? Please past that one.

@grrrrrrrrr
Copy link
Author

Sent you a mail with more debugging info. Thanks for investigating this!

@giampaolo
Copy link
Owner

Mmm.. it seems the problem only occurs with those Link encap:UNSPEC NICs, which I'm not sure what they are (it also says NOARP and POINTTOPOINT). I would say we can ignore them.

@mrjefftang
Copy link
Collaborator

Those look like virtual interfaces for tunneling (GRE, 6to4, etc).

@grrrrrrrrr
Copy link
Author

Yes, they probably are. Do you know what the correct value would be to report for HWaddr in that case?

@mrjefftang
Copy link
Collaborator

Matching the system tool such as ifconfig is probably best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants