* Duplicate pfctl -Fa operation to get rid of as much as we can. */
| 4413 | * Duplicate pfctl -Fa operation to get rid of as much as we can. |
| 4414 | */ |
| 4415 | static int |
| 4416 | shutdown_pf(void) |
| 4417 | { |
| 4418 | int error = 0; |
| 4419 | u_int32_t t[5]; |
| 4420 | char nn = '\0'; |
| 4421 | |
| 4422 | do { |
| 4423 | if ((error = pf_begin_rules(&t[0], PF_RULESET_SCRUB, &nn)) |
| 4424 | != 0) { |
| 4425 | DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: SCRUB\n")); |
| 4426 | break; |
| 4427 | } |
| 4428 | if ((error = pf_begin_rules(&t[1], PF_RULESET_FILTER, &nn)) |
| 4429 | != 0) { |
| 4430 | DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: FILTER\n")); |
| 4431 | break; /* XXX: rollback? */ |
| 4432 | } |
| 4433 | if ((error = pf_begin_rules(&t[2], PF_RULESET_NAT, &nn)) |
| 4434 | != 0) { |
| 4435 | DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: NAT\n")); |
| 4436 | break; /* XXX: rollback? */ |
| 4437 | } |
| 4438 | if ((error = pf_begin_rules(&t[3], PF_RULESET_BINAT, &nn)) |
| 4439 | != 0) { |
| 4440 | DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: BINAT\n")); |
| 4441 | break; /* XXX: rollback? */ |
| 4442 | } |
| 4443 | if ((error = pf_begin_rules(&t[4], PF_RULESET_RDR, &nn)) |
| 4444 | != 0) { |
| 4445 | DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: RDR\n")); |
| 4446 | break; /* XXX: rollback? */ |
| 4447 | } |
| 4448 | |
| 4449 | /* XXX: these should always succeed here */ |
| 4450 | pf_commit_rules(t[0], PF_RULESET_SCRUB, &nn); |
| 4451 | pf_commit_rules(t[1], PF_RULESET_FILTER, &nn); |
| 4452 | pf_commit_rules(t[2], PF_RULESET_NAT, &nn); |
| 4453 | pf_commit_rules(t[3], PF_RULESET_BINAT, &nn); |
| 4454 | pf_commit_rules(t[4], PF_RULESET_RDR, &nn); |
| 4455 | |
| 4456 | if ((error = pf_clear_tables()) != 0) |
| 4457 | break; |
| 4458 | |
| 4459 | #ifdef ALTQ |
| 4460 | if ((error = pf_begin_altq(&t[0])) != 0) { |
| 4461 | DPFPRINTF(PF_DEBUG_MISC, ("shutdown_pf: ALTQ\n")); |
| 4462 | break; |
| 4463 | } |
| 4464 | pf_commit_altq(t[0]); |
| 4465 | #endif |
| 4466 | |
| 4467 | pf_clear_states(); |
| 4468 | |
| 4469 | pf_clear_srcnodes(NULL); |
| 4470 | |
| 4471 | /* status does not use malloced mem so no need to cleanup */ |
| 4472 | /* fingerprints and interfaces have their own cleanup code */ |
no test coverage detected