Skip to content

Failure to set promiscuous mode on interface after #4497 #4525

@polybassa

Description

@polybassa

Brief description

Scapy raises the following exception on an external USB interface connected to a RaspberryPI 4.

The internal interface doesn't show this issue.

In [10]: sniff(timeout=1, iface="eth0")
Out[10]: <Sniffed: TCP:598 UDP:0 ICMP:0 Other:0>

In [11]: sniff(timeout=1, iface="eth1")
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[11], line 1
----> 1 sniff(timeout=1, iface="eth1")

File /opt/site-packages/scapy/sendrecv.py:1506, in sniff(*args, **kwargs)
   1502 @conf.commands.register
   1503 def sniff(*args, **kwargs):
   1504     # type: (*Any, **Any) -> PacketList
   1505     sniffer = AsyncSniffer()
-> 1506     sniffer._run(*args, **kwargs)
   1507     return cast(PacketList, sniffer.results)

File /opt/site-packages/scapy/sendrecv.py:1350, in AsyncSniffer._run(self, count, store, offline, quiet, prn, lfilter, L2socket, timeout, opened_socket, stop_filter, iface, started_callback, session, chainCC, **karg)
   1348     else:
   1349         iface = iface or conf.iface
-> 1350         sniff_sockets[_RL2(iface)(type=ETH_P_ALL, iface=iface,
   1351                                   **karg)] = iface
   1353 # Get select information from the sockets
   1354 _main_socket = next(iter(sniff_sockets))

File /opt/site-packages/scapy/arch/linux/__init__.py:235, in L2Socket.__init__(self, iface, type, promisc, filter, nofilter, monitor)
    233             raise Scapy_Exception("Cannot set filter: %s" % ex)
    234 if self.promisc:
--> 235     set_promisc(self.ins, self.iface)
    236 self.ins.bind((self.iface, type))
    237 _flush_fd(self.ins.fileno())

File /opt/site-packages/scapy/arch/linux/__init__.py:146, in set_promisc(s, iff, val)
    144 _iff = resolve_iface(iff)
    145 if not _iff.is_valid():
--> 146     raise OSError("set_promisc: Unknown interface %s" % iff)
    147 mreq = struct.pack("IHH8s", _iff.index, PACKET_MR_PROMISC, 0, b"")
    148 if val:

OSError: set_promisc: Unknown interface eth1

However, tcpdump can set promisc mode on this interface

In [12]: !tcpdump -i eth1
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel

KeyboardInterrupt

Also dmesg proofs this:

[  353.148778] bcmgenet fd580000.ethernet eth0: entered promiscuous mode
[  354.167830] bcmgenet fd580000.ethernet eth0: left promiscuous mode
[  375.349857] cdc_ncm 2-1:2.0 eth1: entered promiscuous mode
[  377.147713] cdc_ncm 2-1:2.0 eth1: left promiscuous mode

The first promisc enter was done by scapy, the second by tcpdump

Scapy version

32c79ba

Python version

3.11.2

Operating system

6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian

Additional environment information

No response

How to reproduce

I'm calling sniff on an USB-to-ETH adapter

Actual result

No response

Expected result

No response

Related resources

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions