xref: /openbsd/regress/sys/netinet6/rh0/Makefile (revision 0502cf93)
1*0502cf93Stb#	$OpenBSD: Makefile,v 1.7 2016/10/19 14:31:19 tb Exp $
2694d4422Sbluhm
3694d4422Sbluhm# The following ports must be installed:
4694d4422Sbluhm#
5694d4422Sbluhm# python-2.7		interpreted object-oriented programming language
6694d4422Sbluhm# py-libdnet		python interface to libdnet
7694d4422Sbluhm# scapy			powerful interactive packet manipulation in python
8694d4422Sbluhm
9*0502cf93Stb.if ! (make(clean) || make(cleandir) || make(obj))
10a91e3c70Sbluhm# Check wether all required python packages are installed.  If some
11a91e3c70Sbluhm# are missing print a warning and skip the tests, but do not fail.
12a91e3c70SbluhmPYTHON_IMPORT != python2.7 -c 'from scapy.all import *' 2>&1 || true
13*0502cf93Stb.endif
14a91e3c70Sbluhm.if ! empty(PYTHON_IMPORT)
15a91e3c70Sbluhmregress:
16a91e3c70Sbluhm	@echo '${PYTHON_IMPORT}'
17a91e3c70Sbluhm	@echo install python and the scapy module for additional tests
1854eefd0cSbluhm	@echo SKIPPED
19a91e3c70Sbluhm.endif
20a91e3c70Sbluhm
21694d4422Sbluhm# This test needs a manual setup of two machines
22694d4422Sbluhm# Set up machines: SRC DST
23694d4422Sbluhm# SRC is the machine where this makefile is running.
24694d4422Sbluhm# DST is running OpenBSD with pf disabled to test the IPv6 stack.
25694d4422Sbluhm# SRT source routed host, no packets reach this host,
26694d4422Sbluhm#     it represents just bunch of addresses
27694d4422Sbluhm#
28694d4422Sbluhm# +---+   1   +---+       +---+
29694d4422Sbluhm# |SRC| ----> |DST|       |SRT|
30694d4422Sbluhm# +---+       +---+       +---+
31694d4422Sbluhm#     out    in   out    in   out
32694d4422Sbluhm
33694d4422Sbluhm# Configure Addresses on the machines.
34694d4422Sbluhm# Adapt interface and address variables to your local setup.
35694d4422Sbluhm#
36a91e3c70SbluhmSRC_IF ?=
37a91e3c70SbluhmSRC_MAC ?=
38a91e3c70SbluhmDST_MAC ?=
39694d4422Sbluhm
40a91e3c70SbluhmSRC_OUT6 ?=
41a91e3c70SbluhmDST_IN6 ?=
42a91e3c70SbluhmDST_OUT6 ?=
43a91e3c70SbluhmSRT_IN6 ?=
44a91e3c70SbluhmSRT_OUT6 ?=
45a91e3c70Sbluhm
46a91e3c70Sbluhm.if empty (SRC_IF) || empty (SRC_MAC) || empty (DST_MAC) || \
47a91e3c70Sbluhm    empty (SRC_OUT6) || empty (DST_IN6) || empty (DST_OUT6) || \
48a91e3c70Sbluhm    empty (SRT_IN6) || empty (SRT_OUT6)
49a91e3c70Sbluhmregress:
50a91e3c70Sbluhm	@echo this tests needs a remote machine to operate on
51a91e3c70Sbluhm	@echo SRC_IF SRC_MAC DST_MAC SRC_OUT6 DST_IN6 DST_OUT6
52a91e3c70Sbluhm	@echo SRT_IN6 SRT_OUT6 are empty
53a91e3c70Sbluhm	@echo fill out these variables for additional tests
5454eefd0cSbluhm	@echo SKIPPED
55a91e3c70Sbluhm.endif
56694d4422Sbluhm
57694d4422Sbluhmdepend: addr.py
58694d4422Sbluhm
59694d4422Sbluhm# Create python include file containing the addresses.
60694d4422Sbluhmaddr.py: Makefile
61694d4422Sbluhm	rm -f $@ $@.tmp
62694d4422Sbluhm	echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp
63694d4422Sbluhm	echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp
64694d4422Sbluhm	echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp
65694d4422Sbluhm.for var in SRC_OUT DST_IN DST_OUT SRT_IN SRT_OUT
66694d4422Sbluhm	echo '${var}6 = "${${var}6}"' >>$@.tmp
67694d4422Sbluhm.endfor
68694d4422Sbluhm	mv $@.tmp $@
69694d4422Sbluhm
70a91e3c70Sbluhm# Set variables so that make runs with and without obj directory.
71a91e3c70Sbluhm# Only do that if necessary to keep visible output short.
72a91e3c70Sbluhm.if ${.CURDIR} == ${.OBJDIR}
73a91e3c70SbluhmPYTHON =	python2.7 ./
74a91e3c70Sbluhm.else
75a91e3c70SbluhmPYTHON =	PYTHONPATH=${.OBJDIR} python2.7 ${.CURDIR}/
76a91e3c70Sbluhm.endif
77a91e3c70Sbluhm
787e8c0af0Sbluhm# Send ping6 packet without routing header type 0
797e8c0af0SbluhmTARGETS +=	rh0-none
807e8c0af0Sbluhmrun-regress-rh0-none: addr.py
81a91e3c70Sbluhm	@echo '\n======== $@ ========'
827e8c0af0Sbluhm	@echo Check without routing header type 0
837e8c0af0Sbluhm	${SUDO} ${PYTHON}rh0_none.py
84694d4422Sbluhm
85a91e3c70Sbluhm# Send ping6 packet with routing header type 0 but empty address list
86a91e3c70SbluhmTARGETS +=	rh0-empty
87a91e3c70Sbluhmrun-regress-rh0-empty: addr.py
88694d4422Sbluhm	@echo '\n======== $@ ========'
89a91e3c70Sbluhm	@echo Check routing header type 0 with empty address list
90a91e3c70Sbluhm	${SUDO} ${PYTHON}rh0_empty.py
91a91e3c70Sbluhm
92a91e3c70SbluhmTARGETS +=	rh0-final
93a91e3c70Sbluhm# Send ping6 packet with routing header type 0 to the final destination
94a91e3c70Sbluhmrun-regress-rh0-final: addr.py
95a91e3c70Sbluhm	@echo '\n======== $@ ========'
96a91e3c70Sbluhm	@echo Check routing header type 0 to the final destination
97a91e3c70Sbluhm	${SUDO} ${PYTHON}rh0_final.py
98a91e3c70Sbluhm
99a91e3c70SbluhmTARGETS +=	rh0-route
100a91e3c70Sbluhm# Send ping6 packet with routing header type 0 to be source routed
101a91e3c70Sbluhmrun-regress-rh0-route: addr.py
102a91e3c70Sbluhm	@echo '\n======== $@ ========'
103a91e3c70Sbluhm	@echo Check routing header type 0 to be source routed
104a91e3c70Sbluhm	${SUDO} ${PYTHON}rh0_route.py
105694d4422Sbluhm
106c733c035Sbluhm# Send with fragment and routing header type 0 but empty address list
107c733c035SbluhmTARGETS +=	rh0-frag-empty
108c733c035Sbluhmrun-regress-rh0-frag-empty: addr.py
109c733c035Sbluhm	@echo '\n======== $@ ========'
110c733c035Sbluhm	@echo Check fragment and routing header type 0 with empty address list
111c733c035Sbluhm	${SUDO} ${PYTHON}rh0_frag_empty.py
112c733c035Sbluhm
113c733c035SbluhmTARGETS +=	rh0-frag-final
114c733c035Sbluhm# Send with fragment and routing header type 0 to the final destination
115c733c035Sbluhmrun-regress-rh0-frag-final: addr.py
116c733c035Sbluhm	@echo '\n======== $@ ========'
117c733c035Sbluhm	@echo Check fragment and routing header type 0 to the final destination
118c733c035Sbluhm	${SUDO} ${PYTHON}rh0_frag_final.py
119c733c035Sbluhm
120c733c035SbluhmTARGETS +=	rh0-frag-route
121c733c035Sbluhm# Send with fragment and routing header type 0 to be source routed
122c733c035Sbluhmrun-regress-rh0-frag-route: addr.py
123c733c035Sbluhm	@echo '\n======== $@ ========'
124c733c035Sbluhm	@echo Check fragment and routing header type 0 to be source routed
125c733c035Sbluhm	${SUDO} ${PYTHON}rh0_frag_route.py
126c733c035Sbluhm
127c733c035SbluhmTARGETS +=	rh0-frag2
128c733c035Sbluhm# Send with fragment and routing header type 0 to be source routed
129c733c035Sbluhmrun-regress-rh0-frag2: addr.py
130c733c035Sbluhm	@echo '\n======== $@ ========'
131c733c035Sbluhm	@echo Check routing header type 0 in the second fragment
132c733c035Sbluhm	${SUDO} ${PYTHON}rh0_frag2.py
133c733c035Sbluhm
134694d4422SbluhmREGRESS_TARGETS =	${TARGETS:S/^/run-regress-/}
135694d4422Sbluhm
136694d4422SbluhmCLEANFILES +=		addr.py *.pyc *.log
137694d4422Sbluhm
1387e8c0af0Sbluhm.PHONY: check-setup
1397e8c0af0Sbluhm
1407e8c0af0Sbluhm# Check wether the address, route and remote setup is correct
1417e8c0af0Sbluhmcheck-setup:
142c54bd846Sbluhm	@echo '\n======== $@ ========'
143c54bd846Sbluhm	route -n get -inet6 ${SRC_OUT6} | grep -q 'flags: .*LOCAL'
1447e8c0af0Sbluhm	ping6 -n -c 1 ${SRC_OUT6}
145c54bd846Sbluhm	route -n get -inet6 ${DST_IN6} | grep -q 'interface: ${SRC_IF}$$'
1467e8c0af0Sbluhm	ping6 -n -c 1 ${DST_IN6}
147c54bd846Sbluhm	route -n get -inet6 ${DST_OUT6} | grep -q 'gateway: ${DST_IN6}$$'
1487e8c0af0Sbluhm	ping6 -n -c 1 ${DST_OUT6}
149c54bd846Sbluhm	route -n get -inet6 ${SRT_IN6} | grep -q 'gateway: ${DST_IN6}$$'
150c54bd846Sbluhm	ndp -n ${DST_IN6} | grep -q ' ${DST_MAC} '
151c733c035Sbluhm.if defined(REMOTE_SSH)
152c733c035Sbluhm	ssh ${REMOTE_SSH} ${SUDO} pfctl -si | grep '^Status: Disabled '
153c733c035Sbluhm.endif
1547e8c0af0Sbluhm
155694d4422Sbluhm.include <bsd.regress.mk>
156