Open bmxp opened 7 months ago
The Error comes from ifaddresses(interface)[AF_INET]
and AF_INET is a constant with the value of 2.
This looks like the system has no ipv4 address.
Does it happen directly after a system start and the ip stack is not completely initialized? Can it be, that no dhcp address is assigned to the system yet?
If we just catch the error, should the function just return an empty list?
Hm. No. The basic system ist running for some weeks now and I do have an IP4 adress. Yesterday the error occurred twice while using the admin interface (looking at logics, logs and items)
I caught the exception and log a warning. Could you elaborate on your environment (os, python version, ...)?
This is the log entry:
2024-04-24 19:14:23 WARNING lib.utils get_all_local_ipv4_addresses: Exception 2 - {17: [{'addr': '06:af:73:fe:f7:11', 'broadcast': 'ff:ff:ff:ff:ff:ff'}]}
Running Python 3.9.2 on Linux (5.10.0-27-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64 GNU/Linux)
Ok, there seems to be an interface that has no ipv4 address (AF_INET, which is 2) and no ipv6 address (AF_INET6, which is 10)
I added further info to the logging. Could you test again and post the (multiline) log entry?
This results in:
2024-04-26 06:54:56 WARNING lib.utils get_all_local_ipv4_addresses: Exception 2
- interfaces=['lo', 'eno1', 'wlo2']
-act. interface=wlo2
-act. interface data={'lo': {17: [{'addr': '00:00:00:00:00:00', 'peer': '00:00:00:00:00:00'}], 2: [{'addr': '127.0.0.1', 'netmask': '255.0.0.0', 'peer': '127.0.0.1'}], 10: [{'addr': '::1', 'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128'}]}, 'eno1': {17: [{'addr': '1c:69:7a:a4:9c:0d', 'broadcast': 'ff:ff:ff:ff:ff:ff'}], 2: [{'addr': '192.168.20.13', 'netmask': '255.255.255.0', 'broadcast': '192.168.20.255'}], 10: [{'addr': 'fe80::1e69:7aff:fea4:9c0d%eno1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]}, 'wlo2': {17: [{'addr': 'da:81:02:8b:0d:37', 'broadcast': 'ff:ff:ff:ff:ff:ff'}]}}
- {17: [{'addr': 'da:81:02:8b:0d:37', 'broadcast': 'ff:ff:ff:ff:ff:ff'}]}
I have pushed a fix (and removed the logging)
There seems to be a bug in
Utils.get_all_local_ipv4_addresses()
I just can not really reproduce it, it's very rare and I do not find any reason when it comes up. Since it is just a KeyError we could catch it probably very easy...