mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
network/ndisc: do not try to set too large value for ICMP ratelimting
Follow-up for 6197db53ba.
When we set too large value, the kernel just refuse it. So, this does
not change the net behavior.
Prompted by https://github.com/systemd/systemd/pull/30490#discussion_r1449477125.
This commit is contained in:
committed by
Luca Boccassi
parent
f4220d8c05
commit
be89a76a46
@@ -358,8 +358,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
||||
}
|
||||
|
||||
static int ndisc_router_process_icmp6_ratelimit(Link *link, sd_ndisc_router *rt) {
|
||||
char buf[DECIMAL_STR_MAX(usec_t)];
|
||||
usec_t icmp6_ratelimit;
|
||||
usec_t icmp6_ratelimit, msec;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
@@ -375,14 +374,17 @@ static int ndisc_router_process_icmp6_ratelimit(Link *link, sd_ndisc_router *rt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We do not allow 0 here. */
|
||||
if (!timestamp_is_set(icmp6_ratelimit))
|
||||
return 0;
|
||||
|
||||
msec = DIV_ROUND_UP(icmp6_ratelimit, USEC_PER_MSEC);
|
||||
if (msec <= 0 || msec > INT_MAX)
|
||||
return 0;
|
||||
|
||||
/* Limit the maximal rates for sending ICMPv6 packets. 0 to disable any limiting, otherwise the
|
||||
* minimal space between responses in milliseconds. Default: 1000. */
|
||||
xsprintf(buf, USEC_FMT, DIV_ROUND_UP(icmp6_ratelimit, USEC_PER_MSEC));
|
||||
|
||||
r = sysctl_write_ip_property(AF_INET6, NULL, "icmp/ratelimit", buf);
|
||||
r = sysctl_write_ip_property_int(AF_INET6, NULL, "icmp/ratelimit", (int) msec);
|
||||
if (r < 0)
|
||||
log_link_warning_errno(link, r, "Failed to apply ICMP6 ratelimit, ignoring: %m");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user