summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-route-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/networkd-route-util.c')
-rw-r--r--src/network/networkd-route-util.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/network/networkd-route-util.c b/src/network/networkd-route-util.c
index 9bb1e0f707..dc9663e24b 100644
--- a/src/network/networkd-route-util.c
+++ b/src/network/networkd-route-util.c
@@ -16,23 +16,26 @@
#include "strv.h"
#include "sysctl-util.h"
-#define ROUTES_DEFAULT_MAX_PER_FAMILY 4096U
+#define ROUTES_DEFAULT_MAX_PER_FAMILY 4096
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;
+ int val4 = ROUTES_DEFAULT_MAX_PER_FAMILY, val6 = ROUTES_DEFAULT_MAX_PER_FAMILY;
if (cached > 0)
return cached;
- if (sysctl_read_ip_property(AF_INET, NULL, "route/max_size", &s4) >= 0)
- if (safe_atou(s4, &val4) >= 0 && val4 == 2147483647U)
+ /* The kernel internally stores these maximum size in int. */
+
+ if (sysctl_read_ip_property_int(AF_INET, /* ifname = */ NULL, "route/max_size", &val4) >= 0)
+ if (val4 == INT_MAX)
/* This is the default "no limit" value in the kernel */
val4 = ROUTES_DEFAULT_MAX_PER_FAMILY;
- if (sysctl_read_ip_property(AF_INET6, NULL, "route/max_size", &s6) >= 0)
- (void) safe_atou(s6, &val6);
+ if (sysctl_read_ip_property_int(AF_INET6, /* ifname = */ NULL, "route/max_size", &val6) >= 0)
+ if (val6 == INT_MAX)
+ /* This is the default "no limit" value in the kernel */
+ val6 = ROUTES_DEFAULT_MAX_PER_FAMILY;
cached = MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val4) +
MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val6);