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_getnode and test_windll_getnode fail if connected to the Internet via an Android phone
Type: behavior Stage: patch review
Components: Tests Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Ivan.Pozdeev, __Vano, barry, serhiy.storchaka, xdegaye
Priority: normal Keywords:

Created on 2017-09-29 21:37 by Ivan.Pozdeev, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 4448 closed Ivan.Pozdeev, 2017-11-18 03:39
PR 4804 closed Ivan.Pozdeev, 2017-12-12 00:00
Messages (7)
msg303360 - (view) Author: Ivan Pozdeev (Ivan.Pozdeev) * Date: 2017-09-29 21:37
Ethernet emulation for some devices like Android phones' tethering use all-zero MAC addresses (which is okay since they don't actually pass Ethernet frames to other NICs). This results in a node ID of 0 if I'm currently connected to the Net via such a device. Which fails range checks in the corresponding tests.

RFC 4122 doesn't actually have any prohibitions of using a node ID of 0. Neither does IEEE 802.3 (or rather, whatever info I gathered on it since the standard's text is not freely available) assign any special meaning to an all-zero MAC address.

The patch also corrects the check call in test_windll_getnode since the tested function always generates UUID from a MAC address.
msg303373 - (view) Author: Ivan Pozdeev (Ivan.Pozdeev) * Date: 2017-09-29 23:30
Example failure:

======================================================================
FAIL: test_windll_getnode (test.test_uuid.TestInternals)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Ivan\cpython\lib\test\test_uuid.py", line 501, in test_windll_getnode

    self.check_node(node)
  File "C:\Ivan\cpython\lib\test\test_uuid.py", line 449, in check_node
    "%s is not an RFC 4122 node ID" % hex)
AssertionError: False is not true : 000000000000 is not an RFC 4122 node ID

======================================================================
FAIL: test_getnode (test.test_uuid.TestUUID)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Ivan\cpython\lib\test\test_uuid.py", line 296, in test_getnode
    self.assertTrue(0 < node1 < (1 << 48), '%012x' % node1)
AssertionError: False is not true : 000000000000
msg308097 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2017-12-12 09:01
On a Samsung device with Android 5.1 and tethering enabled, only one network device has a MAC address and it is not an all-zero MAC address.

Ivan can you please provide more information about this problem: which device, what Android version, what is the output of 'ip link' ?
msg308100 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-12 09:39
I'm not sure that 000000000000 is better than a random address. Even if an all-zero MAC address is not explicitly prohibited it is used in a multiple independent devices. A random address looks more appropriate fore the purpose of generating a UUID.
msg308104 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2017-12-12 10:21
> I'm not sure that 000000000000 is better than a random address.

I agree, getnode() when obtained from a MAC address should not return 0.

RFC 4122 states (emphasis on 'uniqueness' is mine):

This document specifies three algorithms to generate UUIDs: the
      first leverages the unique values of 802 MAC addresses to
      guarantee *uniqueness*, ...
msg308152 - (view) Author: Ivan Pozdeev (__Vano) Date: 2017-12-12 21:28
> Xavier de Gaye <xdegaye@gmail.com> added the comment:
>
> On a Samsung device with Android 5.1 and tethering enabled, only one network device has a MAC address and it is not an all-zero MAC address.
>
> Ivan can you please provide more information about this problem: which device, what Android version, what is the output of 'ip link' ?

C:\> ipconfig -all
<...>
Samsung Galaxy S7 - Ethernet адаптер:

         DNS-суффикс этого подключения . . :
         Описание  . . . . . . . . . . . . : Android USB Ethernet/RNDIS
         Физический адрес. . . . . . . . . : 00-00-00-00-00-00
         Dhcp включен. . . . . . . . . . . : да
         Автонастройка включена  . . . . . : да
         IP-адрес  . . . . . . . . . . . . : 192.168.42.2
         Маска подсети . . . . . . . . . . : 255.255.255.0
         Основной шлюз . . . . . . . . . . : 192.168.42.129
         DHCP-сервер . . . . . . . . . . . : 192.168.42.129
         DNS-серверы . . . . . . . . . . . : 192.168.42.129

Device name: Samsung Galaxy S7
Model number: SM-G930F
Android version: 6.0.1
Firmware version: G930FXXU1APGJ
Baseband version: G930VVRS4APH1
Build number: MMB29M.G930VVRU2APG5

> Serhiy Storchaka<storchaka+cpython@gmail.com>  added the comment:
>
> I'm not sure that 000000000000 is better than a random address. Even if an all-zero MAC address is not explicitly prohibited it is used in a multiple independent devices. A random address looks more appropriate fore the purpose of generating a UUID.
The question is not whether it's good UUID source material. The 
question, for the purpose of the test, is whether it's valid getnode() 
output -- which it is for the current logic.
msg308194 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2017-12-13 09:33
> C:\> ipconfig -all

So the all-zero MAC address occurs on a Windows box and that explains the test_windll_getnode failure (this test is skipped on Android). I missed that point in your initial post and knowing what Android device you are using is irrelevant.
History
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75824
2021-06-14 21:55:20iritkatrielsetkeywords: - patch
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
2017-12-13 09:33:22xdegayesetmessages: + msg308194
2017-12-12 21:28:07__Vanosetnosy: + __Vano
messages: + msg308152
2017-12-12 10:21:25xdegayesetmessages: + msg308104
2017-12-12 09:39:32serhiy.storchakasetmessages: + msg308100
2017-12-12 09:01:01xdegayesetmessages: + msg308097
2017-12-12 02:17:53Ivan.Pozdeevsetfiles: - 0001-Allow-for-all-zero-MAC-based-node-ID-e.g.-mobile-mod.patch
2017-12-12 00:00:54Ivan.Pozdeevsetpull_requests: + pull_request4701
2017-12-11 19:52:44serhiy.storchakasetnosy: + barry, xdegaye, serhiy.storchaka
2017-11-18 03:39:21Ivan.Pozdeevsetstage: patch review
pull_requests: + pull_request4387
2017-09-29 23:30:48Ivan.Pozdeevsetmessages: + msg303373
2017-09-29 21:37:18Ivan.Pozdeevcreate