diff options
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/netinet6/rh0/Makefile | 70 | ||||
-rw-r--r-- | regress/sys/netinet6/rh0/rh0_empty.py | 41 | ||||
-rw-r--r-- | regress/sys/netinet6/rh0/rh0_final.py | 41 | ||||
-rw-r--r-- | regress/sys/netinet6/rh0/rh0_route.py | 41 |
4 files changed, 193 insertions, 0 deletions
diff --git a/regress/sys/netinet6/rh0/Makefile b/regress/sys/netinet6/rh0/Makefile new file mode 100644 index 00000000000..11417bd9535 --- /dev/null +++ b/regress/sys/netinet6/rh0/Makefile @@ -0,0 +1,70 @@ +# $OpenBSD: Makefile,v 1.1 2013/10/20 13:45:44 bluhm Exp $ + +# The following ports must be installed: +# +# python-2.7 interpreted object-oriented programming language +# py-libdnet python interface to libdnet +# scapy powerful interactive packet manipulation in python + +# This test needs a manual setup of two machines +# 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. +# SRT source routed host, no packets reach this host, +# it represents just bunch of addresses +# +# +---+ 1 +---+ +---+ +# |SRC| ----> |DST| |SRT| +# +---+ +---+ +---+ +# out in out in out + +# Configure Addresses on the machines. +# Adapt interface and address variables to your local setup. +# +SRC_IF ?= tun0 +SRC_MAC ?= fe:e1:ba:d1:56:1f +DST_MAC ?= 70:5f:ca:21:8d:70 + +SRC_OUT6 ?= fdd7:e83e:66bc:7:fce1:baff:fed2:26be +DST_IN6 ?= fdd7:e83e:66bc:7:725f:caff:fe21:8d70 +DST_OUT6 ?= fdd7:e83e:66bc:70:725f:caff:fe21:8d70 +SRT_IN6 ?= fdd7:e83e:66bc:70::1 +SRT_OUT6 ?= fdd7:e83e:66bc:71::1 + +depend: addr.py + +# Create python include file containing the addresses. +addr.py: Makefile + rm -f $@ $@.tmp + echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp + echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp + echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp +.for var in SRC_OUT DST_IN DST_OUT SRT_IN SRT_OUT + echo '${var}6 = "${${var}6}"' >>$@.tmp +.endfor + mv $@.tmp $@ + +# Ping all addresses. This ensures that the ip addresses are configured +# and all routing tables are set up to allow bidirectional packet flow. +TARGETS += ping6 +run-regress-ping6: + @echo '\n======== $@ ========' +.for ip in SRC_OUT DST_IN DST_OUT + @echo Check ping6 ${ip}6: + ping6 -n -c 1 ${${ip}6} +.endfor + +.for i in empty final route +# Send hand-crafted routing header type 0 packets +TARGETS += rh0-${i} +run-regress-rh0-${i}: addr.py + @echo '\n======== $@ ========' + @echo Check routing header type 0 ${i} + ${SUDO} python2.7 rh0_${i}.py +.endfor + +REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/} + +CLEANFILES += addr.py *.pyc *.log + +.include <bsd.regress.mk> diff --git a/regress/sys/netinet6/rh0/rh0_empty.py b/regress/sys/netinet6/rh0/rh0_empty.py new file mode 100644 index 00000000000..f757b9b9e67 --- /dev/null +++ b/regress/sys/netinet6/rh0/rh0_empty.py @@ -0,0 +1,41 @@ +#!/usr/local/bin/python2.7 +# send a ping6 packet with routing header type 0 +# the address list is empty +# we expect an echo reply, as there are no more hops + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLMNOP" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ + IPv6ExtHdrRouting(addresses=[])/\ + ICMPv6EchoRequest(id=pid, data=payload) +eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet + +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 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': + reply=a.payload.payload + id=reply.id + print "id=%#x" % (id) + if id != pid: + print "WRONG ECHO REPLY ID" + exit(2) + data=reply.data + print "payload=%s" % (data) + if data != payload: + print "WRONG PAYLOAD" + exit(2) + exit(0) +print "NO ICMP6 ECHO REPLY" +exit(1) diff --git a/regress/sys/netinet6/rh0/rh0_final.py b/regress/sys/netinet6/rh0/rh0_final.py new file mode 100644 index 00000000000..dc5299333a3 --- /dev/null +++ b/regress/sys/netinet6/rh0/rh0_final.py @@ -0,0 +1,41 @@ +#!/usr/local/bin/python2.7 +# send a ping6 packet with routing header type 0 +# the address pointer is at the final destination +# we expect an echo reply, as there are no more hops + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLMNOP" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ + IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=0)/\ + ICMPv6EchoRequest(id=pid, data=payload) +eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet + +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 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': + reply=a.payload.payload + id=reply.id + print "id=%#x" % (id) + if id != pid: + print "WRONG ECHO REPLY ID" + exit(2) + data=reply.data + print "payload=%s" % (data) + if data != payload: + print "WRONG PAYLOAD" + exit(2) + exit(0) +print "NO ICMP6 ECHO REPLY" +exit(1) diff --git a/regress/sys/netinet6/rh0/rh0_route.py b/regress/sys/netinet6/rh0/rh0_route.py new file mode 100644 index 00000000000..ace7af2400b --- /dev/null +++ b/regress/sys/netinet6/rh0/rh0_route.py @@ -0,0 +1,41 @@ +#!/usr/local/bin/python2.7 +# send a ping6 packet with routing header type 0 +# try to source route +# we expect an ICMP6 error, as we do not support source routing + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLMNOP" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ + IPv6ExtHdrRouting(addresses=[SRT_IN6, SRT_OUT6], segleft=2)/\ + ICMPv6EchoRequest(id=pid, data=payload) +eth=Ether(src=SRC_MAC, dst=DST_MAC)/packet + +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 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] == 'Parameter problem': + pprob=a.payload.payload + code=pprob.code + print "code=%#d" % (code) + if code != 0: + print "WRONG PARAMETER PROBLEM CODE" + exit(2) + prt=pprob.ptr + print "prt=%#d" % (prt) + if prt != 42: + print "WRONG PARAMETER PROBLEM POINTER" + exit(2) + exit(0) +print "NO ICMP6 PARAMETER PROBLEM" +exit(1) |