xref: /openbsd/regress/sys/net/etherip/Makefile (revision 427e22f8)
1#	$OpenBSD: Makefile,v 1.8 2023/10/19 18:36:40 anton Exp $
2
3# Copyright (c) 2017 Alexander Bluhm <bluhm@openbsd.org>
4# Copyright (c) 2015 Vincent Gross <vgross@openbsd.org>
5#
6# Permission to use, copy, modify, and distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9#
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
18# This tests creates a routing domain setup with bridge, vether,
19# etherip, pair.  Then ping packets are sent through these interfaces.
20# Finally the setup is destroyed.
21
22SYSCTL_ETHERIP !=	sysctl net.inet.etherip.allow
23
24.if ${SYSCTL_ETHERIP:C/.*=//} != 1
25regress:
26	@echo "${SYSCTL_ETHERIP}"
27	@echo set this sysctl to 1 for additional tests
28	@echo SKIPPED
29.endif
30
31# This test uses routing domain and interface number 11 and 12.
32# Adjust it here, if you want to use something else.
33N1 =		11
34N2 =		12
35NUMS =		${N1} ${N2}
36IFS =		bridge vether etherip pair
37
38.PHONY: busy-interfaces busy-rdomains ifconfig unconfig
39
40REGRESS_SETUP_ONCE +=	busy-interfaces
41busy-interfaces:
42	# Check if interfaces are busy.
43.for n in ${NUMS}
44.for i in ${IFS}
45	@if ! /sbin/ifconfig $i$n 2>&1 | grep -q "no such interface"; then\
46	    echo interface $i$n is already used >&2; exit 1; fi
47.endfor
48.endfor
49
50REGRESS_SETUP_ONCE +=	busy-rdomains
51busy-rdomains:
52	# Check if rdomains are busy.
53.for n in ${NUMS}
54	@if /sbin/ifconfig | grep -v '^lo$n:' | grep ' rdomain $n '; then\
55	    echo routing domain $n is already used >&2; exit 1; fi
56.endfor
57
58REGRESS_SETUP_ONCE +=	ifconfig
59ifconfig: unconfig
60	# Create and configure interfaces.
61.for n in ${NUMS}
62.for i in ${IFS}
63	${SUDO} /sbin/ifconfig $i$n create rdomain $n
64.endfor
65.endfor
66	${SUDO} /sbin/ifconfig pair${N1}    172.31.0.1/24
67	${SUDO} /sbin/ifconfig pair${N2}    172.31.0.2/24 patch pair${N1}
68	${SUDO} /sbin/ifconfig vether${N1}  192.168.0.1
69	${SUDO} /sbin/ifconfig vether${N2}  192.168.0.2
70	${SUDO} /sbin/ifconfig etherip${N1} tunneldomain ${N1}
71	${SUDO} /sbin/ifconfig etherip${N2} tunneldomain ${N2}
72	${SUDO} /sbin/ifconfig bridge${N1}  add vether${N1} add etherip${N1} up
73	${SUDO} /sbin/ifconfig bridge${N2}  add vether${N2} add etherip${N2} up
74	${SUDO} /sbin/ifconfig etherip${N1} tunnel 172.31.0.1 172.31.0.2 up
75	${SUDO} /sbin/ifconfig etherip${N2} tunnel 172.31.0.2 172.31.0.1 up
76
77REGRESS_CLEANUP +=	unconfig
78unconfig:
79	# Destroy interfaces.
80.for n in ${NUMS}
81.for i in ${IFS}
82	-${SUDO} /sbin/ifconfig $i$n destroy
83.endfor
84.endfor
85	-${SUDO} /sbin/ifconfig lo${N1} destroy
86	-${SUDO} /sbin/ifconfig lo${N2} destroy
87	rm -f stamp-ifconfig
88
89REGRESS_TARGETS +=	run-ping-1-2
90run-ping-1-2:
91	/sbin/ping -n -w 1 -c 1 -V ${N1} 192.168.0.2
92
93REGRESS_TARGETS +=	run-ping-2-1
94run-ping-2-1:
95	/sbin/ping -n -w 1 -c 1 -V ${N2} 192.168.0.1
96
97.include <bsd.regress.mk>
98