diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2012-01-24 19:12:35 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2012-01-24 19:12:35 +0000 |
commit | ed5adef7b5dabb6546de5467d5bd8c98643686fd (patch) | |
tree | f5a85500e95240116ba341135e318e598f3afbcc /regress/sys | |
parent | cc2499c7e5beeb6106d6938bab5442a31df63032 (diff) |
Add a test for atomic IPv6 fragment reassembly.
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/netinet6/frag6/Makefile | 9 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_overatomic.py | 47 |
2 files changed, 55 insertions, 1 deletions
diff --git a/regress/sys/netinet6/frag6/Makefile b/regress/sys/netinet6/frag6/Makefile index 6275981aa43..bf0998e3745 100644 --- a/regress/sys/netinet6/frag6/Makefile +++ b/regress/sys/netinet6/frag6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 2012/01/11 21:37:44 bluhm Exp $ +# $OpenBSD: Makefile,v 1.4 2012/01/24 19:12:34 bluhm Exp $ # The following ports must be installed: # @@ -102,6 +102,13 @@ run-regress-frag6-overdrop: addr.py @echo Check ping6 overlap drop future fragments ${SUDO} python2.7 frag6_overdrop.py +# fragmented packet with overlap, atomic fragment must be processed +TARGETS += frag6-overatomic +run-regress-frag6-overatomic: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 overlapping and atomic fragments + ${SUDO} python2.7 frag6_overatomic.py + # fragmented packet permuted fragments TARGETS += frag6-permute run-regress-frag6-permute: addr.py diff --git a/regress/sys/netinet6/frag6/frag6_overatomic.py b/regress/sys/netinet6/frag6/frag6_overatomic.py new file mode 100644 index 00000000000..a1c0809265a --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_overatomic.py @@ -0,0 +1,47 @@ +#!/usr/local/bin/python2.7 +# send ping6 fragment that will overlap the second fragment +# send atomic fragment with offset=0 and more=0, it must be processed + +# |XXXXXXXX| +# |-------------| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +dummy="0123456701234567" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=pid, data=payload) +frag=[] +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, offset=1)/dummy) +frag.append(IPv6ExtHdrFragment(nh=58, id=pid)/str(packet)[40:64]) +eth=[] +for f in frag: + pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f + eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + +if os.fork() == 0: + time.sleep(1) + sendp(eth, iface=SRC_IF) + os._exit(0) + +ans=sniff(iface=SRC_IF, timeout=3, filter= + "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +for a in ans: + if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \ + ipv6nh[a.payload.nh] == 'ICMPv6' and \ + icmp6types[a.payload.payload.type] == 'Echo Reply': + id=a.payload.payload.id + print "id=%#x" % (id) + if id != pid: + print "WRONG ECHO REPLY ID" + exit(2) + data=a.payload.payload.data + print "payload=%s" % (data) + if data == payload: + exit(0) + print "PAYLOAD!=%s" % (payload) + exit(2) +print "NO ECHO REPLY" +exit(1) |