summaryrefslogtreecommitdiff
path: root/regress/sbin/pfctl/Makefile
blob: e1e70ac8e0c057c3a867af167743d157ec3b0bc7 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# $OpenBSD: Makefile,v 1.167 2003/12/16 00:30:16 mcbride Exp $

# TARGETS
# pf: feed pfNN.in through pfctl and check wether the output matches pfNN.ok
# selfpf: feed pfctl output through pfctl again and verify it stays the same
# pfail: invalid rulesets pfctl must reject; pfailNN.in and pfailNN.ok
# pfsetup: set up lo1 and perform more tests
# pfr: table tests
# pfsimple: just check wether pfctl accepts a given ruleset, not checking output
# pfload: load ruleset into anchor regress:regress and verify pfctl -vvsr
# pfopt: as target pf, but supply extra command line options

PFTESTS=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
PFTESTS+=28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
PFTESTS+=51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
PFTESTS+=74 75 76 77 78 79 80 81 82 83
PFFAIL=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
PFFAIL+=28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
PFSIMPLE=1 2
PFSETUP=1 2 3 4
PFLOAD=1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29
PFLOAD+=30 31 32 34 36 38 39 40 44 46 47 48 49 54 56 60 61 65 66 67 68 69 70 71
PFLOAD+=72 73 74 75 76 77 78 79 80 81 82
PFALTQ=1 2 3 4 5 6 7 8 9 10 11 12 13 14
# disabled; no altq in anchors
# PFLOAD+=33 35 37 42 43 45 51 58 59 62 63 64
# only testing parser, load test would be useless
# PFLOAD+=6 22 41 50 52 53 55 57 83
PFTABLE=1 2 3 4 5 6 7 8 9 10 11 12 13
PFOPT=1 2 3 4 5

.ifmake !obj && !clean && !cleandir
.BEGIN:
	-${SUDO} ifconfig lo1000000 create
	-${SUDO} ifconfig tun1000000 create
	-${SUDO} ifconfig tun1000001 create

.END:
	${SUDO} ifconfig lo1000000 destroy
# destroy on tun does not work yet
#	${SUDO} ifconfig tun1000000 destroy
#	${SUDO} ifconfig tun1000001 destroy
.endif

.for n in ${PFFAIL}
PFAIL_TARGETS+=pfail${n}
PFAIL_UPDATES+=pfail${n}-update

pfail${n}:
	pfctl -nv -f - < ${.CURDIR}/pfail${n}.in 2>&1 | \
	    diff -u ${.CURDIR}/pfail${n}.ok /dev/stdin

pfail${n}-update:
	if pfctl -nv -f - < ${.CURDIR}/pfail${n}.in > \
	    ${.CURDIR}/pfail${n}.ok 2>&1; then \
		true; \
	fi;
	
.endfor

pfail:		${PFAIL_TARGETS}
pfail-update:	${PFAIL_UPDATES}
REGRESS_TARGETS+=pfail
UPDATE_TARGETS+=pfail-update

.for n in ${PFTESTS}
PF_TARGETS+=pf${n}
PF_UPDATES+=pf${n}-update

pf${n}:
	pfctl -nv -f - < ${.CURDIR}/pf${n}.in | \
	    diff -u ${.CURDIR}/pf${n}.ok /dev/stdin

pf${n}-update:
	pfctl -nv -f - < ${.CURDIR}/pf${n}.in > ${.CURDIR}/pf${n}.ok

SELFPF_TARGETS+=selfpf${n}
selfpf${n}:
	pfctl -nv -f - < ${.CURDIR}/pf${n}.ok | \
	    diff -u ${.CURDIR}/pf${n}.ok /dev/stdin

.endfor

pf:		${PF_TARGETS}
selfpf:		${SELFPF_TARGETS}
pf-update:	${PF_UPDATES}
REGRESS_TARGETS+=pf
REGRESS_TARGETS+=selfpf
UPDATE_TARGETS+=pf-update

.for n in ${PFSIMPLE}
PFSIMPLE_TARGETS+=pfsimple${n}

pfsimple${n}:
	pfctl -nf - < ${.CURDIR}/pfsimple${n}.in

.endfor

pfsimple:	${PFSIMPLE_TARGETS}
REGRESS_TARGETS+=pfsimple

.for n in ${PFLOAD}
PFLOAD_TARGETS+=pfload${n}
PFLOAD_UPDATES+=pfload${n}-update

pfload${n}:
	${SUDO} pfctl -a regress:regress -f - < ${.CURDIR}/pf${n}.in
	(${SUDO} pfctl -a regress:regress -gvvsn; \
	${SUDO} pfctl -a regress:regress -gvvsr) | \
	    diff -u ${.CURDIR}/pf${n}.loaded /dev/stdin
	${SUDO} pfctl -a regress:regress -Fn >/dev/null 2>&1
	${SUDO} pfctl -a regress:regress -Fr >/dev/null 2>&1

pfload${n}-update:
	${SUDO} pfctl -a regress:regress -f - < ${.CURDIR}/pf${n}.in
	(${SUDO} pfctl -a regress:regress -gvvsn; \
	${SUDO} pfctl -a regress:regress -gvvsr) > ${.CURDIR}/pf${n}.loaded
	${SUDO} pfctl -a regress:regress -Fn >/dev/null 2>&1
	${SUDO} pfctl -a regress:regress -Fr >/dev/null 2>&1

.endfor

pfload:		${PFLOAD_TARGETS}
pfload-update:	${PFLOAD_UPDATES}
REGRESS_TARGETS+=pfload
UPDATE_TARGETS+=pfload-update

.for n in ${PFTABLE}
PFR_TARGETS+=pfr${n}
PFR_UPDATES+=pfr${n}-update

pfr${n}:
	${SUDO} /bin/ksh ${.CURDIR}/pfr.exec ${.CURDIR}/pfr${n}.in | \
	    diff -u ${.CURDIR}/pfr${n}.ok /dev/stdin

pfr${n}-update:
	${SUDO} /bin/ksh ${.CURDIR}/pfr.exec ${.CURDIR}/pfr${n}.in > \
	    ${.CURDIR}/pfr${n}.ok

.endfor

pfr:		${PFR_TARGETS}
pfr-update:	${PFR_UPDATES}
NODEFAULT_TARGETS+=pfr

.for n in ${PFOPT}
PFOPT_TARGETS+=pfopt${n}
PFOPT_UPDATES+=pfopt${n}-update

pfopt${n}:
	pfctl -nv -f - `cat ${.CURDIR}/pfopt${n}.opts` \
	    < ${.CURDIR}/pfopt${n}.in | \
	    diff -u ${.CURDIR}/pfopt${n}.ok /dev/stdin

pfopt${n}-update:
	pfctl -nv -f - `cat ${.CURDIR}/pfopt${n}.opts` \
	    < ${.CURDIR}/pfopt${n}.in > ${.CURDIR}/pfopt${n}.ok

.endfor

pfopt:		${PFOPT_TARGETS}
pfopt-update:	${PFOPT_UPDATES}
REGRESS_TARGETS+=pfopt
UPDATE_TARGETS+=pfopt-update

.for n in ${PFSETUP}
PFSETUP_TARGETS+=pfsetup${n}
PFSETUP_UPDATES+=pfsetup${n}-update

pfsetup${n}:
	${SUDO} ${SHELL} ${.CURDIR}/pfsetup${n}.setup
	pfctl -nv -f - < ${.CURDIR}/pfsetup${n}.in | \
	    diff -u ${.CURDIR}/pfsetup${n}.ok /dev/stdin
	${SUDO} ${SHELL} ${.CURDIR}/pfsetup${n}.clean

pfsetup${n}-update:
	${SUDO} ${SHELL} ${.CURDIR}/pfsetup${n}.setup
	pfctl -nv -f - < ${.CURDIR}/pfsetup${n}.in > ${.CURDIR}/pfsetup${n}.ok
	${SUDO} ${SHELL} ${.CURDIR}/pfsetup${n}.clean

.endfor

pfsetup:	${PFSETUP_TARGETS}
pfsetup-update:	${PFSETUP_UPDATES}

NODEFAULT_TARGETS+=pfsetup

.for n in ${PFALTQ}
PFALTQ_TARGETS+=pfaltq${n}
PFALTQ_UPDATES+=pfaltq${n}-update

pfaltq${n}:
	${SUDO} pfctl -Fa >/dev/null 2>&1
	${SUDO} pfctl -f - < ${.CURDIR}/pfaltq${n}.in
	( ${SUDO} pfctl -gsq; \
	${SUDO} pfctl -gsr ) | \
	    diff -u ${.CURDIR}/pfaltq${n}.ok /dev/stdin
	${SUDO} pfctl -Fa >/dev/null 2>&1

pfaltq${n}-update:
	${SUDO} pfctl -Fa >/dev/null 2>&1
	${SUDO} pfctl -f - < ${.CURDIR}/pfaltq${n}.in
	( ${SUDO} pfctl -gsq; \
	${SUDO} pfctl -gsr ) > ${.CURDIR}/pfaltq${n}.ok
	${SUDO} pfctl -Fa >/dev/null 2>&1

.endfor

pfaltq:		${PFALTQ_TARGETS}
pfaltq-update:	${PFALTQ_UPDATES}

NODEFAULT_TARGETS+=pfaltq

update:	${UPDATE_TARGETS}

alltests: ${REGRESS_TARGETS} ${NODEFAULT_TARGETS}

.PHONY: ${REGRESS_TARGETS}

.include <bsd.regress.mk>