Page MenuHomeFreeBSD

counter(9): rate limit periods may be more than 1 second
ClosedPublic

Authored by kp on Jun 11 2025, 7:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 19, 4:52 AM
Unknown Object (File)
Mon, Jul 14, 1:10 AM
Unknown Object (File)
Sat, Jul 12, 2:15 PM
Unknown Object (File)
Sun, Jul 6, 7:04 PM
Unknown Object (File)
Sat, Jul 5, 3:43 AM
Unknown Object (File)
Jul 3 2025, 10:36 AM
Unknown Object (File)
Jun 30 2025, 10:38 PM
Unknown Object (File)
Jun 29 2025, 2:31 PM

Details

Summary

Teach counter_rate() to deal with periods of more than 1 second, so we can
express 'at most 100 in 10 seconds', which is different from 'at most 10 in
1 second'.
While here move the struct counter_rate definition into subr_counter.c so users
cannot mess with its internals. Add allocation and free functions.

Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kp requested review of this revision.Jun 11 2025, 7:40 PM

May I ask to wait for my review until next week?

May I ask to wait for my review until next week?

Sure. This isn't particularly urgent. It's a preparatory commit for the max-pkt-rate feature in pf.

I totally agree with the period feature. Thanks!

I'm not sure about making the structure opaque and thus only dynamically allocated. In general I prefer hiding internals, but for some reason when we did this, we decided to make it exposed. There definitely was some reason for that, otherwise I would make it opaque. Adding Jonathan, maybe he can recall.

Manual page counter.9 also needs to be updated.

I'm not sure about making the structure opaque and thus only dynamically allocated. In general I prefer hiding internals, but for some reason when we did this, we decided to make it exposed. There definitely was some reason for that, otherwise I would make it opaque. Adding Jonathan, maybe he can recall.

Given that we already had to counter_u64_alloc() I don't think this actually makes a difference.

Unless Jonathan remembers something I'd like to go with this version.

In D50796#1162649, @kp wrote:

Unless Jonathan remembers something I'd like to go with this version.

I intend to commit this tomorrow.

I have no plans to MFC this, so if it does turn out to cause issues (presumably we'd discover this on your next merge?) we can still change it later.

No objection from me. Thanks for the change and sorry for the delay. But please wait for the stabweek closure.

This revision is now accepted and ready to land.Jun 23 2025, 6:59 PM