- regression tests for 'load anchor ... from ...'
authorsashan <sashan@openbsd.org>
Wed, 29 Nov 2017 00:24:32 +0000 (00:24 +0000)
committersashan <sashan@openbsd.org>
Wed, 29 Nov 2017 00:24:32 +0000 (00:24 +0000)
  the test case itself comes from Leonardo Guardati

regress/sbin/pfctl/Makefile
regress/sbin/pfctl/pf112.in [new file with mode: 0644]
regress/sbin/pfctl/pf112.ok [new file with mode: 0644]
regress/sbin/pfctl/pf112.one [new file with mode: 0644]
regress/sbin/pfctl/pf112.two [new file with mode: 0644]
regress/sbin/pfctl/pf113.in [new file with mode: 0644]
regress/sbin/pfctl/pf113.ok [new file with mode: 0644]
regress/sbin/pfctl/pf113.one [new file with mode: 0644]
regress/sbin/pfctl/pf113.two [new file with mode: 0644]

index adc236c..281f282 100644 (file)
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.228 2017/11/24 22:53:55 bluhm Exp $
+# $OpenBSD: Makefile,v 1.229 2017/11/29 00:24:32 sashan Exp $
 
 # TARGETS
 # pf: feed pfNN.in through pfctl and check whether the output matches pfNN.ok
@@ -30,6 +30,7 @@ PFIF2IP=1 2 3
 PFCHKSUM=1 2 3
 PFCMD=1
 PFCMDFAIL=1
+PFLOADANCHORS=112 113
 
 PFCTL ?=       /sbin/pfctl
 
@@ -331,6 +332,31 @@ pfchksum-update:   ${PFCHKSUM_UPDATES}
 NODEFAULT_TARGETS+=pfchksum
 REGRESS_ROOT_TARGETS+=pfchksum
 
+.for n in ${PFLOADANCHORS}
+PFLOADANCHORS_TARGETS+=pfloadanchors${n}
+PFLOADANCHORS_UPDATES+=pfloadanchors${n}-update
+
+pfloadanchors${n}:
+       ${SUDO} ${PFCTL} -a regress -v -f - < ${.CURDIR}/pf${n}.in
+       (${SUDO} ${PFCTL} -a 'regress/*' -sr | \
+           sed -e 's/__automatic_[0-9a-f]*_.*>/__automatic_>/' ) | \
+           diff -u ${.CURDIR}/pf${n}.ok /dev/stdin
+       ${SUDO} ${PFCTL} -o none -a regress -Fr >/dev/null 2>&1
+
+pfloadanchors${n}-update:
+       ${SUDO} ${PFCTL} -a regress -v -f - < ${.CURDIR}/pf${n}.in
+       (${SUDO} ${PFCTL} -a 'regress/*' -sr | \
+           sed -e 's/__automatic_[0-9a-f]*_.*>/__automatic_>/' ) \
+           > ${.CURDIR}/pf${n}.ok
+       ${SUDO} ${PFCTL} -o none -a regress -Fr >/dev/null 2>&1
+
+.endfor
+
+pfloadanchors:         ${PFLOADANCHORS_TARGETS}
+pfloadanchors-update:  ${PFLOADANCHORS_UPDATES}
+
+REGRESS_TARGETS+=pfloadanchors
+
 update:        ${UPDATE_TARGETS}
 
 alltests: ${REGRESS_TARGETS} ${NODEFAULT_TARGETS}
diff --git a/regress/sbin/pfctl/pf112.in b/regress/sbin/pfctl/pf112.in
new file mode 100644 (file)
index 0000000..5b40dc0
--- /dev/null
@@ -0,0 +1,2 @@
+anchor "one"
+load anchor "one" from "pf112.one"
diff --git a/regress/sbin/pfctl/pf112.ok b/regress/sbin/pfctl/pf112.ok
new file mode 100644 (file)
index 0000000..67420f7
--- /dev/null
@@ -0,0 +1,5 @@
+anchor "one" all {
+  anchor "two" all {
+    pass from <foo> to any flags S/SA
+  }
+}
diff --git a/regress/sbin/pfctl/pf112.one b/regress/sbin/pfctl/pf112.one
new file mode 100644 (file)
index 0000000..68e2003
--- /dev/null
@@ -0,0 +1,2 @@
+anchor "two"
+load anchor "two" from "pf112.two"
diff --git a/regress/sbin/pfctl/pf112.two b/regress/sbin/pfctl/pf112.two
new file mode 100644 (file)
index 0000000..84e5f75
--- /dev/null
@@ -0,0 +1,2 @@
+table <foo> { 10.0.0.1 }
+pass from <foo>
diff --git a/regress/sbin/pfctl/pf113.in b/regress/sbin/pfctl/pf113.in
new file mode 100644 (file)
index 0000000..f62fa7a
--- /dev/null
@@ -0,0 +1,2 @@
+anchor "one"
+load anchor "one" from "pf113.one"
diff --git a/regress/sbin/pfctl/pf113.ok b/regress/sbin/pfctl/pf113.ok
new file mode 100644 (file)
index 0000000..a599c3c
--- /dev/null
@@ -0,0 +1,5 @@
+anchor "one" all {
+  anchor "two" all {
+    pass inet from <__automatic_> to any flags S/SA
+  }
+}
diff --git a/regress/sbin/pfctl/pf113.one b/regress/sbin/pfctl/pf113.one
new file mode 100644 (file)
index 0000000..4e4b633
--- /dev/null
@@ -0,0 +1,2 @@
+anchor "two"
+load anchor "two" from "pf113.two"
diff --git a/regress/sbin/pfctl/pf113.two b/regress/sbin/pfctl/pf113.two
new file mode 100644 (file)
index 0000000..a99c64f
--- /dev/null
@@ -0,0 +1,12 @@
+addrs = "{     1.2.3.4,
+               10.20.30.40,
+               2.4.6.8,
+               20.40.60.80,
+               4.8.12.16,
+               40.80.120.160,
+               5.6.7.8,
+               50.60.70.80,
+               10.12.14.16,
+               100.120.140.160
+       }"
+pass from $addrs