1# $OpenBSD: Makefile,v 1.6 2024/01/16 06:40:07 anton Exp $ 2 3REGRESS_TARGETS= hit miss cleanup flags 4CLEANFILES= stamp-* \ 5 pf-instab.conf \ 6 pf-instance.conf \ 7 pf-reftab.conf \ 8 table-ref.conf \ 9 table-pgone.out \ 10 table-persist.out \ 11 table-ref.out \ 12 table-refgone.out 13 14 15stamp-setup: 16 ${SUDO} pfctl -q -a regress/ttest -Fa || exit 0 17 ${SUDO} pfctl -qt __regress_tbl -T add -f ${.CURDIR}/table.in 18 date >$@ 19 20cleanup: 21 rm -f stamp-setup 22 ${SUDO} pfctl -qt __regress_tbl -T kill 23 ${SUDO} pfctl -q -a regress/ttest -Fr 24 ${SUDO} pfctl -q -a regress/ttest -qt instance -T kill 25 26hit: stamp-setup 27 for i in `cat ${.CURDIR}/table.hit`; do \ 28 echo -n "hit $$i "; \ 29 ${SUDO} pfctl -qt __regress_tbl -T test $$i || exit 1; \ 30 echo success; \ 31 done; \ 32 exit 0 33 34miss: stamp-setup 35 for i in `cat ${.CURDIR}/table.miss`; do \ 36 echo -n "miss $$i "; \ 37 ${SUDO} pfctl -qt __regress_tbl -T test $$i && exit 1; \ 38 echo success; \ 39 done; \ 40 exit 0 41 42# 43# tables <instance> and <reference> are both referenced by rule only 44# 45pf-instab.conf: 46 @echo 'table <instance> { 192.168.1.0/24 }' > $@ 47 @echo 'pass in from <instance> to <reference>' >> $@ 48 49# 50# table <instance> is active and referred by rule, table <reference> 51# is referenced only. 52pf-reftab.conf: 53 @echo 'pass in from <instance> to <reference>' > $@ 54 55# 56# check persistent flag (p) is gone from table <instance> after 57# we load pf-instab.conf. Deals with case when persistent table <instance> 58# exists before pf-instab.conf gets loaded. 59# 60table-pgone.out: 61 @echo '--a-r-- instance@regress/ttest' > $@ 62 @echo '----r-- reference@regress/ttest' >> $@ 63 64# 65# verify table <instance> got persistent flag after we 66# run 'pfctl -t instance -T add ...' 67# 68table-persist.out: 69 @echo '-pa-r-- instance@regress/ttest' > $@ 70 @echo '----r-- reference@regress/ttest' >> $@ 71 72# 73# verify tables <instance> and <reference> are created on behalf of 74# reference by rule after pf-reftab.conf got loaded. 75# 76table-ref.out: 77 @echo '----r-- instance@regress/ttest' > $@ 78 @echo '----r-- reference@regress/ttest' >> $@ 79 80# 81# verify reference to <instance> table (persistent) is gone 82# after rules got flushed 83# 84table-refgone.out: 85 @echo '-pa---- instance@regress/ttest' > $@ 86 87flags: pf-instab.conf pf-reftab.conf table-pgone.out table-persist.out \ 88 table-ref.out table-refgone.out 89 @echo 'loading pf-reftab,conf (tables referenced by rules only)' 90 @cat pf-reftab.conf 91 ${SUDO} pfctl -a regress/ttest -f pf-reftab.conf 92 @echo 'tables <reference> and <instance> should both have ----r--' 93 ${SUDO} pfctl -a regress/ttest -sT -vg | diff table-ref.out - 94 @echo 'creating <instance> table on command line, flags should be:' 95 @cat table-persist.out 96 ${SUDO} pfctl -a regress/ttest -t instance -T add 192.168.1.0/24 97 ${SUDO} pfctl -a regress/ttest -sT -vg | diff table-persist.out - 98 @echo 'flushing rules' 99 ${SUDO} pfctl -a regress/ttest -Fr 100 @echo 'table <reference> should be gone, table <instance> should stay' 101 ${SUDO} pfctl -a regress/ttest -sT -vg | diff table-refgone.out - 102 @echo 'loading pf-instab.conf' 103 @cat pf-instab.conf 104 ${SUDO} pfctl -a regress/ttest -f pf-instab.conf 105 @echo 'table <instance> loses -p- flag:' 106 @cat table-pgone.out 107 ${SUDO} pfctl -a regress/ttest -sT -vg | diff table-pgone.out - 108 @echo 'flusing rules, both tables should be gone' 109 ${SUDO} pfctl -a regress/ttest -Fr 110 @echo 'anchor regress/ttest must be gone' 111 ${SUDO} pfctl -a regress/ttest -sr 2>&1 | grep 'pfctl: Anchor does not exist' 112 113.PHONY: hit miss flags 114 115.include <bsd.regress.mk> 116