}
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);
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");