Project

General

Profile

Bug #8555 » pfsense.patch

Steven Brown, 07/15/2018 09:44 PM

View differences:

src/etc/inc/filter.inc
194 194
}
195 195

  
196 196
function filter_delete_states_for_down_gateways() {
197
	global $config, $GatewaysList;
197
	global $config;
198 198

  
199 199
	if (!isset($config['system']['gw_down_kill_states'])) {
200 200
		return;
201 201
	}
202 202

  
203
	$any_gateway_down = false;
204 203
	$a_gateways = return_gateways_status();
205
	if (is_array($GatewaysList)) {
206
		foreach ($GatewaysList as $gwname => $gateway) {
207
			if (empty($gateway['monitor'])) {
208
				continue;
209
			}
210
			if (!is_ipaddr($gateway['monitor'])) {
211
				continue;
212
			}
213
			if (strstr($gateway['monitor'], "127.0.0.")) {
214
				continue;
215
			}
216
			if (empty($a_gateways[$gateway['monitor']])) {
217
				continue;
218
			}
219
			$gwstatus =& $a_gateways[$gateway['monitor']];
220
			if (strstr($gwstatus['status'], "down")) {
221
				$any_gateway_down = true;
222
				break;
204
	$gateways = return_gateways_array();
205

  
206
	foreach($a_gateways as $gwip => $gateway) {
207
		if (is_ipaddr($gwip) && ($gateway['status'] == 'down' || $gateway['status'] == 'force_down')) {
208
			log_error("Killing states for down gateway {$gateway['name']} ({$gwip})");
209
			$output = array();
210
			exec("/sbin/pfctl -M -k gateway -k {$gwip} 2>&1", $output);
211
			if (is_array($output) && isset($output[0])) {
212
				log_error($output[0]);
223 213
			}
224 214
		}
225 215
	}
226
	if ($any_gateway_down == true) {
227
		mwexec("/sbin/pfctl -Fs");
228
	}
229 216
}
230 217

  
231 218
/* reload filter sync */
(4-4/4)