mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
pf: fix the "keepcounters" to stop truncating to 32-bit
The machinery to support 64-bit counters even on 32-bit kernels had a bug where it would unitentionally truncate the value back to 32-bits when transferring to a new counter. This resulted in buggy be behavior on 64-bit kernels as well. Sponsored by: Rubicon Communications, LLC ("Netgate")
This commit is contained in:
parent
3beb43dd4f
commit
b6196537b0
@ -127,6 +127,14 @@ pf_counter_u64_critical_exit(void)
|
||||
critical_exit();
|
||||
}
|
||||
|
||||
static inline void
|
||||
pf_counter_u64_rollup_protected(struct pf_counter_u64 *pfcu64, uint64_t n)
|
||||
{
|
||||
|
||||
MPASS(curthread->td_critnest > 0);
|
||||
pfcu64->pfcu64_value += n;
|
||||
}
|
||||
|
||||
static inline void
|
||||
pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)
|
||||
{
|
||||
@ -250,6 +258,13 @@ pf_counter_u64_critical_exit(void)
|
||||
|
||||
}
|
||||
|
||||
static inline void
|
||||
pf_counter_u64_rollup_protected(struct pf_counter_u64 *pfcu64, uint64_t n)
|
||||
{
|
||||
|
||||
counter_u64_add(pfcu64->counter, n);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)
|
||||
{
|
||||
|
@ -1408,15 +1408,15 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor)
|
||||
continue;
|
||||
}
|
||||
pf_counter_u64_critical_enter();
|
||||
pf_counter_u64_add_protected(&rule->evaluations,
|
||||
pf_counter_u64_rollup_protected(&rule->evaluations,
|
||||
pf_counter_u64_fetch(&old_rule->evaluations));
|
||||
pf_counter_u64_add_protected(&rule->packets[0],
|
||||
pf_counter_u64_rollup_protected(&rule->packets[0],
|
||||
pf_counter_u64_fetch(&old_rule->packets[0]));
|
||||
pf_counter_u64_add_protected(&rule->packets[1],
|
||||
pf_counter_u64_rollup_protected(&rule->packets[1],
|
||||
pf_counter_u64_fetch(&old_rule->packets[1]));
|
||||
pf_counter_u64_add_protected(&rule->bytes[0],
|
||||
pf_counter_u64_rollup_protected(&rule->bytes[0],
|
||||
pf_counter_u64_fetch(&old_rule->bytes[0]));
|
||||
pf_counter_u64_add_protected(&rule->bytes[1],
|
||||
pf_counter_u64_rollup_protected(&rule->bytes[1],
|
||||
pf_counter_u64_fetch(&old_rule->bytes[1]));
|
||||
pf_counter_u64_critical_exit();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user