Skip to content

Commit 778c879

Browse files
committed
network: use sysctl_read_ip_property() where applicable
1 parent 31a9a27 commit 778c879

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/network/networkd-route.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,19 @@ static const char *format_route_protocol(int protocol, char *buf, size_t size) {
152152

153153
static unsigned routes_max(void) {
154154
static thread_local unsigned cached = 0;
155-
156155
_cleanup_free_ char *s4 = NULL, *s6 = NULL;
157156
unsigned val4 = ROUTES_DEFAULT_MAX_PER_FAMILY, val6 = ROUTES_DEFAULT_MAX_PER_FAMILY;
158157

159158
if (cached > 0)
160159
return cached;
161160

162-
if (sysctl_read("net/ipv4/route/max_size", &s4) >= 0) {
163-
truncate_nl(s4);
164-
if (safe_atou(s4, &val4) >= 0 &&
165-
val4 == 2147483647U)
161+
if (sysctl_read_ip_property(AF_INET, NULL, "route/max_size", &s4) >= 0)
162+
if (safe_atou(s4, &val4) >= 0 && val4 == 2147483647U)
166163
/* This is the default "no limit" value in the kernel */
167164
val4 = ROUTES_DEFAULT_MAX_PER_FAMILY;
168-
}
169165

170-
if (sysctl_read("net/ipv6/route/max_size", &s6) >= 0) {
171-
truncate_nl(s6);
166+
if (sysctl_read_ip_property(AF_INET6, NULL, "route/max_size", &s6) >= 0)
172167
(void) safe_atou(s6, &val6);
173-
}
174168

175169
cached = MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val4) +
176170
MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val6);

0 commit comments

Comments
 (0)