git: f858f6b2381c - stable/12 - pf: Simplify cleanup
Kristof Provost
kp at FreeBSD.org
Sat Mar 20 09:59:45 UTC 2021
The branch stable/12 has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=f858f6b2381c07ae75f672064e647c6c691d4b88
commit f858f6b2381c07ae75f672064e647c6c691d4b88
Author: Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-03-10 14:15:16 +0000
Commit: Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-03-19 22:41:15 +0000
pf: Simplify cleanup
We can now counter_u64_free(NULL), so remove the checks.
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29190
(cherry picked from commit 28dc2c954f5096ae594ed5cd7a83d66ce4bf1ded)
---
sys/netpfil/pf/if_pfsync.c | 6 ++----
sys/netpfil/pf/pf.c | 12 ++++--------
sys/netpfil/pf/pf_if.c | 6 ++----
3 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index a9950350cb29..0f55dacd18ad 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -625,10 +625,8 @@ cleanup:
cleanup_state: /* pf_state_insert() frees the state keys. */
if (st) {
for (int i = 0; i < 2; i++) {
- if (st->packets[i] != NULL)
- counter_u64_free(st->packets[i]);
- if (st->bytes[i] != NULL)
- counter_u64_free(st->bytes[i]);
+ counter_u64_free(st->packets[i]);
+ counter_u64_free(st->bytes[i]);
}
if (st->dst.scrub)
uma_zfree(V_pf_state_scrub_z, st->dst.scrub);
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 625b1d6e32ca..3422cdea1e2e 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -707,10 +707,8 @@ pf_free_src_node(struct pf_ksrc_node *sn)
{
for (int i = 0; i < 2; i++) {
- if (sn->bytes[i])
- counter_u64_free(sn->bytes[i]);
- if (sn->packets[i])
- counter_u64_free(sn->packets[i]);
+ counter_u64_free(sn->bytes[i]);
+ counter_u64_free(sn->packets[i]);
}
uma_zfree(V_pf_sources_z, sn);
}
@@ -1737,10 +1735,8 @@ pf_free_state(struct pf_state *cur)
cur->timeout));
for (int i = 0; i < 2; i++) {
- if (cur->bytes[i] != NULL)
- counter_u64_free(cur->bytes[i]);
- if (cur->packets[i] != NULL)
- counter_u64_free(cur->packets[i]);
+ counter_u64_free(cur->bytes[i]);
+ counter_u64_free(cur->packets[i]);
}
pf_normalize_tcp_cleanup(cur);
diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c
index 48733d351a24..7e4d8033da0d 100644
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -232,10 +232,8 @@ pf_kkif_free(struct pfi_kkif *kif)
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
- if (kif->pfik_packets[i][j][k])
- counter_u64_free(kif->pfik_packets[i][j][k]);
- if (kif->pfik_bytes[i][j][k])
- counter_u64_free(kif->pfik_bytes[i][j][k]);
+ counter_u64_free(kif->pfik_packets[i][j][k]);
+ counter_u64_free(kif->pfik_bytes[i][j][k]);
}
}
}
More information about the dev-commits-src-branches
mailing list