summaryrefslogtreecommitdiff
path: root/regress/sys/net/etherip/Makefile
blob: b5937bf68843864a42b92f01ae5388473e0d3b86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#	$OpenBSD: Makefile,v 1.4 2017/11/15 15:00:04 bluhm Exp $

# Copyright (c) 2017 Alexander Bluhm <bluhm@openbsd.org>
# Copyright (c) 2015 Vincent Gross <vgross@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# This tests creates a routing doamin setup with bridge, vether,
# etherip, pair.  Then ping packets are sent through these interfaces.
# Finally the setup is destroyed.

SYSCTL_ETHERIP !=	sysctl net.inet.etherip.allow

.if ${SYSCTL_ETHERIP:C/.*=//} != 1
regress:
	@echo "${SYSCTL_ETHERIP}"
	@echo set this sysctl to 1 for additional tests
	@echo SKIPPED
.endif

# This test uses routing doamin and interface number 11 and 12.
# Adjust it here, if ue want to use something else.
N1 =		11
N2 =		12
NUMS =		${N1} ${N2}
IFS =		bridge vether etherip pair

CLEANFILES =	stamp-*

.PHONY: check-interfaces check-rdomains ifconfig unconfig

check-interfaces:
	# check if interfaces are busy
.for n in ${NUMS}
.for i in ${IFS}
	@if ! /sbin/ifconfig ${i}${n} 2>&1 | grep -q "no such interface"; then\
	    echo interface ${i}${n} is already used >&2; exit 1; fi
.endfor
.endfor

check-rdomains:
	# check if rdomains are busy
.for n in ${NUMS}
	@if /sbin/ifconfig | grep -v '^lo${n}:' | grep ' rdomain ${n} '; then\
	    echo routing domain ${n} is already used >&2; exit 1; fi
.endfor

ifconfig: check-interfaces check-rdomains
	# create and configure interfaces
.for n in ${NUMS}
.for i in ${IFS}
	${SUDO} /sbin/ifconfig ${i}${n} create rdomain ${n}
.endfor
.endfor
	${SUDO} /sbin/ifconfig pair${N1}    172.31.0.1/24
	${SUDO} /sbin/ifconfig pair${N2}    172.31.0.2/24 patch pair${N1}
	${SUDO} /sbin/ifconfig vether${N1}  192.168.0.1
	${SUDO} /sbin/ifconfig vether${N2}  192.168.0.2
	${SUDO} /sbin/ifconfig etherip${N1} tunneldomain ${N1}
	${SUDO} /sbin/ifconfig etherip${N2} tunneldomain ${N2}
	${SUDO} /sbin/ifconfig bridge${N1}  add vether${N1} add etherip${N1} up
	${SUDO} /sbin/ifconfig bridge${N2}  add vether${N2} add etherip${N2} up
	${SUDO} /sbin/ifconfig etherip${N1} tunnel 172.31.0.1 172.31.0.2 up
	${SUDO} /sbin/ifconfig etherip${N2} tunnel 172.31.0.2 172.31.0.1 up

unconfig:
	# destroy interfaces
.for n in ${NUMS}
.for i in ${IFS}
	-${SUDO} /sbin/ifconfig ${i}${n} destroy
.endfor
.endfor
	rm -f stamp-setup

stamp-setup:
	@echo '\n======== $@ ========'
	${.MAKE} -C ${.CURDIR} ifconfig
	date >$@

REGRESS_TARGETS +=	run-regress-ping-1-2
run-regress-ping-1-2: stamp-setup
	@echo '\n======== $@ ========'
	/sbin/ping -n -w 1 -c 1 -V ${N1} 192.168.0.2

REGRESS_TARGETS +=	run-regress-ping-2-1
run-regress-ping-2-1: stamp-setup
	@echo '\n======== $@ ========'
	/sbin/ping -n -w 1 -c 1 -V ${N2} 192.168.0.1

REGRESS_TARGETS +=	run-regress-cleanup
run-regress-cleanup: stamp-setup
	@echo '\n======== $@ ========'
	${.MAKE} -C ${.CURDIR} unconfig

.include <bsd.regress.mk>