Speed up rctl(8) rule retrieval; the difference shows mostly in "rctl -n",
as otherwise most of the time is spent resolving UIDs to names.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
I disagree with this approach. Userspace can pass arbitrarily large buffer which is not checked.
Current code expands the buffer until it is big enough.
The speedup can be achieved without sacrificing this functionality. For instance, one can start with min(RCTL_DEFAULT_BUFSIZE, uap->outbuflen) and grow it to uap->outbuflen tops. With the define increased this should give the same speedup, while not allowing way too much memory just because userspace asked for it.
The lack of limit is on purpuse - the API is root-only (and would require serious review if made non-root), and having a limit would introduce a new failure mode, where the admin needs to bump some sysctl to list rules.
As for the speedup - we cannot do this with looping, because each loop always traverses all the rules. In other words, if we start with a small value, we'll have to make multiple passes in the kernel.