summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2020-12-25 16:50:41 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2020-12-25 16:50:41 +0000
commitb076a4ce3441ffde6f43779bde8949af58118170 (patch)
treeb8d27c3a0b11b0f4b48f6d790015fabef6576c81
parentfda3c6e935a2ffe2518ef6fae079686b2221b4a3 (diff)
Switch to scapy with python 3.
-rw-r--r--regress/sys/kern/sosplice/LICENSE26
-rw-r--r--regress/sys/kern/sosplice/Makefile.inc7
-rw-r--r--regress/sys/kern/sosplice/scapy/Makefile15
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py56
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-delay-synack.py56
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-handshake.py30
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py42
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-oobinline.py38
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py42
-rw-r--r--regress/sys/kern/sosplice/scapy/scapy-payload.py38
10 files changed, 176 insertions, 174 deletions
diff --git a/regress/sys/kern/sosplice/LICENSE b/regress/sys/kern/sosplice/LICENSE
index 52b251631b7..d4acc003a67 100644
--- a/regress/sys/kern/sosplice/LICENSE
+++ b/regress/sys/kern/sosplice/LICENSE
@@ -1,13 +1,13 @@
-# 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
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+Copyright (c) 2010-2020 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
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/regress/sys/kern/sosplice/Makefile.inc b/regress/sys/kern/sosplice/Makefile.inc
index 872ab0fed31..10c95c7db78 100644
--- a/regress/sys/kern/sosplice/Makefile.inc
+++ b/regress/sys/kern/sosplice/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.4 2019/07/12 19:31:29 bluhm Exp $
+# $OpenBSD: Makefile.inc,v 1.5 2020/12/25 16:50:40 bluhm Exp $
# The following ports must be installed for the regression tests:
# p5-BSD-Socket-Splice perl interface to OpenBSD socket splicing
@@ -16,7 +16,8 @@ PERL_REQUIRE != perl -Mstrict -Mwarnings -e ' \
.if ! empty (PERL_REQUIRE) && ! defined (TARGETS)
regress:
@echo "${PERL_REQUIRE}"
- @echo install these perl packages for additional tests
+ @echo Install these Perl modules for additional tests.
+ @echo SKIPPED
.endif
# Fill out these variables if you want to test socket splicing with
@@ -35,7 +36,7 @@ REMOTE_SSH ?=
ARGS != cd ${.CURDIR} && ls args-*.pl
TARGETS ?= ${ARGS}
.endif
-REGRESS_TARGETS = ${TARGETS:S/^/run-/}
+REGRESS_TARGETS += ${TARGETS:S/^/run-/}
CLEANFILES += *.log ktrace.out stamp-*
# Set variables so that make runs with and without obj directory.
diff --git a/regress/sys/kern/sosplice/scapy/Makefile b/regress/sys/kern/sosplice/scapy/Makefile
index 0981c1af603..f3ddfd50579 100644
--- a/regress/sys/kern/sosplice/scapy/Makefile
+++ b/regress/sys/kern/sosplice/scapy/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.7 2020/12/17 00:51:12 bluhm Exp $
+# $OpenBSD: Makefile,v 1.8 2020/12/25 16:50:40 bluhm Exp $
# Copyright (c) 2017-2020 Alexander Bluhm <bluhm@openbsd.org>
#
@@ -22,9 +22,9 @@
.if ! (make(clean) || make(cleandir) || make(obj))
-.if ! exists(/usr/local/bin/scapy)
+.if ! exists(/usr/local/bin/scapy-3)
regress:
- @echo Install scapy package to run this regress.
+ @echo Install py3-scapy package to run this regress.
@echo SKIPPED
.endif
@@ -32,7 +32,8 @@ regress:
.if ! empty (PERL_REQUIRE)
regress:
@echo perl require: "${PERL_REQUIRE}"
- @echo install these perl packages for additional tests
+ @echo Install these Perl modules for additional tests.
+ @echo SKIPPED
.endif
PF_STATUS != ${SUDO} pfctl -si | sed -n 's/^Status: \([^ ]*\) .*/\1/p'
@@ -85,9 +86,9 @@ regress:
.if make (regress) || make (all)
.BEGIN:
- @echo
${SUDO} true
ssh -t ${REMOTE_SSH} true
+ @echo
.endif
# Create python include file containing the addresses.
@@ -114,10 +115,10 @@ TARGETS =
# Set variables so that make runs with and without obj directory.
# Only do that if necessary to keep visible output short.
.if ${.CURDIR} == ${.OBJDIR}
-PYTHON = python2.7 -u
+PYTHON = python3 -u
SCAPYPATH =
.else
-PYTHON = PYTHONPATH=${.OBJDIR} python2.7 -u
+PYTHON = PYTHONPATH=${.OBJDIR} python3 -u
SCAPYPATH = ${.CURDIR}/
.endif
diff --git a/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py b/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py
index 319567cca58..7cf3da409e7 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-delay-oobinline.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# send urgent data from client before handshake has completed
import os
@@ -27,22 +27,22 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
@@ -51,86 +51,86 @@ sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Send 20 bytes payload and one urgent byte"
+print("Send 20 bytes payload and one urgent byte")
data="0123456789Xabcdefghij"
payload=TCP(sport=synack.dport, dport=synack.sport, urgptr=11,
seq=1, ack=synack.seq+1, flags='APU')/data
payload_ack=sr1(ip/payload, iface=LOCAL_IF)
if payload_ack is None:
- print "ERROR: No payload ACK packet received"
+ print("ERROR: No payload ACK packet received")
exit(1)
if payload_ack.ack != len(data)+1:
- print "ERROR: Expected ack %d, got %d in payload ACK" % \
- (len(data)+1, payload_ack.ack)
+ print("ERROR: Expected ack %d, got %d in payload ACK" %
+ (len(data)+1, payload_ack.ack))
exit(1)
time.sleep(1)
-print "Expect spliced urgent payload"
+print("Expect spliced urgent payload")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-ack|tcp-urg" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
sniffer.join(timeout=7)
spliced_payload = sniffer.packet
if spliced_payload is None:
- print "ERROR: No spliced urgent payload packet received"
+ print("ERROR: No spliced urgent payload packet received")
exit(1)
if spliced_payload.seq != spliced_ack.seq:
- print "ERROR: Expected seq %d, got %d in spliced payload" % \
- (spliced_ack.seq, spliced_payload.seq)
+ print("ERROR: Expected seq %d, got %d in spliced payload" %
+ (spliced_ack.seq, spliced_payload.seq))
exit(1)
if spliced_payload.urgptr != 11:
- print "ERROR: Expected urgptr %d, got %d in spliced payload" % \
- (11, spliced_payload.urgptr)
+ print("ERROR: Expected urgptr %d, got %d in spliced payload" %
+ (11, spliced_payload.urgptr))
exit(1)
-print "Expect spliced ACK retransmission"
+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"
+print("Retransmit spliced SYN+ACK packet to trigger ACK")
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"
+ print("ERROR: No spliced ACK retransmit packet received")
exit(1)
if spliced_ack_retrans.seq != spliced_syn.seq+1+len(data):
- print "ERROR: Expected seq %d, got %d in retransmitted spliced ack" % \
- (spliced_syn.seq+1+len(data), spliced_ack_retrans.seq)
+ print("ERROR: Expected seq %d, got %d in retransmitted spliced ack" %
+ (spliced_syn.seq+1+len(data), spliced_ack_retrans.seq))
exit(1)
if spliced_ack_retrans.ack != 1:
- print "ERROR: Expected ack %d, got %d in retransmitted spliced ack" % \
- (1, spliced_ack_retrans.ack)
+ print("ERROR: Expected ack %d, got %d in retransmitted spliced ack" %
+ (1, spliced_ack_retrans.ack))
exit(1)
if spliced_ack_retrans.len-20-20 != 0:
- print "ERROR: Expected len %d, got %d in retransmitted spliced ack" % \
- (0, spliced_ack_retrans.len-20-20)
+ print("ERROR: Expected len %d, got %d in retransmitted spliced ack" %
+ (0, spliced_ack_retrans.len-20-20))
exit(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)
diff --git a/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py b/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py
index 00a5dc914b1..1d3e7c740f9 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-delay-synack.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# send data from client via relay before server handshake is completed
import os
@@ -27,22 +27,22 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
@@ -51,86 +51,86 @@ sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Send 10 bytes payload"
+print("Send 10 bytes payload")
data="0123456789"
payload=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='AP')/data
payload_ack=sr1(ip/payload, iface=LOCAL_IF)
if payload_ack is None:
- print "ERROR: No payload ACK packet received"
+ print("ERROR: No payload ACK packet received")
exit(1)
if payload_ack.ack != len(data)+1:
- print "ERROR: Expected ack %d, got %d in payload ACK" % \
- (len(data)+1, payload_ack.ack)
+ print("ERROR: Expected ack %d, got %d in payload ACK" %
+ (len(data)+1, payload_ack.ack))
exit(1)
time.sleep(1)
-print "Expect spliced payload"
+print("Expect spliced payload")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-ack|tcp-push" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
sniffer.join(timeout=7)
spliced_payload = sniffer.packet
if spliced_payload is None:
- print "ERROR: No spliced payload packet received"
+ print("ERROR: No spliced payload packet received")
exit(1)
if spliced_payload.seq != spliced_ack.seq:
- print "ERROR: Expected seq %d, got %d in spliced payload" % \
- (spliced_ack.seq, spliced_payload.seq)
+ print("ERROR: Expected seq %d, got %d in spliced payload" %
+ (spliced_ack.seq, spliced_payload.seq))
exit(1)
if spliced_payload.len-20-20 != len(data):
- print "ERROR: Expected len %d, got %d in spliced payload" % \
- (len(data), spliced_payload.len-20-20)
+ print("ERROR: Expected len %d, got %d in spliced payload" %
+ (len(data), spliced_payload.len-20-20))
exit(1)
-print "Expect spliced ACK retransmission"
+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"
+print("Retransmit spliced SYN+ACK packet to trigger ACK")
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"
+ print("ERROR: No spliced ACK retransmit packet received")
exit(1)
if spliced_ack_retrans.seq != spliced_syn.seq+1+len(data):
- print "ERROR: Expected seq %d, got %d in retransmitted spliced ack" % \
- (spliced_syn.seq+1+len(data), spliced_ack_retrans.seq)
+ print("ERROR: Expected seq %d, got %d in retransmitted spliced ack" %
+ (spliced_syn.seq+1+len(data), spliced_ack_retrans.seq))
exit(1)
if spliced_ack_retrans.ack != 1:
- print "ERROR: Expected ack %d, got %d in retransmitted spliced ack" % \
- (1, spliced_ack_retrans.ack)
+ print("ERROR: Expected ack %d, got %d in retransmitted spliced ack" %
+ (1, spliced_ack_retrans.ack))
exit(1)
if spliced_ack_retrans.len-20-20 != 0:
- print "ERROR: Expected len %d, got %d in retransmitted spliced ack" % \
- (0, spliced_ack_retrans.len-20-20)
+ print("ERROR: Expected len %d, got %d in retransmitted spliced ack" %
+ (0, spliced_ack_retrans.len-20-20))
exit(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)
diff --git a/regress/sys/kern/sosplice/scapy/scapy-handshake.py b/regress/sys/kern/sosplice/scapy/scapy-handshake.py
index 4285e857492..176f64ec8d0 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-handshake.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-handshake.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# do a tcp handshake for the client and server connection
import os
@@ -27,22 +27,22 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
@@ -51,33 +51,33 @@ sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
if spliced_ack.seq != spliced_syn.seq+1:
- print "ERROR: Expected seq %d, got %d in spliced ack" % \
- (spliced_syn.seq+1, spliced_ack.seq)
+ print("ERROR: Expected seq %d, got %d in spliced ack" %
+ (spliced_syn.seq+1, spliced_ack.seq))
exit(1)
if spliced_ack.ack != 1:
- print "ERROR: Expected ack %d, got %d in spliced ack" % \
- (1, spliced_ack.ack)
+ print("ERROR: Expected ack %d, got %d in spliced ack" %
+ (1, spliced_ack.ack))
exit(1)
if spliced_ack.len-20-20 != 0:
- print "ERROR: Expected len %d, got %d in spliced ack" % \
- (0, spliced_ack.len-20-20)
+ print("ERROR: Expected len %d, got %d in spliced ack" %
+ (0, spliced_ack.len-20-20))
exit(1)
time.sleep(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)
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 558b468d92b..2d3b2882017 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-oobinline-delay-connect.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# send urgent data from client to relay before connecting to server
import os
@@ -28,55 +28,55 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send 20 bytes payload and one urgent byte"
+print("Send 20 bytes payload and one urgent byte")
data="0123456789Xabcdefghij"
payload=TCP(sport=synack.dport, dport=synack.sport, urgptr=11,
seq=1, ack=synack.seq+1, flags='APU')/data
payload_ack=sr1(ip/payload, iface=LOCAL_IF)
if payload_ack is None:
- print "ERROR: No payload ACK packet received"
+ print("ERROR: No payload ACK packet received")
exit(1)
if payload_ack.ack != len(data)+1:
- print "ERROR: Expected ack %d, got %d in payload ACK" % \
- (len(data)+1, payload_ack.ack)
+ print("ERROR: Expected ack %d, got %d in payload ACK" %
+ (len(data)+1, payload_ack.ack))
exit(1)
sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Expect spliced urgent payload"
+print("Expect spliced urgent payload")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-ack|tcp-urg" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Wait for splicing syscall, grep it in relay log"
+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'):
@@ -85,34 +85,34 @@ def loggrep(file, regex, timeout):
time.sleep(1)
return None
if not loggrep("relay.log", "Spliced", 5):
- print "ERROR: Relay did not splice"
+ print("ERROR: Relay did not splice")
exit(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
sniffer.join(timeout=7)
spliced_payload = sniffer.packet
if spliced_payload is None:
- print "ERROR: No spliced urgent payload packet received"
+ print("ERROR: No spliced urgent payload packet received")
exit(1)
if spliced_payload.seq != spliced_ack.seq:
- print "ERROR: Expected seq %d, got %d in spliced payload" % \
- (spliced_ack.seq, spliced_payload.seq)
+ print("ERROR: Expected seq %d, got %d in spliced payload" %
+ (spliced_ack.seq, spliced_payload.seq))
exit(1)
if spliced_payload.urgptr != 11:
- print "ERROR: Expected urgptr %d, got %d in spliced payload" % \
- (11, spliced_payload.urgptr)
+ print("ERROR: Expected urgptr %d, got %d in spliced payload" %
+ (11, spliced_payload.urgptr))
exit(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)
diff --git a/regress/sys/kern/sosplice/scapy/scapy-oobinline.py b/regress/sys/kern/sosplice/scapy/scapy-oobinline.py
index a588d278acf..87aa4f55954 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-oobinline.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-oobinline.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# after tcp handshake send urgent data from client via relay to server
import os
@@ -27,22 +27,22 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
@@ -51,55 +51,55 @@ sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
-print "Expect spliced urgent payload"
+print("Expect spliced urgent payload")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-ack|tcp-urg" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send 20 bytes payload and one urgent byte"
+print("Send 20 bytes payload and one urgent byte")
data="0123456789Xabcdefghij"
payload=TCP(sport=synack.dport, dport=synack.sport, urgptr=11,
seq=1, ack=synack.seq+1, flags='APU')/data
payload_ack=sr1(ip/payload, iface=LOCAL_IF)
if payload_ack is None:
- print "ERROR: No payload ACK packet received"
+ print("ERROR: No payload ACK packet received")
exit(1)
if payload_ack.ack != len(data)+1:
- print "ERROR: Expected ack %d, got %d in payload ACK" % \
- (len(data)+1, payload_ack.ack)
+ print("ERROR: Expected ack %d, got %d in payload ACK" %
+ (len(data)+1, payload_ack.ack))
exit(1)
sniffer.join(timeout=7)
spliced_payload = sniffer.packet
if spliced_payload is None:
- print "ERROR: No spliced urgent payload packet received"
+ print("ERROR: No spliced urgent payload packet received")
exit(1)
if spliced_payload.seq != spliced_ack.seq:
- print "ERROR: Expected seq %d, got %d in spliced payload" % \
- (spliced_ack.seq, spliced_payload.seq)
+ print("ERROR: Expected seq %d, got %d in spliced payload" %
+ (spliced_ack.seq, spliced_payload.seq))
exit(1)
if spliced_payload.urgptr != 11:
- print "ERROR: Expected urgptr %d, got %d in spliced payload" % \
- (11, spliced_payload.urgptr)
+ print("ERROR: Expected urgptr %d, got %d in spliced payload" %
+ (11, spliced_payload.urgptr))
exit(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)
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 4b58b32c2a1..aeef1eeeedc 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-payload-delay-connect.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# send payload from client to relay before connecting to server
import os
@@ -28,55 +28,55 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send 10 bytes payload"
+print("Send 10 bytes payload")
data="0123456789"
payload=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='APU')/data
payload_ack=sr1(ip/payload, iface=LOCAL_IF)
if payload_ack is None:
- print "ERROR: No payload ACK packet received"
+ print("ERROR: No payload ACK packet received")
exit(1)
if payload_ack.ack != len(data)+1:
- print "ERROR: Expected ack %d, got %d in payload ACK" % \
- (len(data)+1, payload_ack.ack)
+ print("ERROR: Expected ack %d, got %d in payload ACK" %
+ (len(data)+1, payload_ack.ack))
exit(1)
sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Expect spliced payload"
+print("Expect spliced payload")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-ack|tcp-push" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Wait for splicing syscall, grep it in relay log"
+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'):
@@ -85,34 +85,34 @@ def loggrep(file, regex, timeout):
time.sleep(1)
return None
if not loggrep("relay.log", "Spliced", 5):
- print "ERROR: Relay did not splice"
+ print("ERROR: Relay did not splice")
exit(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
sniffer.join(timeout=7)
spliced_payload = sniffer.packet
if spliced_payload is None:
- print "ERROR: No spliced payload packet received"
+ print("ERROR: No spliced payload packet received")
exit(1)
if spliced_payload.seq != spliced_ack.seq:
- print "ERROR: Expected seq %d, got %d in spliced payload" % \
- (spliced_ack.seq, spliced_payload.seq)
+ print("ERROR: Expected seq %d, got %d in spliced payload" %
+ (spliced_ack.seq, spliced_payload.seq))
exit(1)
if spliced_payload.len-20-20 != len(data):
- print "ERROR: Expected len %d, got %d in spliced payload" % \
- (len(data), spliced_payload.len-20-20)
+ print("ERROR: Expected len %d, got %d in spliced payload" %
+ (len(data), spliced_payload.len-20-20))
exit(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)
diff --git a/regress/sys/kern/sosplice/scapy/scapy-payload.py b/regress/sys/kern/sosplice/scapy/scapy-payload.py
index 1e0e67104af..9ee3e41f236 100644
--- a/regress/sys/kern/sosplice/scapy/scapy-payload.py
+++ b/regress/sys/kern/sosplice/scapy/scapy-payload.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
# after tcp handshake send data from client via relay to server
import os
@@ -27,22 +27,22 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
-print "Send SYN packet, receive SYN+ACK"
+print("Send SYN packet, receive SYN+ACK")
syn=TCP(sport=client, dport=relay, seq=0, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: No matching SYN+ACK packet received"
+ print("ERROR: No matching SYN+ACK packet received")
exit(1)
-print "Expect spliced SYN"
+print("Expect spliced SYN")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-syn" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send ACK packet to finish handshake"
+print("Send ACK packet to finish handshake")
ack=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='A')
send(ip/ack, iface=LOCAL_IF)
@@ -51,55 +51,55 @@ sniffer.join(timeout=7)
spliced_syn = sniffer.packet
if spliced_syn is None:
- print "ERROR: No spliced SYN packet received"
+ print("ERROR: No spliced SYN packet received")
exit(1)
-print "Send spliced SYN+ACK packet to finish handshake"
+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')
spliced_ack=sr1(ip/spliced_synack, iface=LOCAL_IF)
if spliced_ack is None:
- print "ERROR: No spliced ACK packet received"
+ print("ERROR: No spliced ACK packet received")
exit(1)
-print "Expect spliced payload"
+print("Expect spliced payload")
sniffer = Sniff1();
sniffer.filter = "src %s and dst %s and tcp port %u " \
"and tcp[tcpflags] = tcp-ack|tcp-push" % (ip.dst, ip.src, server)
sniffer.start()
time.sleep(1)
-print "Send 10 bytes payload"
+print("Send 10 bytes payload")
data="0123456789"
payload=TCP(sport=synack.dport, dport=synack.sport,
seq=1, ack=synack.seq+1, flags='AP')/data
payload_ack=sr1(ip/payload, iface=LOCAL_IF)
if payload_ack is None:
- print "ERROR: No payload ACK packet received"
+ print("ERROR: No payload ACK packet received")
exit(1)
if payload_ack.ack != len(data)+1:
- print "ERROR: Expected ack %d, got %d in payload ACK" % \
- (len(data)+1, payload_ack.ack)
+ print("ERROR: Expected ack %d, got %d in payload ACK" %
+ (len(data)+1, payload_ack.ack))
exit(1)
sniffer.join(timeout=7)
spliced_payload = sniffer.packet
if spliced_payload is None:
- print "ERROR: No spliced payload packet received"
+ print("ERROR: No spliced payload packet received")
exit(1)
if spliced_payload.seq != spliced_ack.seq:
- print "ERROR: Expected seq %d, got %d in spliced payload" % \
- (spliced_ack.seq, spliced_payload.seq)
+ print("ERROR: Expected seq %d, got %d in spliced payload" %
+ (spliced_ack.seq, spliced_payload.seq))
exit(1)
if spliced_payload.len-20-20 != len(data):
- print "ERROR: Expected len %d, got %d in spliced payload" % \
- (len(data), spliced_payload.len-20-20)
+ print("ERROR: Expected len %d, got %d in spliced payload" %
+ (len(data), spliced_payload.len-20-20))
exit(1)
-print "Kill connections with RST"
+print("Kill connections with RST")
spliced_rst=TCP(sport=spliced_ack.dport, dport=spliced_ack.sport,
seq=1, ack=spliced_ack.seq, flags='RA')
send(ip/spliced_rst, iface=LOCAL_IF)