New scapy 2.4.0 buffers packets at the bfp layer. Call sniff() to
authorbluhm <bluhm@openbsd.org>
Sun, 29 Jul 2018 09:25:58 +0000 (09:25 +0000)
committerbluhm <bluhm@openbsd.org>
Sun, 29 Jul 2018 09:25:58 +0000 (09:25 +0000)
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.

regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py
regress/sys/kern/sosplice/scapy/scapy-delay-synack.py
regress/sys/kern/sosplice/scapy/scapy-handshake.py
regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py
regress/sys/kern/sosplice/scapy/scapy-oobinline.py
regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py
regress/sys/kern/sosplice/scapy/scapy-payload.py

index 14c04e3..319567c 100644 (file)
@@ -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"
index 913b588..00a5dc9 100644 (file)
@@ -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"
index a10d052..4285e85 100644 (file)
@@ -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)
index e3803fe..558b468 100644 (file)
@@ -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)
index 3127d67..a588d27 100644 (file)
@@ -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)
index d090306..4b58b32 100644 (file)
@@ -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)
index 4dbd5e8..1e0e671 100644 (file)
@@ -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)