diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2012-02-08 00:35:32 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2012-02-08 00:35:32 +0000 |
commit | b6de2da2a1714f8a8845dd45dbb753a2f37cd659 (patch) | |
tree | 616dd4cc387c38cabbcd9b98da53666f6f4b7579 /regress/sys | |
parent | fc9caf72f582d6fc20719811e101366fdcb6e971 (diff) |
Add IPv6 tests for fragmented destination options, fragments without
payload, fragmented UDP packets.
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/netinet6/frag6/Makefile | 47 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_opt.py | 44 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_overhead.py | 2 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_udpatomic.py | 44 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_udpheader.py | 45 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_udppayload.py | 45 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_zerofirst.py | 47 | ||||
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_zerosecond.py | 47 |
8 files changed, 318 insertions, 3 deletions
diff --git a/regress/sys/netinet6/frag6/Makefile b/regress/sys/netinet6/frag6/Makefile index a093f5e31aa..b285f26a64e 100644 --- a/regress/sys/netinet6/frag6/Makefile +++ b/regress/sys/netinet6/frag6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2012/01/27 17:28:00 bluhm Exp $ +# $OpenBSD: Makefile,v 1.6 2012/02/08 00:35:31 bluhm Exp $ # The following ports must be installed: # @@ -10,6 +10,7 @@ # Set up machines: SRC DST # SRC is the machine where this makefile is running. # DST is running OpenBSD with pf disabled to test the IPv6 stack. +# Enable echo udp6 in inetd.conf of DST to test UDP fragments. # # +---+ 1 +---+ # |SRC| ----> |DST| @@ -74,6 +75,13 @@ run-regress-frag6-ext: addr.py @echo Check ping6 extension header reassembly ${SUDO} python2.7 frag6_ext.py +# An destination options extension header after the fragment header +TARGETS += frag6-opt +run-regress-frag6-opt: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 destination option reassembly + ${SUDO} python2.7 frag6_opt.py + # fragmented packet with head overlapping first fragment TARGETS += frag6-overhead0 run-regress-frag6-overhead0: addr.py @@ -123,8 +131,43 @@ run-regress-frag6-permute: addr.py @echo Check ping6 permuted fragments ${SUDO} python2.7 frag6_permute.py +# fragmented packet with zero length first fragment +TARGETS += frag6-zerofirst +run-regress-frag6-zerofirst: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 zero length first fragment + ${SUDO} python2.7 frag6_zerofirst.py + +# fragmented packet with zero length second fragment +TARGETS += frag6-zerosecond +run-regress-frag6-zerosecond: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 zero length second fragment + ${SUDO} python2.7 frag6_zerosecond.py + +# atomic fragmented udp packet +TARGETS += frag6-udpatomic +run-regress-frag6-udpatomic: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 atomic udp fragment + ${SUDO} python2.7 frag6_udpatomic.py + +# fragmented udp packet after header +TARGETS += frag6-udpheader +run-regress-frag6-udpheader: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 udp header fragment + ${SUDO} python2.7 frag6_udpheader.py + +# fragmented udp packet within payload +TARGETS += frag6-udppayload +run-regress-frag6-udppayload: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 udp payload fragment + ${SUDO} python2.7 frag6_udppayload.py + REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/} -CLEANFILES += *.pyc *.log +CLEANFILES += addr.py *.pyc *.log .include <bsd.regress.mk> diff --git a/regress/sys/netinet6/frag6/frag6_opt.py b/regress/sys/netinet6/frag6/frag6_opt.py new file mode 100644 index 00000000000..43809db0d80 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_opt.py @@ -0,0 +1,44 @@ +#!/usr/local/bin/python2.7 +# send 2 ping6 fragments with fragmented destination option + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/IPv6ExtHdrDestOpt( \ + options=PadN(optdata='\0'*12)/PadN(optdata='\0'*6))/ \ + ICMPv6EchoRequest(id=pid, data=payload) +frag=[] +frag.append(IPv6ExtHdrFragment(nh=60, id=pid, m=1)/str(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=60, id=pid, offset=1)/str(packet)[48:88]) +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(1) +print "NO ECHO REPLY" +exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_overhead.py b/regress/sys/netinet6/frag6/frag6_overhead.py index e10ca263e46..d9cab47d4e3 100644 --- a/regress/sys/netinet6/frag6/frag6_overhead.py +++ b/regress/sys/netinet6/frag6/frag6_overhead.py @@ -1,5 +1,5 @@ #!/usr/local/bin/python2.7 -# send ping6 fragment that overlaps the second fragment with the head +# send ping6 fragment that overlaps the second fragment with the head # |----| # |----| diff --git a/regress/sys/netinet6/frag6/frag6_udpatomic.py b/regress/sys/netinet6/frag6/frag6_udpatomic.py new file mode 100644 index 00000000000..526359e4a33 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_udpatomic.py @@ -0,0 +1,44 @@ +#!/usr/local/bin/python2.7 +# send atomic udp fragment + +# |--------| +# |----| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/UDP(sport=pid, dport=7)/payload +frag=[] +frag.append(IPv6ExtHdrFragment(nh=17, 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 udp") +for a in ans: + if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \ + ipv6nh[a.payload.nh] == 'UDP' and \ + a.payload.payload.sport == 7: + port=a.payload.payload.dport + print "port=%d" % (port) + if port != pid: + print "WRONG UDP ECHO REPLY PORT" + exit(2) + data=a.payload.payload.load + print "payload=%s" % (data) + if data == payload: + exit(0) + print "PAYLOAD!=%s" % (payload) + exit(1) +print "NO UDP ECHO REPLY" +exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_udpheader.py b/regress/sys/netinet6/frag6/frag6_udpheader.py new file mode 100644 index 00000000000..318cabb64c8 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_udpheader.py @@ -0,0 +1,45 @@ +#!/usr/local/bin/python2.7 +# send 2 udp fragments splitted after udp header + +# |--------| +# |----| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/UDP(sport=pid, dport=7)/payload +frag=[] +frag.append(IPv6ExtHdrFragment(nh=17, id=pid, m=1)/str(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=17, id=pid, offset=1)/str(packet)[48: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 udp") +for a in ans: + if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \ + ipv6nh[a.payload.nh] == 'UDP' and \ + a.payload.payload.sport == 7: + port=a.payload.payload.dport + print "port=%d" % (port) + if port != pid: + print "WRONG UDP ECHO REPLY PORT" + exit(2) + data=a.payload.payload.load + print "payload=%s" % (data) + if data == payload: + exit(0) + print "PAYLOAD!=%s" % (payload) + exit(1) +print "NO UDP ECHO REPLY" +exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_udppayload.py b/regress/sys/netinet6/frag6/frag6_udppayload.py new file mode 100644 index 00000000000..4b4528c53a2 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_udppayload.py @@ -0,0 +1,45 @@ +#!/usr/local/bin/python2.7 +# send 2 udp fragments with splitted payload + +# |--------| +# |----| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/UDP(sport=pid, dport=7)/payload +frag=[] +frag.append(IPv6ExtHdrFragment(nh=17, id=pid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=17, id=pid, offset=2)/str(packet)[56: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 udp") +for a in ans: + if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \ + ipv6nh[a.payload.nh] == 'UDP' and \ + a.payload.payload.sport == 7: + port=a.payload.payload.dport + print "port=%d" % (port) + if port != pid: + print "WRONG UDP ECHO REPLY PORT" + exit(2) + data=a.payload.payload.load + print "payload=%s" % (data) + if data == payload: + exit(0) + print "PAYLOAD!=%s" % (payload) + exit(1) +print "NO UDP ECHO REPLY" +exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_zerofirst.py b/regress/sys/netinet6/frag6/frag6_zerofirst.py new file mode 100644 index 00000000000..19e537abd05 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_zerofirst.py @@ -0,0 +1,47 @@ +#!/usr/local/bin/python2.7 +# send ping6 fragment without payload with other proto before first fragment + +# || +# |---------| +# |----| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=pid, data=payload) +frag=[] +frag.append(IPv6ExtHdrFragment(nh=59, id=pid, m=1)) +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, offset=2)/str(packet)[56: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) diff --git a/regress/sys/netinet6/frag6/frag6_zerosecond.py b/regress/sys/netinet6/frag6/frag6_zerosecond.py new file mode 100644 index 00000000000..5c53cf516f9 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_zerosecond.py @@ -0,0 +1,47 @@ +#!/usr/local/bin/python2.7 +# send ping6 fragment without payload with other proto after the first fragment + +# |---------| +# || +# |----| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=pid, data=payload) +frag=[] +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=59, id=pid, m=1)) +frag.append(IPv6ExtHdrFragment(nh=58, id=pid, offset=2)/str(packet)[56: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) |