summaryrefslogtreecommitdiff
path: root/regress/sys/net/etherip/Makefile
blob: 61c8369fa19b87acb93350d712d63e83bdb854a7 (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
#	$OpenBSD: Makefile,v 1.7 2020/12/17 00:39:42 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 domain 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 domain and interface number 11 and 12.
# Adjust it here, if you want to use something else.
N1 =		11
N2 =		12
NUMS =		${N1} ${N2}
IFS =		bridge vether etherip pair

.PHONY: busy-interfaces busy-rdomains ifconfig unconfig

REGRESS_SETUP_ONCE +=	busy-interfaces
busy-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

REGRESS_SETUP_ONCE +=	busy-rdomains
busy-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

REGRESS_SETUP_ONCE +=	ifconfig
ifconfig: unconfig
	# 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

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

REGRESS_TARGETS +=	run-ping-1-2
run-ping-1-2:
	/sbin/ping -n -w 1 -c 1 -V ${N1} 192.168.0.2

REGRESS_TARGETS +=	run-ping-2-1
run-ping-2-1:
	/sbin/ping -n -w 1 -c 1 -V ${N2} 192.168.0.1

.include <bsd.regress.mk>