-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Brief description
After applying a new filter with conf.layers.filter()
, all subsequent calls to get_if_addr6
fail with an exception. (ipv4 get_if_addr
continues to work.) This issue occurs for me on Linux and macOS but not on Windows.
Not sure if ipv6 requires some extra undocumented layers to always be enabled or if this is a bug?
Scapy version
2.6.1
Python version
3.10 and 3.11
Operating system
Ubuntu 22.04.5 LTS
Additional environment information
No response
How to reproduce
from scapy.all import conf, IP, IPv6, get_if_addr6
print(get_if_addr6("eth0")) # Works fine
conf.layers.filter([IP, IPv6]) # Filter itself here can be anything, doesn't matter
print(get_if_addr6("eth0")) # Throws exception
Actual result
None
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 480, in __getattr__
fld, v = self.getfield_and_val(attr)
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 475, in getfield_and_val
raise ValueError
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 480, in __getattr__
fld, v = self.getfield_and_val(attr)
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 475, in getfield_and_val
raise ValueError
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/c/Users/wardz/test.py", line 32, in <module>
print(get_if_addr6("eth0")) # Throws exception
File "/usr/local/lib/python3.10/dist-packages/scapy/arch/__init__.py", line 105, in get_if_addr6
return next((x[0] for x in in6_getifaddr()
File "/usr/local/lib/python3.10/dist-packages/scapy/arch/linux/rtnetlink.py", line 846, in in6_getifaddr
ips = _get_ips(af_family=socket.AF_INET6)
File "/usr/local/lib/python3.10/dist-packages/scapy/arch/linux/rtnetlink.py", line 774, in _get_ips
ifindex = msg.ifa_index
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 482, in __getattr__
return self.payload.__getattr__(attr)
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 482, in __getattr__
return self.payload.__getattr__(attr)
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 480, in __getattr__
fld, v = self.getfield_and_val(attr)
File "/usr/local/lib/python3.10/dist-packages/scapy/packet.py", line 1886, in getfield_and_val
raise AttributeError(attr)
AttributeError: ifa_index
Expected result
None
None
Related resources
No response