From a3dc2b79ea70c9f7224f316bf2a93b0af7ed337b Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 1 Oct 2026 00:44:23 +0000 Subject: [PATCH] libpcap: pass positive BIOCIMMEDIATE to ioctl to prevent ioctl from failing with ``` 14115 14115 python3 CALL ioctl(3,0xffffffff80044270,0x7f7fff1415b0) 14115 14115 python3 GIO fd 3 wrote 4 bytes "\^A\0\0\0" 14115 14115 python3 RET ioctl -1 errno 22 Invalid argument ``` and actually turn on immediate mode on 64-bit NetBSD machines. With this patch applied tests waiting for timely replies receive those replies in time in libpcap mode. The negative value was most likely used to get around a bug in Python 2.4 where ioctl failed with ``` OverflowError: signed integer is greater than maximum ``` when the positive value was passed instead. That bug was fixed in Python 2.5 in https://bugs.python.org/issue1231069 and scapy no longer supports Python 2 anyway. AI-Assisted: no --- scapy/arch/libpcap.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scapy/arch/libpcap.py b/scapy/arch/libpcap.py index e24ab131563..4c5b2f00efd 100644 --- a/scapy/arch/libpcap.py +++ b/scapy/arch/libpcap.py @@ -66,8 +66,7 @@ ############ # From BSD net/bpf.h -# BIOCIMMEDIATE = 0x80044270 -BIOCIMMEDIATE = -2147204496 +BIOCIMMEDIATE = 0x80044270 # https://github.com/the-tcpdump-group/libpcap/blob/master/pcap/pcap.h PCAP_IF_UP = 0x00000002 # interface is up