From: bluhm Date: Sun, 29 Jul 2018 09:25:58 +0000 (+0000) Subject: New scapy 2.4.0 buffers packets at the bfp layer. Call sniff() to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=925939b706654eeebe43e597bffe0e97c52fc5a2;p=openbsd New scapy 2.4.0 buffers packets at the bfp layer. Call sniff() to clear this list when starting the sniffer thread. The TCP sequence number check in sr1() became more strict. Use the sniffer thread to capture retransmitted packetes which the new TCP answers() check ignores now. --- diff --git a/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py b/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py index 14c04e399a9..319567cca58 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py +++ b/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py @@ -15,6 +15,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5) @@ -97,8 +101,18 @@ if spliced_payload.urgptr != 11: (11, spliced_payload.urgptr) exit(1) +print "Expect spliced ACK retransmission" +sniffer = Sniff1(); +sniffer.filter = "src %s and dst %s and tcp port %u " \ + "and tcp[tcpflags] = tcp-ack" % (ip.dst, ip.src, server) +sniffer.start() +time.sleep(1) + print "Retransmit spliced SYN+ACK packet to trigger ACK" -spliced_ack_retrans=sr1(ip/spliced_synack, iface=LOCAL_IF) +send(ip/spliced_synack, iface=LOCAL_IF) + +sniffer.join(timeout=7) +spliced_ack_retrans = sniffer.packet if spliced_ack_retrans is None: print "ERROR: No spliced ACK retransmit packet received" diff --git a/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py b/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py index 913b5887fde..00a5dc914b1 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py +++ b/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py @@ -15,6 +15,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5) @@ -97,8 +101,18 @@ if spliced_payload.len-20-20 != len(data): (len(data), spliced_payload.len-20-20) exit(1) +print "Expect spliced ACK retransmission" +sniffer = Sniff1(); +sniffer.filter = "src %s and dst %s and tcp port %u " \ + "and tcp[tcpflags] = tcp-ack" % (ip.dst, ip.src, server) +sniffer.start() +time.sleep(1) + print "Retransmit spliced SYN+ACK packet to trigger ACK" -spliced_ack_retrans=sr1(ip/spliced_synack, iface=LOCAL_IF) +send(ip/spliced_synack, iface=LOCAL_IF) + +sniffer.join(timeout=7) +spliced_ack_retrans = sniffer.packet if spliced_ack_retrans is None: print "ERROR: No spliced ACK retransmit packet received" diff --git a/regress/sys/kern/sosplice/scapy/scapy-handshake.py b/regress/sys/kern/sosplice/scapy/scapy-handshake.py index a10d05293c2..4285e857492 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-handshake.py +++ b/regress/sys/kern/sosplice/scapy/scapy-handshake.py @@ -15,6 +15,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5) diff --git a/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py b/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py index e3803fe12a7..558b468d92b 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py +++ b/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py @@ -16,6 +16,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5) diff --git a/regress/sys/kern/sosplice/scapy/scapy-oobinline.py b/regress/sys/kern/sosplice/scapy/scapy-oobinline.py index 3127d679069..a588d278acf 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-oobinline.py +++ b/regress/sys/kern/sosplice/scapy/scapy-oobinline.py @@ -15,6 +15,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5) diff --git a/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py b/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py index d0903061439..4b58b32c2a1 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py +++ b/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py @@ -16,6 +16,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5) diff --git a/regress/sys/kern/sosplice/scapy/scapy-payload.py b/regress/sys/kern/sosplice/scapy/scapy-payload.py index 4dbd5e84384..1e0e67104af 100644 --- a/regress/sys/kern/sosplice/scapy/scapy-payload.py +++ b/regress/sys/kern/sosplice/scapy/scapy-payload.py @@ -15,6 +15,10 @@ class Sniff1(threading.Thread): filter = None captured = None packet = None + def __init__(self): + # clear packets buffered by scapy bpf + sniff(iface=LOCAL_IF, timeout=1) + super(Sniff1, self).__init__() def run(self): self.captured = sniff(iface=LOCAL_IF, filter=self.filter, count=1, timeout=5)