summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2020-12-25 19:01:10 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2020-12-25 19:01:10 +0000
commit5f9908c5f733b786e39e4505e787c49770bbc896 (patch)
tree8b72813305c2a18159203d31b4a22bac1bae04bb
parent06f63664fb499b0dc80c2d81f0b693baf50432ff (diff)
Switch to scapy with python 3.
-rw-r--r--regress/sys/netinet/pmtu/Makefile13
-rwxr-xr-xregress/sys/netinet/pmtu/tcp_atomicfrag6.py30
-rwxr-xr-xregress/sys/netinet/pmtu/tcp_connect.py24
-rwxr-xr-xregress/sys/netinet/pmtu/tcp_connect6.py24
-rwxr-xr-xregress/sys/netinet/pmtu/udp_atomicfrag6.py26
-rwxr-xr-xregress/sys/netinet/pmtu/udp_echo6.py28
6 files changed, 72 insertions, 73 deletions
diff --git a/regress/sys/netinet/pmtu/Makefile b/regress/sys/netinet/pmtu/Makefile
index cdeb08fbb34..87dfc570d0d 100644
--- a/regress/sys/netinet/pmtu/Makefile
+++ b/regress/sys/netinet/pmtu/Makefile
@@ -1,13 +1,12 @@
-# $OpenBSD: Makefile,v 1.13 2020/12/17 00:51:13 bluhm Exp $
+# $OpenBSD: Makefile,v 1.14 2020/12/25 19:01:09 bluhm Exp $
# The following ports must be installed:
#
-# python-2.7 interpreted object-oriented programming language
# scapy powerful interactive packet manipulation in python
-.if ! exists(/usr/local/bin/python2.7) || ! exists(/usr/local/bin/scapy)
+.if ! exists(/usr/local/bin/scapy-3)
regress:
- @echo install python and the scapy module for additional tests
+ @echo Install py3-scapy package to run this regress.
@echo SKIPPED
.endif
@@ -52,9 +51,9 @@ regress:
.elif make (regress) || make (all)
.BEGIN: addr.py
- @echo
${SUDO} true
ssh -t ${REMOTE_SSH} ${SUDO} true
+ @echo
.endif
# Create python include file containing the addresses.
@@ -74,9 +73,9 @@ addr.py: Makefile
# 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 ./
.else
-PYTHON = PYTHONPATH=${.OBJDIR} python2.7 -u ${.CURDIR}/
+PYTHON = PYTHONPATH=${.OBJDIR} python3 -u ${.CURDIR}/
.endif
# Clear local and remote path mtu routes, set fake net route
diff --git a/regress/sys/netinet/pmtu/tcp_atomicfrag6.py b/regress/sys/netinet/pmtu/tcp_atomicfrag6.py
index 247068f9c9a..8352df61e19 100755
--- a/regress/sys/netinet/pmtu/tcp_atomicfrag6.py
+++ b/regress/sys/netinet/pmtu/tcp_atomicfrag6.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
import os
import threading
@@ -23,24 +23,24 @@ e=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)
ip6=IPv6(src=FAKE_NET_ADDR6, dst=REMOTE_ADDR6)
tport=os.getpid() & 0xffff
-print "Send SYN packet, receive SYN+ACK."
+print("Send SYN packet, receive SYN+ACK.")
syn=TCP(sport=tport, dport='chargen', seq=1, flags='S', window=(2**16)-1)
synack=srp1(e/ip6/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: no SYN+ACK from chargen server received"
+ print("ERROR: No SYN+ACK from chargen server received.")
exit(1)
-print "Send ACK packet, receive chargen data."
+print("Send ACK packet, receive chargen data.")
ack=TCP(sport=synack.dport, dport=synack.sport, seq=2, flags='A',
ack=synack.seq+1, window=(2**16)-1)
data=srp1(e/ip6/ack, iface=LOCAL_IF, timeout=5)
if data is None:
- print "ERROR: no data from chargen server received"
+ print("ERROR: No data from chargen server received.")
exit(1)
-print "Fill our receive buffer."
+print("Fill our receive buffer.")
time.sleep(1)
# srp1 cannot be used, fragment answer will not match outgoing ICMP6 packet
@@ -50,14 +50,14 @@ sniffer.filter = \
sniffer.start()
time.sleep(1)
-print "Send ICMP6 packet too big packet with MTU 1272."
+print("Send ICMP6 packet too big packet with MTU 1272.")
icmp6=ICMPv6PacketTooBig(mtu=1272)/data.payload
sendp(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/icmp6, iface=LOCAL_IF)
-print "Path MTU discovery will not resend data, ICMP6 packet is ignored."
+print("Path MTU discovery will not resend data, ICMP6 packet is ignored.")
sniffer.join(timeout=5)
-print "IPv6 atomic fragments must not be generated."
+print("IPv6 atomic fragments must not be generated.")
frag=None
for a in sniffer.captured:
fh=a.payload.payload
@@ -70,25 +70,25 @@ for a in sniffer.captured:
break
if frag is not None:
- print "ERROR: matching IPv6 fragment TCP answer found"
+ print("ERROR: Matching IPv6 fragment TCP answer found.")
exit(1)
-print "Send ACK again to trigger retransmit."
+print("Send ACK again to trigger retransmit.")
data=srp1(e/ip6/ack, iface=LOCAL_IF, timeout=5)
if data is None:
- print "ERROR: no data retransmit from chargen server received"
+ print("ERROR: No data retransmit from chargen server received.")
exit(1)
-print "Cleanup the other's socket with a reset packet."
+print("Cleanup the other's socket with a reset packet.")
rst=TCP(sport=synack.dport, dport=synack.sport, seq=2, flags='AR',
ack=synack.seq+1)
sendp(e/ip6/rst, iface=LOCAL_IF)
len = data.plen + len(IPv6())
-print "len=%d" % len
+print("len=%d" % len)
if len != 1500:
- print "ERROR: TCP data packet len is %d, expected 1500." % len
+ print("ERROR: TCP data packet len is %d, expected 1500." % len)
exit(1)
exit(0)
diff --git a/regress/sys/netinet/pmtu/tcp_connect.py b/regress/sys/netinet/pmtu/tcp_connect.py
index 6f27562e145..5c2c4a326a6 100755
--- a/regress/sys/netinet/pmtu/tcp_connect.py
+++ b/regress/sys/netinet/pmtu/tcp_connect.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
import os
import threading
@@ -22,24 +22,24 @@ class Sniff1(threading.Thread):
ip=IP(src=FAKE_NET_ADDR, dst=REMOTE_ADDR)
tport=os.getpid() & 0xffff
-print "Send SYN packet, receive SYN+ACK."
+print("Send SYN packet, receive SYN+ACK.")
syn=TCP(sport=tport, dport='chargen', seq=1, flags='S', window=(2**16)-1)
synack=sr1(ip/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: no SYN+ACK from chargen server received"
+ print("ERROR: No SYN+ACK from chargen server received.")
exit(1)
-print "Send ACK packet, receive chargen data."
+print("Send ACK packet, receive chargen data.")
ack=TCP(sport=synack.dport, dport=synack.sport, seq=2, flags='A',
ack=synack.seq+1, window=(2**16)-1)
data=sr1(ip/ack, iface=LOCAL_IF, timeout=5)
if data is None:
- print "ERROR: no data from chargen server received"
+ print("ERROR: No data from chargen server received.")
exit(1)
-print "Fill our receive buffer."
+print("Fill our receive buffer.")
time.sleep(1)
# sr1 cannot be used, TCP data will not match outgoing ICMP packet
@@ -50,29 +50,29 @@ sniffer.filter = \
sniffer.start()
time.sleep(1)
-print "Send ICMP fragmentation needed packet with MTU 1300."
+print("Send ICMP fragmentation needed packet with MTU 1300.")
icmp=ICMP(type="dest-unreach", code="fragmentation-needed",
nexthopmtu=1300)/data
send(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/icmp, iface=LOCAL_IF)
-print "Path MTU discovery will resend first data with length 1300."
+print("Path MTU discovery will resend first data with length 1300.")
sniffer.join(timeout=5)
ans = sniffer.packet
if len(ans) == 0:
- print "ERROR: no data retransmit from chargen server received"
+ print("ERROR: No data retransmit from chargen server received.")
exit(1)
data=ans[0]
-print "Cleanup the other's socket with a reset packet."
+print("Cleanup the other's socket with a reset packet.")
rst=TCP(sport=synack.dport, dport=synack.sport, seq=2, flags='AR',
ack=synack.seq+1)
send(ip/rst, iface=LOCAL_IF)
len = data.len
-print "len=%d" % len
+print("len=%d" % len)
if len != 1300:
- print "ERROR: TCP data packet len is %d, expected 1300." % len
+ print("ERROR: TCP data packet len is %d, expected 1300." % len)
exit(1)
exit(0)
diff --git a/regress/sys/netinet/pmtu/tcp_connect6.py b/regress/sys/netinet/pmtu/tcp_connect6.py
index c78ad4c312d..c6e66d7e6c3 100755
--- a/regress/sys/netinet/pmtu/tcp_connect6.py
+++ b/regress/sys/netinet/pmtu/tcp_connect6.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
import os
import threading
@@ -23,24 +23,24 @@ e=Ether(src=LOCAL_MAC, dst=REMOTE_MAC)
ip6=IPv6(src=FAKE_NET_ADDR6, dst=REMOTE_ADDR6)
tport=os.getpid() & 0xffff
-print "Send SYN packet, receive SYN+ACK."
+print("Send SYN packet, receive SYN+ACK.")
syn=TCP(sport=tport, dport='chargen', seq=1, flags='S', window=(2**16)-1)
synack=srp1(e/ip6/syn, iface=LOCAL_IF, timeout=5)
if synack is None:
- print "ERROR: no SYN+ACK from chargen server received"
+ print("ERROR: No SYN+ACK from chargen server received.")
exit(1)
-print "Send ACK packet, receive chargen data."
+print("Send ACK packet, receive chargen data.")
ack=TCP(sport=synack.dport, dport=synack.sport, seq=2, flags='A',
ack=synack.seq+1, window=(2**16)-1)
data=srp1(e/ip6/ack, iface=LOCAL_IF, timeout=5)
if data is None:
- print "ERROR: no data from chargen server received"
+ print("ERROR: No data from chargen server received.")
exit(1)
-print "Fill our receive buffer."
+print("Fill our receive buffer.")
time.sleep(1)
# srp1 cannot be used, TCP data will not match outgoing ICMP6 packet
@@ -51,28 +51,28 @@ sniffer.filter = \
sniffer.start()
time.sleep(1)
-print "Send ICMP6 packet too big packet with MTU 1300."
+print("Send ICMP6 packet too big packet with MTU 1300.")
icmp6=ICMPv6PacketTooBig(mtu=1300)/data.payload
sendp(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/icmp6, iface=LOCAL_IF)
-print "Path MTU discovery will resend first data with length 1300."
+print("Path MTU discovery will resend first data with length 1300.")
sniffer.join(timeout=5)
ans = sniffer.packet
if len(ans) == 0:
- print "ERROR: no data retransmit from chargen server received"
+ print("ERROR: No data retransmit from chargen server received.")
exit(1)
data=ans[0]
-print "Cleanup the other's socket with a reset packet."
+print("Cleanup the other's socket with a reset packet.")
rst=TCP(sport=synack.dport, dport=synack.sport, seq=2, flags='AR',
ack=synack.seq+1)
sendp(e/ip6/rst, iface=LOCAL_IF)
len = data.plen + len(IPv6())
-print "len=%d" % len
+print("len=%d" % len)
if len != 1300:
- print "ERROR: TCP data packet len is %d, expected 1300." % len
+ print("ERROR: TCP data packet len is %d, expected 1300." % len)
exit(1)
exit(0)
diff --git a/regress/sys/netinet/pmtu/udp_atomicfrag6.py b/regress/sys/netinet/pmtu/udp_atomicfrag6.py
index d74cfbb1ef0..23b552cb438 100755
--- a/regress/sys/netinet/pmtu/udp_atomicfrag6.py
+++ b/regress/sys/netinet/pmtu/udp_atomicfrag6.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
import os
import threading
@@ -28,21 +28,21 @@ uport=os.getpid() & 0xffff
if uport < 1024 or uport == 2049:
uport+=1024
-print "Send UDP packet with 1200 octets payload, receive echo."
+print("Send UDP packet with 1200 octets payload, receive echo.")
data=''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase +
string.digits) for _ in range(1200))
udp=UDP(sport=uport, dport='echo')/data
echo=srp1(e/ip6/udp, iface=LOCAL_IF, timeout=5)
if echo is None:
- print "ERROR: no UDP answer from echo server received"
+ print("ERROR: No UDP answer from echo server received.")
exit(1)
-print "Send ICMP6 packet too big packet with MTU 1272."
+print("Send ICMP6 packet too big packet with MTU 1272.")
icmp6=ICMPv6PacketTooBig(mtu=1272)/echo.payload
sendp(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/icmp6, iface=LOCAL_IF)
-print "Clear route cache at echo socket by sending from different address."
+print("Clear route cache at echo socket by sending from different address.")
sendp(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/udp, iface=LOCAL_IF)
# srp1 cannot be used, fragment answer will not match on outgoing UDP packet
@@ -52,13 +52,13 @@ sniffer.filter = \
sniffer.start()
time.sleep(1)
-print "Send UDP packet with 1200 octets payload."
+print("Send UDP packet with 1200 octets payload.")
sendp(e/ip6/udp, iface=LOCAL_IF)
-print "Path MTU discovery will not send UDP atomic fragment."
+print("Path MTU discovery will not send UDP atomic fragment.")
sniffer.join(timeout=5)
-print "IPv6 atomic fragments must not be generated."
+print("IPv6 atomic fragments must not be generated.")
frag=None
for a in sniffer.captured:
fh=a.payload.payload
@@ -71,17 +71,17 @@ for a in sniffer.captured:
break
if frag is not None:
- print "ERROR: matching IPv6 fragment UDP answer found"
+ print("ERROR: Matching IPv6 fragment UDP answer found.")
exit(1)
-print "Send echo again and expect reply without fragmentation."
+print("Send echo again and expect reply without fragmentation.")
reply=srp1(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/udp, iface=LOCAL_IF)
-print "UDP echo has IPv6 and UDP header, so expected payload len is 1248."
+print("UDP echo has IPv6 and UDP header, so expected payload len is 1248.")
elen = reply.plen + len(IPv6())
-print "rlen=%d" % elen
+print("rlen=%d" % elen)
if elen != 1248:
- print "ERROR: UDP reply payload len is %d, expected 1248." % elen
+ print("ERROR: UDP reply payload len is %d, expected 1248." % elen)
exit(1)
exit(0)
diff --git a/regress/sys/netinet/pmtu/udp_echo6.py b/regress/sys/netinet/pmtu/udp_echo6.py
index f1a4e112c27..2505e33783c 100755
--- a/regress/sys/netinet/pmtu/udp_echo6.py
+++ b/regress/sys/netinet/pmtu/udp_echo6.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
import os
import threading
@@ -28,21 +28,21 @@ uport=os.getpid() & 0xffff
if uport < 1024 or uport == 2049:
uport+=1024
-print "Send UDP packet with 1400 octets payload, receive echo."
+print("Send UDP packet with 1400 octets payload, receive echo.")
data=''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase +
string.digits) for _ in range(1400))
udp=UDP(sport=uport, dport='echo')/data
echo=srp1(e/ip6/udp, iface=LOCAL_IF, timeout=5)
if echo is None:
- print "ERROR: no UDP answer from echo server received"
+ print("ERROR: No UDP answer from echo server received.")
exit(1)
-print "Send ICMP6 packet too big packet with MTU 1300."
+print("Send ICMP6 packet too big packet with MTU 1300.")
icmp6=ICMPv6PacketTooBig(mtu=1300)/echo.payload
sendp(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/icmp6, iface=LOCAL_IF)
-print "Clear route cache at echo socket by sending from different address."
+print("Clear route cache at echo socket by sending from different address.")
sendp(e/IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/udp, iface=LOCAL_IF)
# srp1 cannot be used, fragment answer will not match on outgoing UDP packet
@@ -52,10 +52,10 @@ sniffer.filter = \
sniffer.start()
time.sleep(1)
-print "Send UDP packet with 1400 octets payload."
+print("Send UDP packet with 1400 octets payload.")
sendp(e/ip6/udp, iface=LOCAL_IF)
-print "Path MTU discovery will send UDP fragment with maximum length 1300."
+print("Path MTU discovery will send UDP fragment with maximum length 1300.")
sniffer.join(timeout=5)
for a in sniffer.captured:
@@ -68,21 +68,21 @@ for a in sniffer.captured:
frag=a
break
else:
- print "ERROR: no matching IPv6 fragment UDP answer found"
+ print("ERROR: No matching IPv6 fragment UDP answer found.")
exit(1)
-print "UDP echo has IPv6 and UDP header, so expected payload len is 1448."
+print("UDP echo has IPv6 and UDP header, so expected payload len is 1448.")
elen = echo.plen + len(IPv6())
-print "elen=%d" % elen
+print("elen=%d" % elen)
if elen != 1448:
- print "ERROR: UDP echo payload len is %d, expected 1448." % elen
+ print("ERROR: UDP echo payload len is %d, expected 1448." % elen)
exit(1)
-print "Fragments contain multiple of 8 octets, so expected len is 1296."
+print("Fragments contain multiple of 8 octets, so expected len is 1296.")
flen = frag.plen + len(IPv6())
-print "flen=%d" % flen
+print("flen=%d" % flen)
if flen != 1296:
- print "ERROR: UDP fragment len is %d, expected 1296." % flen
+ print("ERROR: UDP fragment len is %d, expected 1296." % flen)
exit(1)
exit(0)