Skip to content

Commit 3658680

Browse files
committed
pf tests: test table information export via snmp_pf
Event: Tokyo Hackathon 202503
1 parent c849f53 commit 3658680

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/sys/netpfil/pf/snmp.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,59 @@ basic_cleanup()
6565
pft_cleanup
6666
}
6767

68+
atf_test_case "table" "cleanup"
69+
table_head()
70+
{
71+
atf_set descr 'Test tables and pf_snmp'
72+
atf_set require.user root
73+
}
74+
75+
table_body()
76+
{
77+
pft_init
78+
79+
epair=$(vnet_mkepair)
80+
81+
ifconfig ${epair}b 192.0.2.2/24 up
82+
83+
vnet_mkjail alcatraz ${epair}a
84+
jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up
85+
86+
jexec alcatraz pfctl -e
87+
pft_set_rules alcatraz \
88+
"table <foo> counters { 192.0.2.0/24 }" \
89+
"pass in from <foo>"
90+
91+
# Start bsnmpd after creating the table so we don't have to wait for
92+
# a refresh timeout
93+
jexec alcatraz bsnmpd -c $(atf_get_srcdir)/bsnmpd.conf
94+
95+
# Sanity check, and create state
96+
atf_check -s exit:0 -o ignore \
97+
ping -c 1 192.0.2.1
98+
99+
# We should have one table
100+
atf_check -s exit:0 -o match:'pfTablesTblNumber.0 = 1' \
101+
bsnmpwalk -s [email protected] -i pf_tree.def begemot
102+
103+
# We have the 'foo' table
104+
atf_check -s exit:0 -o match:'pfTablesTblDescr.* = foo' \
105+
bsnmpwalk -s [email protected] -i pf_tree.def pfTables
106+
107+
# Which contains address 192.0.2.0/24
108+
atf_check -s exit:0 -o match:'pfTablesAddrNet.* = 192.0.2.0' \
109+
bsnmpwalk -s [email protected] -i pf_tree.def pfTables
110+
atf_check -s exit:0 -o match:'pfTablesAddrPrefix.* = 24' \
111+
bsnmpwalk -s [email protected] -i pf_tree.def pfTables
112+
}
113+
114+
table_cleanup()
115+
{
116+
pft_cleanup
117+
}
118+
68119
atf_init_test_cases()
69120
{
70121
atf_add_test_case "basic"
122+
atf_add_test_case "table"
71123
}

0 commit comments

Comments
 (0)