summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-10-28 15:22:47 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-28 15:44:10 +0900
commit778c879533af090e691a67f64f251686a9dbd155 (patch)
tree88377f9c4dea2faf0a34008a16b26347cd1a5e00
parent31a9a27d4c211768098540b0461eacaca2d68287 (diff)
downloadsystemd-778c879533af090e691a67f64f251686a9dbd155.tar.gz
network: use sysctl_read_ip_property() where applicable
-rw-r--r--src/network/networkd-route.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index cd0f0aa707..4c3704b328 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -152,25 +152,19 @@ static const char *format_route_protocol(int protocol, char *buf, size_t size) {
static unsigned routes_max(void) {
static thread_local unsigned cached = 0;
-
_cleanup_free_ char *s4 = NULL, *s6 = NULL;
unsigned val4 = ROUTES_DEFAULT_MAX_PER_FAMILY, val6 = ROUTES_DEFAULT_MAX_PER_FAMILY;
if (cached > 0)
return cached;
- if (sysctl_read("net/ipv4/route/max_size", &s4) >= 0) {
- truncate_nl(s4);
- if (safe_atou(s4, &val4) >= 0 &&
- val4 == 2147483647U)
+ if (sysctl_read_ip_property(AF_INET, NULL, "route/max_size", &s4) >= 0)
+ if (safe_atou(s4, &val4) >= 0 && val4 == 2147483647U)
/* This is the default "no limit" value in the kernel */
val4 = ROUTES_DEFAULT_MAX_PER_FAMILY;
- }
- if (sysctl_read("net/ipv6/route/max_size", &s6) >= 0) {
- truncate_nl(s6);
+ if (sysctl_read_ip_property(AF_INET6, NULL, "route/max_size", &s6) >= 0)
(void) safe_atou(s6, &val6);
- }
cached = MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val4) +
MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val6);