xref: /openbsd/regress/sys/netinet6/nd6/Makefile (revision a6445c1d)
1#	$OpenBSD: Makefile,v 1.2 2013/10/31 01:24:06 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 to test the neighbor discovery states.
22#
23# +---+   1   +---+
24# |SRC| ----> |DST|
25# +---+       +---+
26#     out    in
27
28# Configure Addresses on the machines.
29# Adapt interface and addresse variables to your local setup.
30#
31SRC_IF ?=
32SRC_MAC ?=
33DST_MAC ?=
34
35SRC_OUT6 ?=
36DST_IN6 ?=
37
38# pf rules on DST should look like this:
39#
40# block log
41# pass inet6 proto icmp6 icmp6-type echoreq keep state
42# pass inet6 proto icmp6 icmp6-type neighbrsol keep state
43# pass inet6 proto icmp6 icmp6-type neighbradv keep state
44
45# RFC 4861 7. describes the following test cases for ND:
46#
47# Duplicate Address Detection
48# - request  NS from unspecified address to target solicitated-node multicast
49# - response NA from interface address   to all-nodes multicast
50#
51# Address Resolution
52# - request  NS from interface address   to target solicitated-node multicast
53# - response NA from interface address   to source of NS
54#
55# Unsolicited Neighbor Advertisements
56# - request  NA from interface address   to all-nodes multicast
57#
58# Neighbor Unreachability Detection
59# - request  NS from interface address   to target unicast
60# - response NA from interface address   to source of NS
61
62.if empty (SRC_IF) || empty (SRC_MAC) || empty (DST_MAC) || \
63    empty (SRC_OUT6) || empty (DST_IN6)
64regress:
65	@echo this tests needs a remote machine to operate on
66	@echo SRC_IF SRC_MAC DST_MAC SRC_OUT6 DST_IN6 are empty
67	@echo fill out these variables for additional tests
68.endif
69
70depend: addr.py
71
72# Create python include file containing the addresses.
73addr.py: Makefile
74	rm -f $@ $@.tmp
75	echo 'SRC_IF = "${SRC_IF}"' >>$@.tmp
76	echo 'SRC_MAC = "${SRC_MAC}"' >>$@.tmp
77	echo 'DST_MAC = "${DST_MAC}"' >>$@.tmp
78.for var in SRC_OUT DST_IN
79	echo '${var} = "${${var}}"' >>$@.tmp
80	echo '${var}6 = "${${var}6}"' >>$@.tmp
81.endfor
82	mv $@.tmp $@
83
84# Set variables so that make runs with and without obj directory.
85# Only do that if necessary to keep visible output short.
86.if ${.CURDIR} == ${.OBJDIR}
87PYTHON =	python2.7 ./
88.else
89PYTHON =	PYTHONPATH=${.OBJDIR} python2.7 ${.CURDIR}/
90.endif
91
92# Clear neighbor cache and ping all addresses.  This ensures that
93# the ip addresses are configured and all routing table are set up
94# to allow bidirectional packet flow.
95TARGETS +=	ping6
96run-regress-ping6:
97	@echo '\n======== $@ ========'
98	sudo ndp -c
99.for ip in SRC_OUT DST_IN
100	@echo Check ping6 ${ip}6:
101	ping6 -n -c 1 ${${ip}6}
102.endfor
103
104# Send hand-crafted duplicate address detection neighbor solicitation packet
105TARGETS +=	nd6_dad
106run-regress-nd6_dad: addr.py
107	@echo '\n======== $@ ========'
108	@echo Check duplicate address detection
109	${SUDO} ${PYTHON}nd6_dad.py
110
111# Send hand-crafted address resolution neighbor solicitation packet
112TARGETS +=	nd6_ar
113run-regress-nd6_ar: addr.py
114	@echo '\n======== $@ ========'
115	@echo Check address resolution
116	${SUDO} ${PYTHON}nd6_ar.py
117
118# Send hand-crafted unsolicited neighbor advertisement packet
119TARGETS +=	nd6_una
120run-regress-nd6_una: addr.py
121	@echo '\n======== $@ ========'
122	@echo Check unsolicited neighbor advertisement
123	${SUDO} ${PYTHON}nd6_una.py
124
125# Send hand-crafted neighbor unreachability detection solicitation packet
126TARGETS +=	nd6_nud
127run-regress-nd6_nud: addr.py
128	@echo '\n======== $@ ========'
129	@echo Check neighbor unreachability detection
130	${SUDO} ${PYTHON}nd6_nud.py
131
132REGRESS_TARGETS =	${TARGETS:S/^/run-regress-/}
133
134CLEANFILES +=		addr.py *.pyc *.log
135
136.include <bsd.regress.mk>
137