xref: /openbsd/regress/sys/netinet/pmtu/Makefile (revision 264ca280)
1#	$OpenBSD: Makefile,v 1.2 2016/07/18 09:09:24 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: LOCAL REMOTE
20# LOCAL is the machine where this makefile is running.
21# REMOTE is running OpenBSD with echo and chargen server to test PMTU
22# FAKE is an non existing machine in a non existing network.
23# REMOTE_SSH is the hostname to log in on the REMOTE machine.
24
25# Configure Addresses on the machines.
26# Adapt interface and addresse variables to your local setup.
27#
28LOCAL_IF ?=
29REMOTE_SSH ?=
30
31LOCAL_ADDR ?=
32REMOTE_ADDR ?=
33FAKE_NET ?=
34FAKE_NET_ADDR ?=
35
36LOCAL_ADDR6 ?=
37REMOTE_ADDR6 ?=
38FAKE_NET6 ?=
39FAKE_NET_ADDR6 ?=
40
41.if empty (LOCAL_IF) || empty (REMOTE_SSH) || \
42    empty (LOCAL_ADDR) || empty (LOCAL_ADDR6) || \
43    empty (REMOTE_ADDR) || empty (REMOTE_ADDR6) || \
44    empty (FAKE_NET) || empty (FAKE_NET6) || \
45    empty (FAKE_NET_ADDR) || empty (FAKE_NET_ADDR6)
46regress:
47	@echo This tests needs a remote machine to operate on
48	@echo LOCAL_IF REMOTE_SSH LOCAL_ADDR LOCAL_ADDR6 REMOTE_ADDR
49	@echo REMOTE_ADDR6 FAKE_NET FAKE_NET6 FAKE_NET_ADDR FAKE_NET_ADDR6
50	@echo are empty.  Fill out these variables for additional tests.
51.endif
52
53.if ! empty (REMOTE_SSH)
54.if make (regress) || make (all)
55.BEGIN: pf.conf addr.py
56	@echo
57	${SUDO} true
58	ssh -t ${REMOTE_SSH} ${SUDO} true
59.endif
60.endif
61
62depend: addr.py
63
64# Create python include file containing the addresses.
65addr.py: Makefile
66	rm -f $@ $@.tmp
67	echo 'LOCAL_IF = "${LOCAL_IF}"' >>$@.tmp
68	echo 'LOCAL_MAC = "${LOCAL_MAC}"' >>$@.tmp
69	echo 'REMOTE_MAC = "${REMOTE_MAC}"' >>$@.tmp
70.for var in LOCAL REMOTE FAKE_NET
71	echo '${var}_ADDR = "${${var}_ADDR}"' >>$@.tmp
72	echo '${var}_ADDR6 = "${${var}_ADDR6}"' >>$@.tmp
73.endfor
74	echo 'FAKE_NET = "${FAKE_NET}"' >>$@.tmp
75	echo 'FAKE_NET6 = "${FAKE_NET6}"' >>$@.tmp
76	mv $@.tmp $@
77
78# Set variables so that make runs with and without obj directory.
79# Only do that if necessary to keep visible output short.
80.if ${.CURDIR} == ${.OBJDIR}
81PYTHON =	python2.7 -u ./
82.else
83PYTHON =	PYTHONPATH=${.OBJDIR} python2.7 -u ${.CURDIR}/
84.endif
85
86.PHONY: clean-arp
87
88# Clear local and remote path mtu routes, set fake net route
89reset-route:
90	@echo '\n======== $@ ========'
91	-${SUDO} route -n delete -host ${REMOTE_ADDR}
92	ssh ${REMOTE_SSH} ${SUDO} sh -c "'\
93	    route -n delete -inet -host ${LOCAL_ADDR};\
94	    route -n delete -inet -net ${FAKE_NET};\
95	    route -n delete -inet -host ${FAKE_NET_ADDR};\
96	    route -n add -inet -net ${FAKE_NET} ${LOCAL_ADDR}'"
97reset-route6:
98	@echo '\n======== $@ ========'
99	-${SUDO} route -n delete -host ${REMOTE_ADDR6}
100	ssh ${REMOTE_SSH} ${SUDO} sh -c "'\
101	    route -n delete -inet6 -host ${LOCAL_ADDR6};\
102	    route -n delete -inet6 -net ${FAKE_NET6};\
103	    route -n delete -inet6 -host ${FAKE_NET_ADDR6};\
104	    route -n add -inet6 -net ${FAKE_NET6} ${LOCAL_ADDR6}'"
105
106# Clear host routes and ping all addresses.  This ensures that
107# the IP addresses are configured and all routing table are set up
108# to allow bidirectional packet flow.
109TARGETS +=	ping ping6
110run-regress-ping: reset-route
111	@echo '\n======== $@ ========'
112.for ip in LOCAL_ADDR REMOTE_ADDR
113	@echo Check ping ${ip}
114	ping -n -c 1 ${${ip}}
115.endfor
116run-regress-ping6: reset-route
117	@echo '\n======== $@ ========'
118.for ip in LOCAL_ADDR REMOTE_ADDR
119	@echo Check ping6 ${ip}6
120	ping6 -n -c 1 ${${ip}6}
121.endfor
122
123TARGETS +=	pmtu pmtu6
124run-regress-pmtu: addr.py reset-route
125	@echo '\n======== $@ ========'
126	@echo Send ICMP fragmentation needed after fake TCP connect
127	${SUDO} ${PYTHON}tcp_connect.py
128run-regress-pmtu6: addr.py reset-route6
129	@echo '\n======== $@ ========'
130	@echo Send ICMP6 packet too big after fake TCP connect
131	${SUDO} ${PYTHON}tcp_connect6.py
132
133TARGETS +=	udp6
134run-regress-udp6: addr.py reset-route6
135	@echo '\n======== $@ ========'
136	@echo Send ICMP6 packet too big after UDP echo
137	${SUDO} ${PYTHON}udp_echo6.py
138
139TARGETS +=	gateway6
140run-regress-gateway6: run-regress-udp6
141	@echo '\n======== $@ ========'
142	@echo Remove gateway route of a dynamic PMTU route
143	ssh ${REMOTE_SSH} ${SUDO} route -n delete -inet6 -host ${LOCAL_ADDR6}
144	ssh ${REMOTE_SSH} route -n get -inet6 -host ${FAKE_NET_ADDR6}\
145	    >pmtu.route
146	cat pmtu.route
147	grep -q 'gateway: ${LOCAL_ADDR6}' pmtu.route
148	grep -q 'flags: <UP,GATEWAY,HOST,DYNAMIC,DONE>' pmtu.route
149	${SUDO} ${PYTHON}udp_echo6.py
150
151REGRESS_TARGETS =	${TARGETS:S/^/run-regress-/}
152
153CLEANFILES +=		addr.py *.pyc *.log *.route
154
155.include <bsd.regress.mk>
156