This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_uuid.test_netstat_getnode() fails on FreeBSD VM: uuid._netstat_getnode() uses IPv6 address as MAC address
Type: Stage: resolved
Components: Tests Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, vstinner
Priority: normal Keywords: patch

Created on 2020-03-17 11:27 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19043 merged vstinner, 2020-03-17 13:17
PR 19045 merged vstinner, 2020-03-17 16:41
Messages (6)
msg364412 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-17 11:27
My FreeBSD VM has a NIC with the IPv6 address fe80::5054:ff:fe9: local-link IPv6 address. It's used by uuid._netstat_getnode() as a MAC address, but it seems like this IPv6 address doesn't respect RFC 4122 and so should be skipped.

_find_mac_under_heading() should reject IPv6 address: only use MAC address.


vstinner@freebsd$ uname -a
FreeBSD freebsd 12.1-RELEASE-p2 FreeBSD 12.1-RELEASE-p2 GENERIC  amd64

======================================================================
FAIL: test_netstat_getnode (test.test_uuid.TestInternalsWithExtModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/vstinner/python/master/Lib/test/test_uuid.py", line 767, in test_netstat_getnode
    self.check_node(node, 'netstat')
  File "/usr/home/vstinner/python/master/Lib/test/test_uuid.py", line 736, in check_node
    self.assertTrue(0 < node < (1 << 48),
AssertionError: False is not true : fe805054fffe9 is not an RFC 4122 node ID

======================================================================
FAIL: test_netstat_getnode (test.test_uuid.TestInternalsWithoutExtModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/vstinner/python/master/Lib/test/test_uuid.py", line 767, in test_netstat_getnode
    self.check_node(node, 'netstat')
  File "/usr/home/vstinner/python/master/Lib/test/test_uuid.py", line 736, in check_node
    self.assertTrue(0 < node < (1 << 48),
AssertionError: False is not true : fe805054fffe9 is not an RFC 4122 node ID



It's using a qemu VM run by virt-manager.

fe805054fffe9 seems to be the MAC address of my vtnet network interface:

vstinner@freebsd$ netstat -ian 
Name    Mtu Network       Address              Ipkts Ierrs Idrop    Opkts Oerrs  Coll
vtnet  1500 <Link#1>      52:54:00:9d:0e:67    10017     0     0     8174     0     0
vtnet     - fe80::%vtnet0 fe80::5054:ff:fe9        0     -     -        4     -     -
vtnet     - 192.168.122.0 192.168.122.45        8844     -     -     8171     -     -
lo0   16384 <Link#2>      lo0                 260148     0     0   260148     0     0
lo0       - ::1/128       ::1                    193     -     -      193     -     -
                          ff01::1%lo0      
                          ff02::2:2eb7:74fa
                          ff02::2:ff2e:b774
                          ff02::1%lo0      
                          ff02::1:ff00:1%lo
lo0       - fe80::%lo0/64 fe80::1%lo0              0     -     -        0     -     -
                          ff01::1%lo0      
                          ff02::2:2eb7:74fa
                          ff02::2:ff2e:b774
                          ff02::1%lo0      
                          ff02::1:ff00:1%lo
lo0       - 127.0.0.0/8   127.0.0.1           259955     -     -   259955     -     -
                          224.0.0.1
msg364432 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-17 14:51
New changeset eb886db1e99a15f15a2342aa496197a5f88fa9c8 by Victor Stinner in branch 'master':
bpo-39991: uuid._netstat_getnode() ignores IPv6 addresses (GH-19043)
https://github.com/python/cpython/commit/eb886db1e99a15f15a2342aa496197a5f88fa9c8
msg364435 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-17 15:12
It seems like this issue is a regression caused by the following change of bpo-28009:

commit 0bcbfa43d55d9558cdcb256d8998366281322080
Author: Michael Felt <aixtools@users.noreply.github.com>
Date:   Thu Sep 26 20:43:15 2019 +0100

    bpo-28009: Fix uuid.uuid1() and uuid.get_node() on AIX (GH-8672)

which replaced:
    if len(word) == 17 and word.count(b':') == 5:
with:
    if len(word) == 17:
msg364439 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-17 15:30
My fix is incomplete: the IPv6 address "123:2:3:4:5:6:7:8" is a valid IPv6 address and uuid.py accepts it as a valid MAC address, whereas it's not a MAC address.
msg364459 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-17 17:36
New changeset ebf6bb9f5ef032d1646b418ebbb645ea0b217da6 by Victor Stinner in branch 'master':
bpo-39991: Enhance uuid parser for MAC address (GH-19045)
https://github.com/python/cpython/commit/ebf6bb9f5ef032d1646b418ebbb645ea0b217da6
msg364460 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-17 17:37
Ok, the new stricter parser should now cover all cases. If not, it should be easier to fix it ;-) I close the issue.
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84172
2020-03-17 17:37:36vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg364460

stage: patch review -> resolved
2020-03-17 17:36:51vstinnersetmessages: + msg364459
2020-03-17 16:41:55vstinnersetpull_requests: + pull_request18396
2020-03-17 15:30:44vstinnersetmessages: + msg364439
2020-03-17 15:12:39vstinnersetmessages: + msg364435
2020-03-17 14:51:49vstinnersetmessages: + msg364432
2020-03-17 13:17:04vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request18394
2020-03-17 11:27:33vstinnercreate