diff options
author | Li-Wen Hsu <lwhsu@FreeBSD.org> | 2019-11-06 17:56:47 +0000 |
---|---|---|
committer | Li-Wen Hsu <lwhsu@FreeBSD.org> | 2019-11-06 17:56:47 +0000 |
commit | e81a369361a2b0d77c57cfae8416c119b8aa4878 (patch) | |
tree | bf0381d8be12307d300a678f451ec85200799153 | |
parent | Update to 5.1.18 (diff) |
Add a patch which fixes both the alignment on (32bit) platforms where
sizeof(long) == 4 and for i386 the offset on the bpf_hdr struct as time_t
still is 32bit.
PR: 239380
Approved by: bofh (maintainer)
Sponsored by: Netflix (bz)
Sponsored by: The FreeBSD Foundation (lwhsu)
Notes
Notes:
svn path=/head/; revision=516910
-rw-r--r-- | net/scapy/Makefile | 2 | ||||
-rw-r--r-- | net/scapy/files/patch-i386 | 50 |
2 files changed, 51 insertions, 1 deletions
diff --git a/net/scapy/Makefile b/net/scapy/Makefile index 8a61bd65c17e..e440ba097f19 100644 --- a/net/scapy/Makefile +++ b/net/scapy/Makefile @@ -3,7 +3,7 @@ PORTNAME= scapy PORTVERSION= 2.4.3 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net python MASTER_SITES= CHEESESHOP PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} diff --git a/net/scapy/files/patch-i386 b/net/scapy/files/patch-i386 new file mode 100644 index 000000000000..4304154f7d6d --- /dev/null +++ b/net/scapy/files/patch-i386 @@ -0,0 +1,50 @@ +--- scapy/arch/bpf/supersocket.py.orig 2019-07-29 18:49:37 UTC ++++ scapy/arch/bpf/supersocket.py +@@ -4,9 +4,11 @@ + Scapy *BSD native support - BPF sockets + """ + ++from ctypes import c_long, sizeof + import errno + import fcntl + import os ++import platform + from select import select + import struct + import time +@@ -23,7 +25,10 @@ from scapy.supersocket import SuperSocket + from scapy.compat import raw + + +-if FREEBSD or NETBSD: ++if FREEBSD: ++ # On 32bit architectures long might be 32bit. ++ BPF_ALIGNMENT = sizeof(c_long) ++elif NETBSD: + BPF_ALIGNMENT = 8 # sizeof(long) + else: + BPF_ALIGNMENT = 4 # sizeof(int32_t) +@@ -260,8 +265,21 @@ class L2bpfListenSocket(_L2bpfSocket): + return + + # Extract useful information from the BPF header +- if FREEBSD or NETBSD: +- # struct bpf_xhdr or struct bpf_hdr32 ++ if FREEBSD: ++ # Unless we set BIOCSTSTAMP to something different than BPF_T_MICROTIME ++ # we will get bpf_hdr on FreeBSD, which means that we'll get a ++ # struct timeval, which is time_t, suseconds_t. ++ # On i386 time_t still is 32bit so the bh_tstamp will only be 8 bytes. ++ # We really want to set BIOCSTSTAMP to BPF_T_NANOTIME and be done with this ++ # and it always be 16? ++ if platform.machine() == "i386": ++ # struct bpf_hdr ++ bh_tstamp_offset = 8 ++ else: ++ # struct bpf_hdr (64bit time_t) or struct bpf_xhdr ++ bh_tstamp_offset = 16 ++ elif NETBSD: ++ # struct bpf_hdr or struct bpf_hdr32 + bh_tstamp_offset = 16 + else: + # struct bpf_hdr |