pflog.sh (32df0124f467eff3e4691090fecb022dbdaa1e25) pflog.sh (7309c551a56edeb2e3d35639ecb20b5a70885924)
1#
2# SPDX-License-Identifier: BSD-2-Clause
3#
4# Copyright (c) 2023 Rubicon Communications, LLC (Netgate)
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 65 unchanged lines hidden (view full) ---

74 cat pflog.txt
75}
76
77malformed_cleanup()
78{
79 pft_cleanup
80}
81
1#
2# SPDX-License-Identifier: BSD-2-Clause
3#
4# Copyright (c) 2023 Rubicon Communications, LLC (Netgate)
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 65 unchanged lines hidden (view full) ---

74 cat pflog.txt
75}
76
77malformed_cleanup()
78{
79 pft_cleanup
80}
81
82atf_test_case "matches" "cleanup"
83matches_head()
84{
85 atf_set descr 'Test the pflog matches keyword'
86 atf_set require.user root
87}
88
89matches_body()
90{
91 pflog_init
92
93 epair=$(vnet_mkepair)
94
95 vnet_mkjail alcatraz ${epair}a
96 jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up
97
98 ifconfig ${epair}b 192.0.2.2/24 up
99
100 # Sanity check
101 atf_check -s exit:0 -o ignore \
102 ping -c 1 192.0.2.1
103
104 jexec alcatraz pfctl -e
105 jexec alcatraz ifconfig pflog0 up
106 pft_set_rules alcatraz \
107 "match log(matches) inet proto icmp" \
108 "match log(matches) inet from 192.0.2.2" \
109 "pass"
110
111 jexec alcatraz tcpdump -n -e -ttt --immediate-mode -l -U -i pflog0 >> ${PWD}/pflog.txt &
112 sleep 1 # Wait for tcpdump to start
113
114 atf_check -s exit:0 -o ignore \
115 ping -c 1 192.0.2.1
116
117 echo "Rules"
118 jexec alcatraz pfctl -sr -vv
119 echo "States"
120 jexec alcatraz pfctl -ss -vv
121 echo "Log"
122 cat ${PWD}/pflog.txt
123
124 atf_check -o match:".*rule 0/0\(match\): match in on ${epair}a: 192.0.2.2 > 192.0.2.1: ICMP echo request.*" \
125 cat pflog.txt
126 atf_check -o match:".*rule 1/0\(match\): match in on ${epair}a: 192.0.2.2 > 192.0.2.1: ICMP echo request.*" \
127 cat pflog.txt
128}
129
130matches_cleanup()
131{
132 pft_cleanup
133}
134
82atf_init_test_cases()
83{
84 atf_add_test_case "malformed"
135atf_init_test_cases()
136{
137 atf_add_test_case "malformed"
138 atf_add_test_case "matches"
85}
139}