diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2013-11-13 23:13:05 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2013-11-13 23:13:05 +0000 |
commit | c06ba327f2960fc4eece0a32c5ee3a21cab1fe55 (patch) | |
tree | 385fd6f5ecec20496703b5b5364e23a1879a0c92 /regress/sys | |
parent | 033a066cbf11557cabc369d28e45c57f9435f16a (diff) |
Add a check-setup target to make sure that all addresses and routes
are configured correctly. Add a scapy test that creates a packet
without routing header to check the setup.
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/netinet6/rh0/Makefile | 37 | ||||
-rw-r--r-- | regress/sys/netinet6/rh0/rh0_none.py | 39 |
2 files changed, 58 insertions, 18 deletions
diff --git a/regress/sys/netinet6/rh0/Makefile b/regress/sys/netinet6/rh0/Makefile index 7cc58297246..d777fa01523 100644 --- a/regress/sys/netinet6/rh0/Makefile +++ b/regress/sys/netinet6/rh0/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 2013/10/31 01:24:06 bluhm Exp $ +# $OpenBSD: Makefile,v 1.3 2013/11/13 23:13:04 bluhm Exp $ # The following ports must be installed: # @@ -71,24 +71,12 @@ PYTHON = python2.7 ./ PYTHON = PYTHONPATH=${.OBJDIR} python2.7 ${.CURDIR}/ .endif -# Check routes. This ensures that and the local routing tables is set up. -TARGETS += route6 -run-regress-route6: +# Send ping6 packet without routing header type 0 +TARGETS += rh0-none +run-regress-rh0-none: addr.py @echo '\n======== $@ ========' -.for ip in DST_OUT SRT_IN - @echo Check route6 destination ${ip}6 gateway DST_IN6: - route -n get -inet6 ${${ip}6}/64 | grep 'gateway: ${DST_IN6}$$' -.endfor - -# 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 + @echo Check without routing header type 0 + ${SUDO} ${PYTHON}rh0_none.py # Send ping6 packet with routing header type 0 but empty address list TARGETS += rh0-empty @@ -115,4 +103,17 @@ REGRESS_TARGETS = ${TARGETS:S/^/run-regress-/} CLEANFILES += addr.py *.pyc *.log +.PHONY: check-setup + +# Check wether the address, route and remote setup is correct +check-setup: + route -n get -inet6 ${SRC_OUT6} | grep 'interface: lo0$$' + ping6 -n -c 1 ${SRC_OUT6} + route -n get -inet6 ${DST_IN6} | grep 'interface: ${SRC_IF}$$' + ping6 -n -c 1 ${DST_IN6} + route -n get -inet6 ${DST_OUT6} | grep 'gateway: ${DST_IN6}$$' + ping6 -n -c 1 ${DST_OUT6} + route -n get -inet6 ${SRT_IN6} | grep 'gateway: ${DST_IN6}$$' + ndp -n ${DST_IN6} | grep ' ${DST_MAC} ' + .include <bsd.regress.mk> diff --git a/regress/sys/netinet6/rh0/rh0_none.py b/regress/sys/netinet6/rh0/rh0_none.py new file mode 100644 index 00000000000..e144c405a31 --- /dev/null +++ b/regress/sys/netinet6/rh0/rh0_none.py @@ -0,0 +1,39 @@ +#!/usr/local/bin/python2.7 +# send a ping6 packet without routing header type 0 +# we expect an echo reply, as there is no routing header + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLMNOP" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/\ + 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) |