summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-11-08 22:14:03 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-11-08 22:14:03 +0000
commita9392bee992b09db510caf70359a76f0ccbf9182 (patch)
treef2ac3b2b4f10396970cc0b2b6460bd7ad004283a
parent2ab98b1befd66a7f4cab183690ee83dfddf29be3 (diff)
Wait for the splicing syscall by grepping it in the relay log. This
ensures that scapy's SYN+ACK packet hits the TCP stack when it hurts.
-rw-r--r--regress/sys/kern/sosplice/funcs.pl6
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py13
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py13
3 files changed, 30 insertions, 2 deletions
diff --git a/regress/sys/kern/sosplice/funcs.pl b/regress/sys/kern/sosplice/funcs.pl
index 75856ce6600..43d484ae5a0 100644
--- a/regress/sys/kern/sosplice/funcs.pl
+++ b/regress/sys/kern/sosplice/funcs.pl
@@ -1,6 +1,6 @@
-# $OpenBSD: funcs.pl,v 1.8 2016/05/03 19:13:04 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.9 2017/11/08 22:14:02 bluhm Exp $
-# Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org>
+# Copyright (c) 2010-2017 Alexander Bluhm <bluhm@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -331,6 +331,7 @@ sub relay_splice_stream {
my $splicemax = $max ? $max - $len : 0;
setsplice(\*STDIN, \*STDOUT, $splicemax, $idle)
or die ref($self), " splice stdin to stdout failed: $!";
+ print STDERR "Spliced\n";
if ($self->{readblocking}) {
my $read;
@@ -378,6 +379,7 @@ sub relay_splice_datagram {
my $splicemax = $max || 0;
setsplice(\*STDIN, \*STDOUT, $splicemax, $idle)
or die ref($self), " splice stdin to stdout failed: $!";
+ print STDERR "Spliced\n";
my $rin = '';
vec($rin, fileno(STDIN), 1) = 1;
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 10dafa78c65..e3803fe12a7 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py
@@ -2,6 +2,7 @@
# send urgent data from client to relay before connecting to server
import os
+import re
import sys
import threading
from addr import *
@@ -71,6 +72,18 @@ sniffer.filter = "src %s and dst %s and tcp port %u " \
sniffer.start()
time.sleep(1)
+print "Wait for splicing syscall, grep it in relay log"
+def loggrep(file, regex, timeout):
+ for i in range(timeout):
+ for line in open(file, 'r'):
+ if re.search(regex, line):
+ return line
+ time.sleep(1)
+ return None
+if not loggrep("relay.log", "Spliced", 5):
+ print "ERROR: Relay did not splice"
+ exit(1)
+
print "Send spliced SYN+ACK packet to finish handshake"
spliced_synack=TCP(sport=spliced_syn.dport, dport=spliced_syn.sport,
seq=0, ack=spliced_syn.seq+1, flags='SA')
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 28d2423ef44..d0903061439 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py
@@ -2,6 +2,7 @@
# send payload from client to relay before connecting to server
import os
+import re
import sys
import threading
from addr import *
@@ -71,6 +72,18 @@ sniffer.filter = "src %s and dst %s and tcp port %u " \
sniffer.start()
time.sleep(1)
+print "Wait for splicing syscall, grep it in relay log"
+def loggrep(file, regex, timeout):
+ for i in range(timeout):
+ for line in open(file, 'r'):
+ if re.search(regex, line):
+ return line
+ time.sleep(1)
+ return None
+if not loggrep("relay.log", "Spliced", 5):
+ print "ERROR: Relay did not splice"
+ exit(1)
+
print "Send spliced SYN+ACK packet to finish handshake"
spliced_synack=TCP(sport=spliced_syn.dport, dport=spliced_syn.sport,
seq=0, ack=spliced_syn.seq+1, flags='SA')