OpenGrok
Cross Reference: ratelimit.c
xref
: /
src
/
usr.sbin
/
inetd
/
ratelimit.c
Home
|
History
|
Annotate
|
Download
|
only in
inetd
History log of
/src/usr.sbin/inetd/ratelimit.c
Revision
Date
Author
Comments
1.3
19-Sep-2025
mrg
fix a couple of "allocate too little" issues GCC 14 pointed out.
both ruptime and inetd allocate a less-than-struct-sized space and
assign it to a struct pointer. neither of them actually use more
than the allocated memory, but this is still dodgy and technically
wrong. just allocate the right size.
1.2
12-Oct-2021
rillig
inetd: remove trailing whitespace, add space after 'if' and 'for'
No functional change.
1.1
12-Oct-2021
christos
PR/56448: Solomon Ritzow: Various improvements.
Rate limiting code has been moved to ratelimit.c. I renamed
clear_ip_list to rl_clear_ip_list and broke the code up into more
functions. I have also made the per-IP rate limiting allocation more
efficient. IP addresses are now stored in their network format instead
of a string from getnameinfo (see inetd.h struct rl_ip_node). malloc
calls use only the space needed by the structure by using offsetof on
union members (I suppose this can be a bit dangerous if not done
correctly...). Per-IP rate limiting still supports textual comparison
using getnameinfo for address families other than AF_INET and AF_INET6, but I
don't think there are any that are actually compatible or used by inetd (I
haven't tested UNIX sockets with a remote bound to another file, but I did test
using IPv6 with the textual format by commenting out the IPv6 specific
code, and it works properly). Still potentially handy for the future.
The IP node list (se_rl_ip_list) now uses the <sys/queue.h> SLIST macros
instead of a custom list. I've broken rl_process up into helper functions
for each type of rate limiting and created a separate function for
address stringification, for use with printouts from the -d flag. I
tried to reduce stack memory use by moving printing code involving
string buffers into separate functions. I haven't tested rl_ipv6_eq on
a 32-bit system.
The code for the positional syntax has also been moved to parse.c.
Function try_biltin has been added to remove parse.c:parse_server's
dependency on the biltin structure definition.
File inetd.h has been updated with the proper function prototypes, and
the servtab structure has been update with the new IP node SLIST. I also
moved things around a bit. The way we (a peer and myself)
formatted inetd.h previously was somewhat confusing. Function and global
variable prototypes are now organized by the source file they are
defined in.
I also added a -f flag that I saw in another problem report
(https://gnats.netbsd.org/12823) that I thought could be useful. It
runs inetd in the foreground but without debug printouts or SO_DEBUG.
I'm not completely sure about the line "if (foreground) setsid()" that
I changed from "if (debug) setsid()".
Indexes created Fri Oct 17 17:09:57 GMT 2025