summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2012-07-10 16:52:46 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2012-07-10 16:52:46 +0000
commit91268fc0a0e643924b53fc0f3335588649a7a612 (patch)
treebb055868c25fe4a174a7bca0f529ff6f98b948e3
parentf593257db8ce46cc010d2354b98ccf5790d294bc (diff)
Add a subtest to the MTU ping that checks wether the ip length of
the original packet and the icmp quoted packet are the same.
-rw-r--r--regress/sys/net/pf_forward/Makefile4
-rw-r--r--regress/sys/net/pf_forward/ping6_mtu.py18
-rw-r--r--regress/sys/net/pf_forward/ping_mtu.py18
3 files changed, 27 insertions, 13 deletions
diff --git a/regress/sys/net/pf_forward/Makefile b/regress/sys/net/pf_forward/Makefile
index 0ef375ccdca..7a9e60cbeea 100644
--- a/regress/sys/net/pf_forward/Makefile
+++ b/regress/sys/net/pf_forward/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.1 2012/07/10 12:43:54 bluhm Exp $
+# $OpenBSD: Makefile,v 1.2 2012/07/10 16:52:45 bluhm Exp $
# The following ports must be installed:
#
@@ -129,6 +129,8 @@ run-regress-ping6:
# parse response packet to determine MTU of the router. The MTU has
# to be 1300 octets. The MTU has to be defined at out interface of
# the router RT before.
+# Check that the ip length of the original packet and the icmp
+# quoted packet are the same.
TARGETS += ping-mtu ping6-mtu
run-regress-ping-mtu: addr.py
diff --git a/regress/sys/net/pf_forward/ping6_mtu.py b/regress/sys/net/pf_forward/ping6_mtu.py
index 251a84c24a6..d0b660f0300 100644
--- a/regress/sys/net/pf_forward/ping6_mtu.py
+++ b/regress/sys/net/pf_forward/ping6_mtu.py
@@ -9,16 +9,22 @@ dstaddr=sys.argv[1]
expect=int(sys.argv[2])
pid=os.getpid()
payload="a" * 1452
-a=srp1(Ether(src=SRC_MAC, dst=PF_MAC)/IPv6(src=SRC_OUT6, dst=dstaddr)/
- ICMPv6EchoRequest(id=pid, data=payload), iface=SRC_IF, timeout=2)
+ip=IPv6(src=SRC_OUT6, dst=dstaddr)/ICMPv6EchoRequest(id=pid, data=payload)
+iplen=IPv6(str(ip)).plen
+eth=Ether(src=SRC_MAC, dst=PF_MAC)/ip
+a=srp1(eth, iface=SRC_IF, timeout=2)
if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \
ipv6nh[a.payload.nh] == 'ICMPv6' and \
icmp6types[a.payload.payload.type] == 'Packet too big':
mtu=a.payload.payload.mtu
print "mtu=%d" % (mtu)
- if mtu == expect:
- exit(0)
- print "MTU!=%d" % (expect)
- exit(1)
+ if mtu != expect:
+ print "MTU!=%d" % (expect)
+ exit(1)
+ len=a.payload.payload.payload.plen
+ if len != iplen:
+ print "IPv6 plen %d!=%d" % (len, iplen)
+ exit(1)
+ exit(0)
print "MTU=UNKNOWN"
exit(2)
diff --git a/regress/sys/net/pf_forward/ping_mtu.py b/regress/sys/net/pf_forward/ping_mtu.py
index 76985ae867a..08ff2a62911 100644
--- a/regress/sys/net/pf_forward/ping_mtu.py
+++ b/regress/sys/net/pf_forward/ping_mtu.py
@@ -9,14 +9,20 @@ dstaddr=sys.argv[1]
expect=int(sys.argv[2])
pid=os.getpid()
payload="a" * 1452
-a=srp1(Ether(src=SRC_MAC, dst=PF_MAC)/IP(flags="DF", src=SRC_OUT, dst=dstaddr)/
- ICMP(id=pid)/payload, iface=SRC_IF, timeout=2)
+ip=IP(flags="DF", src=SRC_OUT, dst=dstaddr)/ICMP(id=pid)/payload
+iplen=IP(str(ip)).len
+eth=Ether(src=SRC_MAC, dst=PF_MAC)/ip
+a=srp1(eth, iface=SRC_IF, timeout=2)
if a and a.payload.payload.type==3 and a.payload.payload.code==4:
mtu=a.payload.payload.unused
print "mtu=%d" % (mtu)
- if mtu == expect:
- exit(0)
- print "MTU!=%d" % (expect)
- exit(1)
+ if mtu != expect:
+ print "MTU!=%d" % (expect)
+ exit(1)
+ len=a.payload.payload.payload.len
+ if len != iplen:
+ print "IP len %d!=%d" % (len, iplen)
+ exit(1)
+ exit(0)
print "MTU=UNKNOWN"
exit(2)