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

test_uuid.test_netstat_getnode() fails on FreeBSD VM: uuid._netstat_getnode() uses IPv6 address as MAC address #84172

Closed
vstinner opened this issue Mar 17, 2020 · 6 comments
Labels
3.9 only security fixes tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 39991
Nosy @warsaw, @vstinner
PRs
  • bpo-39991: uuid._netstat_getnode() ignores IPv6 addresses #19043
  • bpo-39991: Enhance uuid parser for MAC address #19045
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-03-17.17:37:36.319>
    created_at = <Date 2020-03-17.11:27:33.918>
    labels = ['tests', '3.9']
    title = 'test_uuid.test_netstat_getnode() fails on FreeBSD VM: uuid._netstat_getnode() uses IPv6 address as MAC address'
    updated_at = <Date 2020-03-17.17:37:36.318>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-03-17.17:37:36.318>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-17.17:37:36.319>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2020-03-17.11:27:33.918>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39991
    keywords = ['patch']
    message_count = 6.0
    messages = ['364412', '364432', '364435', '364439', '364459', '364460']
    nosy_count = 2.0
    nosy_names = ['barry', 'vstinner']
    pr_nums = ['19043', '19045']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39991'
    versions = ['Python 3.9']

    @vstinner
    Copy link
    Member Author

    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

    @vstinner vstinner added 3.9 only security fixes tests Tests in the Lib/test dir labels Mar 17, 2020
    @vstinner
    Copy link
    Member Author

    New changeset eb886db by Victor Stinner in branch 'master':
    bpo-39991: uuid._netstat_getnode() ignores IPv6 addresses (GH-19043)
    eb886db

    @vstinner
    Copy link
    Member Author

    It seems like this issue is a regression caused by the following change of bpo-28009:

    commit 0bcbfa4
    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:

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    New changeset ebf6bb9 by Victor Stinner in branch 'master':
    bpo-39991: Enhance uuid parser for MAC address (GH-19045)
    ebf6bb9

    @vstinner
    Copy link
    Member Author

    Ok, the new stricter parser should now cover all cases. If not, it should be easier to fix it ;-) I close the issue.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant