xref: /openbsd/regress/sys/netinet6/rh0/Makefile (revision 91f110e0)
1#	$OpenBSD: Makefile,v 1.4 2013/11/17 20:16:27 bluhm Exp $
2
3# The following ports must be installed:
4#
5# python-2.7		interpreted object-oriented programming language
6# py-libdnet		python interface to libdnet
7# scapy			powerful interactive packet manipulation in python
8
9# Check wether all required python packages are installed.  If some
10# are missing print a warning and skip the tests, but do not fail.
11PYTHON_IMPORT != python2.7 -c 'from scapy.all import *' 2>&1 || true
12.if ! empty(PYTHON_IMPORT)
13regress:
14	@echo '${PYTHON_IMPORT}'
15	@echo install python and the scapy module for additional tests
16.endif
17
18# This test needs a manual setup of two machines
19# Set up machines: SRC DST
20# SRC is the machine where this makefile is running.
21# DST is running OpenBSD with pf disabled to test the IPv6 stack.
22# SRT source routed host, no packets reach this host,
23#     it represents just bunch of addresses
24#
25# +---+   1   +---+       +---+
26# |SRC| ----> |DST|       |SRT|
27# +---+       +---+       +---+
28#     out    in   out    in   out
29
30# Configure Addresses on the machines.
31# Adapt interface and address variables to your local setup.
32#
33SRC_IF ?=
34SRC_MAC ?=
35DST_MAC ?=
36
37SRC_OUT6 ?=
38DST_IN6 ?=
39DST_OUT6 ?=
40SRT_IN6 ?=
41SRT_OUT6 ?=
42
43.if empty (SRC_IF) || empty (SRC_MAC) || empty (DST_MAC) || \
44    empty (SRC_OUT6) || empty (DST_IN6) || empty (DST_OUT6) || \
45    empty (SRT_IN6) || empty (SRT_OUT6)
46regress:
47	@echo this tests needs a remote machine to operate on
48	@echo SRC_IF SRC_MAC DST_MAC SRC_OUT6 DST_IN6 DST_OUT6
49	@echo SRT_IN6 SRT_OUT6 are empty
50	@echo fill out these variables for additional tests
51.endif
52
53depend: addr.py
54
55# Create python include file containing the addresses.
56addr.py: Makefile
57	rm -f $@ $@.tmp
58	echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp
59	echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp
60	echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp
61.for var in SRC_OUT DST_IN DST_OUT SRT_IN SRT_OUT
62	echo '${var}6 = "${${var}6}"' >>$@.tmp
63.endfor
64	mv $@.tmp $@
65
66# Set variables so that make runs with and without obj directory.
67# Only do that if necessary to keep visible output short.
68.if ${.CURDIR} == ${.OBJDIR}
69PYTHON =	python2.7 ./
70.else
71PYTHON =	PYTHONPATH=${.OBJDIR} python2.7 ${.CURDIR}/
72.endif
73
74# Send ping6 packet without routing header type 0
75TARGETS +=	rh0-none
76run-regress-rh0-none: addr.py
77	@echo '\n======== $@ ========'
78	@echo Check without routing header type 0
79	${SUDO} ${PYTHON}rh0_none.py
80
81# Send ping6 packet with routing header type 0 but empty address list
82TARGETS +=	rh0-empty
83run-regress-rh0-empty: addr.py
84	@echo '\n======== $@ ========'
85	@echo Check routing header type 0 with empty address list
86	${SUDO} ${PYTHON}rh0_empty.py
87
88TARGETS +=	rh0-final
89# Send ping6 packet with routing header type 0 to the final destination
90run-regress-rh0-final: addr.py
91	@echo '\n======== $@ ========'
92	@echo Check routing header type 0 to the final destination
93	${SUDO} ${PYTHON}rh0_final.py
94
95TARGETS +=	rh0-route
96# Send ping6 packet with routing header type 0 to be source routed
97run-regress-rh0-route: addr.py
98	@echo '\n======== $@ ========'
99	@echo Check routing header type 0 to be source routed
100	${SUDO} ${PYTHON}rh0_route.py
101
102# Send with fragment and routing header type 0 but empty address list
103TARGETS +=	rh0-frag-empty
104run-regress-rh0-frag-empty: addr.py
105	@echo '\n======== $@ ========'
106	@echo Check fragment and routing header type 0 with empty address list
107	${SUDO} ${PYTHON}rh0_frag_empty.py
108
109TARGETS +=	rh0-frag-final
110# Send with fragment and routing header type 0 to the final destination
111run-regress-rh0-frag-final: addr.py
112	@echo '\n======== $@ ========'
113	@echo Check fragment and routing header type 0 to the final destination
114	${SUDO} ${PYTHON}rh0_frag_final.py
115
116TARGETS +=	rh0-frag-route
117# Send with fragment and routing header type 0 to be source routed
118run-regress-rh0-frag-route: addr.py
119	@echo '\n======== $@ ========'
120	@echo Check fragment and routing header type 0 to be source routed
121	${SUDO} ${PYTHON}rh0_frag_route.py
122
123TARGETS +=	rh0-frag2
124# Send with fragment and routing header type 0 to be source routed
125run-regress-rh0-frag2: addr.py
126	@echo '\n======== $@ ========'
127	@echo Check routing header type 0 in the second fragment
128	${SUDO} ${PYTHON}rh0_frag2.py
129
130REGRESS_TARGETS =	${TARGETS:S/^/run-regress-/}
131
132CLEANFILES +=		addr.py *.pyc *.log
133
134.PHONY: check-setup
135
136# Check wether the address, route and remote setup is correct
137check-setup:
138	route -n get -inet6 ${SRC_OUT6} | grep 'interface: lo0$$'
139	ping6 -n -c 1 ${SRC_OUT6}
140	route -n get -inet6 ${DST_IN6} | grep 'interface: ${SRC_IF}$$'
141	ping6 -n -c 1 ${DST_IN6}
142	route -n get -inet6 ${DST_OUT6} | grep 'gateway: ${DST_IN6}$$'
143	ping6 -n -c 1 ${DST_OUT6}
144	route -n get -inet6 ${SRT_IN6} | grep 'gateway: ${DST_IN6}$$'
145	ndp -n ${DST_IN6} | grep ' ${DST_MAC} '
146.if defined(REMOTE_SSH)
147	ssh ${REMOTE_SSH} ${SUDO} pfctl -si | grep '^Status: Disabled '
148.endif
149
150.include <bsd.regress.mk>
151