Bug Summary

File:build-scan/../src/network/networkd-route.c
Warning:line 670, column 9
Potential leak of memory pointed to by 'route'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name networkd-route.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.0 -include config.h -I src/network/libnetworkd-core.a.p -I src/network -I ../src/network -I src/basic -I ../src/basic -I src/shared -I ../src/shared -I src/systemd -I ../src/systemd -I src/journal -I ../src/journal -I src/journal-remote -I ../src/journal-remote -I src/nspawn -I ../src/nspawn -I src/resolve -I ../src/resolve -I src/timesync -I ../src/timesync -I ../src/time-wait-sync -I src/login -I ../src/login -I src/udev -I ../src/udev -I src/libudev -I ../src/libudev -I src/core -I ../src/core -I ../src/libsystemd/sd-bus -I ../src/libsystemd/sd-device -I ../src/libsystemd/sd-hwdb -I ../src/libsystemd/sd-id128 -I ../src/libsystemd/sd-netlink -I ../src/libsystemd/sd-network -I src/libsystemd-network -I ../src/libsystemd-network -I . -I .. -D _FILE_OFFSET_BITS=64 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -std=gnu99 -fconst-strings -fdebug-compilation-dir /home/mrc0mmand/repos/@redhat-plumbers/systemd-rhel8/build-scan -ferror-limit 19 -fvisibility hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-07-16-221226-1465241-1 -x c ../src/network/networkd-route.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include <linux1/icmpv6.h>
4
5#include "alloc-util.h"
6#include "conf-parser.h"
7#include "in-addr-util.h"
8#include "netlink-util.h"
9#include "networkd-manager.h"
10#include "networkd-route.h"
11#include "parse-util.h"
12#include "set.h"
13#include "string-util.h"
14#include "sysctl-util.h"
15#include "util.h"
16
17#define ROUTES_DEFAULT_MAX_PER_FAMILY4096U 4096U
18
19static unsigned routes_max(void) {
20 static thread_local__thread unsigned cached = 0;
21
22 _cleanup_free___attribute__((cleanup(freep))) char *s4 = NULL((void*)0), *s6 = NULL((void*)0);
23 unsigned val4 = ROUTES_DEFAULT_MAX_PER_FAMILY4096U, val6 = ROUTES_DEFAULT_MAX_PER_FAMILY4096U;
24
25 if (cached > 0)
26 return cached;
27
28 if (sysctl_read("net/ipv4/route/max_size", &s4) >= 0) {
29 truncate_nl(s4);
30 if (safe_atou(s4, &val4) >= 0 &&
31 val4 == 2147483647U)
32 /* This is the default "no limit" value in the kernel */
33 val4 = ROUTES_DEFAULT_MAX_PER_FAMILY4096U;
34 }
35
36 if (sysctl_read("net/ipv6/route/max_size", &s6) >= 0) {
37 truncate_nl(s6);
38 (void) safe_atou(s6, &val6);
39 }
40
41 cached = MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val4)__extension__ ({ const typeof((4096U)) __unique_prefix_A20 = (
(4096U)); const typeof((val4)) __unique_prefix_B21 = ((val4))
; __unique_prefix_A20 > __unique_prefix_B21 ? __unique_prefix_A20
: __unique_prefix_B21; })
+
42 MAX(ROUTES_DEFAULT_MAX_PER_FAMILY, val6)__extension__ ({ const typeof((4096U)) __unique_prefix_A22 = (
(4096U)); const typeof((val6)) __unique_prefix_B23 = ((val6))
; __unique_prefix_A22 > __unique_prefix_B23 ? __unique_prefix_A22
: __unique_prefix_B23; })
;
43 return cached;
44}
45
46int route_new(Route **ret) {
47 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *route = NULL((void*)0);
48
49 route = new0(Route, 1)((Route*) calloc((1), sizeof(Route)));
74
Memory is allocated
50 if (!route)
75
Assuming 'route' is non-null
76
Taking false branch
51 return -ENOMEM12;
52
53 route->family = AF_UNSPEC0;
54 route->scope = RT_SCOPE_UNIVERSE;
55 route->protocol = RTPROT_UNSPEC0;
56 route->type = RTN_UNICAST;
57 route->table = RT_TABLE_MAIN;
58 route->lifetime = USEC_INFINITY((usec_t) -1);
59 route->quickack = -1;
60
61 *ret = TAKE_PTR(route)({ typeof(route) _ptr_ = (route); (route) = ((void*)0); _ptr_
; })
;
62
63 return 0;
64}
65
66int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret) {
67 _cleanup_(network_config_section_freep)__attribute__((cleanup(network_config_section_freep))) NetworkConfigSection *n = NULL((void*)0);
68 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *route = NULL((void*)0);
69 int r;
70
71 assert(network)do { if ((__builtin_expect(!!(!(network)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("network"), "../src/network/networkd-route.c"
, 71, __PRETTY_FUNCTION__); } while (0)
;
72 assert(ret)do { if ((__builtin_expect(!!(!(ret)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("ret"), "../src/network/networkd-route.c"
, 72, __PRETTY_FUNCTION__); } while (0)
;
73 assert(!!filename == (section_line > 0))do { if ((__builtin_expect(!!(!(!!filename == (section_line >
0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!!filename == (section_line > 0)"
), "../src/network/networkd-route.c", 73, __PRETTY_FUNCTION__
); } while (0)
;
74
75 if (filename) {
76 r = network_config_section_new(filename, section_line, &n);
77 if (r < 0)
78 return r;
79
80 route = hashmap_get(network->routes_by_section, n);
81 if (route) {
82 *ret = TAKE_PTR(route)({ typeof(route) _ptr_ = (route); (route) = ((void*)0); _ptr_
; })
;
83
84 return 0;
85 }
86 }
87
88 if (network->n_static_routes >= routes_max())
89 return -E2BIG7;
90
91 r = route_new(&route);
92 if (r < 0)
93 return r;
94
95 route->protocol = RTPROT_STATIC4;
96
97 if (filename) {
98 route->section = TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
99
100 r = hashmap_put(network->routes_by_section, route->section, route);
101 if (r < 0)
102 return r;
103 }
104
105 route->network = network;
106 LIST_PREPEND(routes, network->static_routes, route)do { typeof(*(network->static_routes)) **_head = &(network
->static_routes), *_item = (route); do { if ((__builtin_expect
(!!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD,
("_item"), "../src/network/networkd-route.c", 106, __PRETTY_FUNCTION__
); } while (0); if ((_item->routes_next = *_head)) _item->
routes_next->routes_prev = _item; _item->routes_prev = (
(void*)0); *_head = _item; } while (0)
;
107 network->n_static_routes++;
108
109 *ret = TAKE_PTR(route)({ typeof(route) _ptr_ = (route); (route) = ((void*)0); _ptr_
; })
;
110
111 return 0;
112}
113
114void route_free(Route *route) {
115 if (!route)
116 return;
117
118 if (route->network) {
119 LIST_REMOVE(routes, route->network->static_routes, route)do { typeof(*(route->network->static_routes)) **_head =
&(route->network->static_routes), *_item = (route)
; do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("_item"), "../src/network/networkd-route.c"
, 119, __PRETTY_FUNCTION__); } while (0); if (_item->routes_next
) _item->routes_next->routes_prev = _item->routes_prev
; if (_item->routes_prev) _item->routes_prev->routes_next
= _item->routes_next; else { do { if ((__builtin_expect(!
!(!(*_head == _item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("*_head == _item"), "../src/network/networkd-route.c", 119
, __PRETTY_FUNCTION__); } while (0); *_head = _item->routes_next
; } _item->routes_next = _item->routes_prev = ((void*)0
); } while (0)
;
120
121 assert(route->network->n_static_routes > 0)do { if ((__builtin_expect(!!(!(route->network->n_static_routes
> 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("route->network->n_static_routes > 0"
), "../src/network/networkd-route.c", 121, __PRETTY_FUNCTION__
); } while (0)
;
122 route->network->n_static_routes--;
123
124 if (route->section)
125 hashmap_remove(route->network->routes_by_section, route->section);
126 }
127
128 network_config_section_free(route->section);
129
130 if (route->link) {
131 set_remove(route->link->routes, route);
132 set_remove(route->link->routes_foreign, route);
133 }
134
135 sd_event_source_unref(route->expire);
136
137 free(route);
138}
139
140static void route_hash_func(const void *b, struct siphash *state) {
141 const Route *route = b;
142
143 assert(route)do { if ((__builtin_expect(!!(!(route)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("route"), "../src/network/networkd-route.c"
, 143, __PRETTY_FUNCTION__); } while (0)
;
144
145 siphash24_compress(&route->family, sizeof(route->family), state);
146
147 switch (route->family) {
148 case AF_INET2:
149 case AF_INET610:
150 /* Equality of routes are given by the 4-touple
151 (dst_prefix,dst_prefixlen,tos,priority,table) */
152 siphash24_compress(&route->dst, FAMILY_ADDRESS_SIZE(route->family), state);
153 siphash24_compress(&route->dst_prefixlen, sizeof(route->dst_prefixlen), state);
154 siphash24_compress(&route->tos, sizeof(route->tos), state);
155 siphash24_compress(&route->priority, sizeof(route->priority), state);
156 siphash24_compress(&route->table, sizeof(route->table), state);
157
158 break;
159 default:
160 /* treat any other address family as AF_UNSPEC */
161 break;
162 }
163}
164
165static int route_compare_func(const void *_a, const void *_b) {
166 const Route *a = _a, *b = _b;
167
168 if (a->family < b->family)
169 return -1;
170 if (a->family > b->family)
171 return 1;
172
173 switch (a->family) {
174 case AF_INET2:
175 case AF_INET610:
176 if (a->dst_prefixlen < b->dst_prefixlen)
177 return -1;
178 if (a->dst_prefixlen > b->dst_prefixlen)
179 return 1;
180
181 if (a->tos < b->tos)
182 return -1;
183 if (a->tos > b->tos)
184 return 1;
185
186 if (a->priority < b->priority)
187 return -1;
188 if (a->priority > b->priority)
189 return 1;
190
191 if (a->table < b->table)
192 return -1;
193 if (a->table > b->table)
194 return 1;
195
196 return memcmp(&a->dst, &b->dst, FAMILY_ADDRESS_SIZE(a->family));
197 default:
198 /* treat any other address family as AF_UNSPEC */
199 return 0;
200 }
201}
202
203static const struct hash_ops route_hash_ops = {
204 .hash = route_hash_func,
205 .compare = route_compare_func
206};
207
208int route_get(Link *link,
209 int family,
210 const union in_addr_union *dst,
211 unsigned char dst_prefixlen,
212 unsigned char tos,
213 uint32_t priority,
214 uint32_t table,
215 Route **ret) {
216
217 Route route, *existing;
218
219 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-route.c"
, 219, __PRETTY_FUNCTION__); } while (0)
;
220 assert(dst)do { if ((__builtin_expect(!!(!(dst)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("dst"), "../src/network/networkd-route.c"
, 220, __PRETTY_FUNCTION__); } while (0)
;
221
222 route = (Route) {
223 .family = family,
224 .dst = *dst,
225 .dst_prefixlen = dst_prefixlen,
226 .tos = tos,
227 .priority = priority,
228 .table = table,
229 };
230
231 existing = set_get(link->routes, &route);
232 if (existing) {
233 if (ret)
234 *ret = existing;
235 return 1;
236 }
237
238 existing = set_get(link->routes_foreign, &route);
239 if (existing) {
240 if (ret)
241 *ret = existing;
242 return 0;
243 }
244
245 return -ENOENT2;
246}
247
248static int route_add_internal(
249 Link *link,
250 Set **routes,
251 int family,
252 const union in_addr_union *dst,
253 unsigned char dst_prefixlen,
254 unsigned char tos,
255 uint32_t priority,
256 uint32_t table,
257 Route **ret) {
258
259 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *route = NULL((void*)0);
260 int r;
261
262 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-route.c"
, 262, __PRETTY_FUNCTION__); } while (0)
;
67
Taking false branch
68
Loop condition is false. Exiting loop
263 assert(routes)do { if ((__builtin_expect(!!(!(routes)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("routes"), "../src/network/networkd-route.c"
, 263, __PRETTY_FUNCTION__); } while (0)
;
69
Taking false branch
70
Loop condition is false. Exiting loop
264 assert(dst)do { if ((__builtin_expect(!!(!(dst)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("dst"), "../src/network/networkd-route.c"
, 264, __PRETTY_FUNCTION__); } while (0)
;
71
Taking false branch
72
Loop condition is false. Exiting loop
265
266 r = route_new(&route);
73
Calling 'route_new'
77
Returned allocated memory via 1st parameter
267 if (r
77.1
'r' is >= 0
< 0)
78
Taking false branch
268 return r;
269
270 route->family = family;
271 route->dst = *dst;
272 route->dst_prefixlen = dst_prefixlen;
273 route->tos = tos;
274 route->priority = priority;
275 route->table = table;
276
277 r = set_ensure_allocated(routes, &route_hash_ops)internal_set_ensure_allocated(routes, &route_hash_ops );
278 if (r < 0)
79
Assuming 'r' is >= 0
80
Taking false branch
279 return r;
280
281 r = set_put(*routes, route);
282 if (r < 0)
81
Assuming 'r' is >= 0
82
Taking false branch
283 return r;
284
285 route->link = link;
286
287 if (ret
82.1
'ret' is non-null
)
83
Taking true branch
288 *ret = route;
289
290 route = NULL((void*)0);
291
292 return 0;
293}
294
295int route_add_foreign(
296 Link *link,
297 int family,
298 const union in_addr_union *dst,
299 unsigned char dst_prefixlen,
300 unsigned char tos,
301 uint32_t priority,
302 uint32_t table,
303 Route **ret) {
304
305 return route_add_internal(link, &link->routes_foreign, family, dst, dst_prefixlen, tos, priority, table, ret);
306}
307
308int route_add(Link *link,
309 int family,
310 const union in_addr_union *dst,
311 unsigned char dst_prefixlen,
312 unsigned char tos,
313 uint32_t priority,
314 uint32_t table,
315 Route **ret) {
316
317 Route *route;
318 int r;
319
320 r = route_get(link, family, dst, dst_prefixlen, tos, priority, table, &route);
321 if (r == -ENOENT2) {
64
Assuming the condition is true
65
Taking true branch
322 /* Route does not exist, create a new one */
323 r = route_add_internal(link, &link->routes, family, dst, dst_prefixlen, tos, priority, table, &route);
66
Calling 'route_add_internal'
84
Returned allocated memory via 9th parameter
324 if (r
84.1
'r' is >= 0
< 0)
85
Taking false branch
325 return r;
326 } else if (r == 0) {
327 /* Take over a foreign route */
328 r = set_ensure_allocated(&link->routes, &route_hash_ops)internal_set_ensure_allocated(&link->routes, &route_hash_ops
)
;
329 if (r < 0)
330 return r;
331
332 r = set_put(link->routes, route);
333 if (r < 0)
334 return r;
335
336 set_remove(link->routes_foreign, route);
337 } else if (r == 1) {
338 /* Route exists, do nothing */
339 ;
340 } else
341 return r;
342
343 if (ret
85.1
'ret' is non-null
)
86
Taking true branch
344 *ret = route;
345
346 return 0;
347}
348
349void route_update(Route *route,
350 const union in_addr_union *src,
351 unsigned char src_prefixlen,
352 const union in_addr_union *gw,
353 const union in_addr_union *prefsrc,
354 unsigned char scope,
355 unsigned char protocol,
356 unsigned char type) {
357
358 assert(route)do { if ((__builtin_expect(!!(!(route)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("route"), "../src/network/networkd-route.c"
, 358, __PRETTY_FUNCTION__); } while (0)
;
359 assert(src || src_prefixlen == 0)do { if ((__builtin_expect(!!(!(src || src_prefixlen == 0)),0
))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("src || src_prefixlen == 0"
), "../src/network/networkd-route.c", 359, __PRETTY_FUNCTION__
); } while (0)
;
360
361 route->src = src ? *src : (union in_addr_union) {};
362 route->src_prefixlen = src_prefixlen;
363 route->gw = gw ? *gw : (union in_addr_union) {};
364 route->prefsrc = prefsrc ? *prefsrc : (union in_addr_union) {};
365 route->scope = scope;
366 route->protocol = protocol;
367 route->type = type;
368}
369
370int route_remove(Route *route, Link *link,
371 sd_netlink_message_handler_t callback) {
372
373 _cleanup_(sd_netlink_message_unrefp)__attribute__((cleanup(sd_netlink_message_unrefp))) sd_netlink_message *req = NULL((void*)0);
374 int r;
375
376 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-route.c"
, 376, __PRETTY_FUNCTION__); } while (0)
;
377 assert(link->manager)do { if ((__builtin_expect(!!(!(link->manager)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link->manager"), "../src/network/networkd-route.c"
, 377, __PRETTY_FUNCTION__); } while (0)
;
378 assert(link->manager->rtnl)do { if ((__builtin_expect(!!(!(link->manager->rtnl)),0
))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("link->manager->rtnl"
), "../src/network/networkd-route.c", 378, __PRETTY_FUNCTION__
); } while (0)
;
379 assert(link->ifindex > 0)do { if ((__builtin_expect(!!(!(link->ifindex > 0)),0))
) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("link->ifindex > 0"
), "../src/network/networkd-route.c", 379, __PRETTY_FUNCTION__
); } while (0)
;
380 assert(IN_SET(route->family, AF_INET, AF_INET6))do { if ((__builtin_expect(!!(!(({ _Bool _found = 0; static __attribute__
((unused)) char _static_assert__macros_need_to_be_extended[20
- sizeof((int[]){2, 10})/sizeof(int)]; switch(route->family
) { case 2: case 10: _found = 1; break; default: break; } _found
; }))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("IN_SET(route->family, AF_INET, AF_INET6)"
), "../src/network/networkd-route.c", 380, __PRETTY_FUNCTION__
); } while (0)
;
381
382 r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
383 RTM_DELROUTERTM_DELROUTE, route->family,
384 route->protocol);
385 if (r < 0)
386 return log_error_errno(r, "Could not create RTM_DELROUTE message: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 386, __func__, "Could not create RTM_DELROUTE message: %m"
) : -abs(_e); })
;
387
388 if (!in_addr_is_null(route->family, &route->gw)) {
389 if (route->family == AF_INET2)
390 r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->gw.in);
391 else if (route->family == AF_INET610)
392 r = sd_netlink_message_append_in6_addr(req, RTA_GATEWAY, &route->gw.in6);
393 if (r < 0)
394 return log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 394, __func__, "Could not append RTA_GATEWAY attribute: %m"
) : -abs(_e); })
;
395 }
396
397 if (route->dst_prefixlen) {
398 if (route->family == AF_INET2)
399 r = sd_netlink_message_append_in_addr(req, RTA_DST, &route->dst.in);
400 else if (route->family == AF_INET610)
401 r = sd_netlink_message_append_in6_addr(req, RTA_DST, &route->dst.in6);
402 if (r < 0)
403 return log_error_errno(r, "Could not append RTA_DST attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 403, __func__, "Could not append RTA_DST attribute: %m"
) : -abs(_e); })
;
404
405 r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen);
406 if (r < 0)
407 return log_error_errno(r, "Could not set destination prefix length: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 407, __func__, "Could not set destination prefix length: %m"
) : -abs(_e); })
;
408 }
409
410 if (route->src_prefixlen) {
411 if (route->family == AF_INET2)
412 r = sd_netlink_message_append_in_addr(req, RTA_SRC, &route->src.in);
413 else if (route->family == AF_INET610)
414 r = sd_netlink_message_append_in6_addr(req, RTA_SRC, &route->src.in6);
415 if (r < 0)
416 return log_error_errno(r, "Could not append RTA_SRC attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 416, __func__, "Could not append RTA_SRC attribute: %m"
) : -abs(_e); })
;
417
418 r = sd_rtnl_message_route_set_src_prefixlen(req, route->src_prefixlen);
419 if (r < 0)
420 return log_error_errno(r, "Could not set source prefix length: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 420, __func__, "Could not set source prefix length: %m"
) : -abs(_e); })
;
421 }
422
423 if (!in_addr_is_null(route->family, &route->prefsrc)) {
424 if (route->family == AF_INET2)
425 r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc.in);
426 else if (route->family == AF_INET610)
427 r = sd_netlink_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc.in6);
428 if (r < 0)
429 return log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 429, __func__, "Could not append RTA_PREFSRC attribute: %m"
) : -abs(_e); })
;
430 }
431
432 r = sd_rtnl_message_route_set_scope(req, route->scope);
433 if (r < 0)
434 return log_error_errno(r, "Could not set scope: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 434, __func__, "Could not set scope: %m"
) : -abs(_e); })
;
435
436 r = sd_netlink_message_append_u32(req, RTA_PRIORITY, route->priority);
437 if (r < 0)
438 return log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 438, __func__, "Could not append RTA_PRIORITY attribute: %m"
) : -abs(_e); })
;
439
440 if (!IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended
[20 - sizeof((int[]){RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE
})/sizeof(int)]; switch(route->type) { case RTN_UNREACHABLE
: case RTN_PROHIBIT: case RTN_BLACKHOLE: _found = 1; break; default
: break; } _found; })
) {
441 r = sd_netlink_message_append_u32(req, RTA_OIF, link->ifindex);
442 if (r < 0)
443 return log_error_errno(r, "Could not append RTA_OIF attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 443, __func__, "Could not append RTA_OIF attribute: %m"
) : -abs(_e); })
;
444 }
445
446 r = sd_netlink_call_async(link->manager->rtnl, req, callback, link, 0, NULL((void*)0));
447 if (r < 0)
448 return log_error_errno(r, "Could not send rtnetlink message: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 448, __func__, "Could not send rtnetlink message: %m"
) : -abs(_e); })
;
449
450 link_ref(link);
451
452 return 0;
453}
454
455static int route_expire_callback(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
456 Link *link = userdata;
457 int r;
458
459 assert(rtnl)do { if ((__builtin_expect(!!(!(rtnl)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rtnl"), "../src/network/networkd-route.c"
, 459, __PRETTY_FUNCTION__); } while (0)
;
460 assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("m"), "../src/network/networkd-route.c",
460, __PRETTY_FUNCTION__); } while (0)
;
461 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-route.c"
, 461, __PRETTY_FUNCTION__); } while (0)
;
462 assert(link->ifname)do { if ((__builtin_expect(!!(!(link->ifname)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link->ifname"), "../src/network/networkd-route.c"
, 462, __PRETTY_FUNCTION__); } while (0)
;
463
464 if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended
[20 - sizeof((int[]){LINK_STATE_FAILED, LINK_STATE_LINGER})/sizeof
(int)]; switch(link->state) { case LINK_STATE_FAILED: case
LINK_STATE_LINGER: _found = 1; break; default: break; } _found
; })
)
465 return 1;
466
467 r = sd_netlink_message_get_errno(m);
468 if (r < 0 && r != -EEXIST17)
469 log_link_warning_errno(link, r, "could not remove route: %m")({ const Link *_l = (link); _l ? log_object_internal(4, r, "../src/network/networkd-route.c"
, 469, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "could not remove route: %m") : log_internal_realm(((LOG_REALM_SYSTEMD
) << 10 | ((4))), r, "../src/network/networkd-route.c",
469, __func__, "could not remove route: %m"); })
;
470
471 return 1;
472}
473
474int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
475 Route *route = userdata;
476 int r;
477
478 assert(route)do { if ((__builtin_expect(!!(!(route)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("route"), "../src/network/networkd-route.c"
, 478, __PRETTY_FUNCTION__); } while (0)
;
479
480 r = route_remove(route, route->link, route_expire_callback);
481 if (r < 0)
482 log_warning_errno(r, "Could not remove route: %m")({ int _level = ((4)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 482, __func__, "Could not remove route: %m"
) : -abs(_e); })
;
483 else
484 route_free(route);
485
486 return 1;
487}
488
489int route_configure(
490 Route *route,
491 Link *link,
492 sd_netlink_message_handler_t callback) {
493
494 _cleanup_(sd_netlink_message_unrefp)__attribute__((cleanup(sd_netlink_message_unrefp))) sd_netlink_message *req = NULL((void*)0);
495 _cleanup_(sd_event_source_unrefp)__attribute__((cleanup(sd_event_source_unrefp))) sd_event_source *expire = NULL((void*)0);
496 usec_t lifetime;
497 int r;
498
499 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-route.c"
, 499, __PRETTY_FUNCTION__); } while (0)
;
1
Assuming 'link' is non-null
2
Taking false branch
3
Loop condition is false. Exiting loop
500 assert(link->manager)do { if ((__builtin_expect(!!(!(link->manager)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link->manager"), "../src/network/networkd-route.c"
, 500, __PRETTY_FUNCTION__); } while (0)
;
4
Assuming field 'manager' is non-null
5
Taking false branch
6
Loop condition is false. Exiting loop
501 assert(link->manager->rtnl)do { if ((__builtin_expect(!!(!(link->manager->rtnl)),0
))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("link->manager->rtnl"
), "../src/network/networkd-route.c", 501, __PRETTY_FUNCTION__
); } while (0)
;
7
Assuming field 'rtnl' is non-null
8
Taking false branch
9
Loop condition is false. Exiting loop
502 assert(link->ifindex > 0)do { if ((__builtin_expect(!!(!(link->ifindex > 0)),0))
) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("link->ifindex > 0"
), "../src/network/networkd-route.c", 502, __PRETTY_FUNCTION__
); } while (0)
;
10
Assuming field 'ifindex' is > 0
11
Taking false branch
12
Loop condition is false. Exiting loop
503 assert(IN_SET(route->family, AF_INET, AF_INET6))do { if ((__builtin_expect(!!(!(({ _Bool _found = 0; static __attribute__
((unused)) char _static_assert__macros_need_to_be_extended[20
- sizeof((int[]){2, 10})/sizeof(int)]; switch(route->family
) { case 2: case 10: _found = 1; break; default: break; } _found
; }))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("IN_SET(route->family, AF_INET, AF_INET6)"
), "../src/network/networkd-route.c", 503, __PRETTY_FUNCTION__
); } while (0)
;
13
Control jumps to 'case 2:' at line 503
14
Execution continues on line 503
15
Taking false branch
16
Loop condition is false. Exiting loop
504
505 if (route_get(link, route->family, &route->dst, route->dst_prefixlen, route->tos, route->priority, route->table, NULL((void*)0)) <= 0 &&
18
Taking false branch
506 set_size(link->routes) >= routes_max())
17
Assuming the condition is false
507 return -E2BIG7;
508
509 r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
510 RTM_NEWROUTERTM_NEWROUTE, route->family,
511 route->protocol);
512 if (r < 0)
19
Assuming 'r' is >= 0
20
Taking false branch
513 return log_error_errno(r, "Could not create RTM_NEWROUTE message: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 513, __func__, "Could not create RTM_NEWROUTE message: %m"
) : -abs(_e); })
;
514
515 if (!in_addr_is_null(route->family, &route->gw)) {
21
Assuming the condition is false
22
Taking false branch
516 if (route->family == AF_INET2)
517 r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->gw.in);
518 else if (route->family == AF_INET610)
519 r = sd_netlink_message_append_in6_addr(req, RTA_GATEWAY, &route->gw.in6);
520 if (r < 0)
521 return log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 521, __func__, "Could not append RTA_GATEWAY attribute: %m"
) : -abs(_e); })
;
522
523 r = sd_rtnl_message_route_set_family(req, route->family);
524 if (r < 0)
525 return log_error_errno(r, "Could not set route family: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 525, __func__, "Could not set route family: %m"
) : -abs(_e); })
;
526 }
527
528 if (route->dst_prefixlen) {
23
Assuming field 'dst_prefixlen' is 0
24
Taking false branch
529 if (route->family == AF_INET2)
530 r = sd_netlink_message_append_in_addr(req, RTA_DST, &route->dst.in);
531 else if (route->family == AF_INET610)
532 r = sd_netlink_message_append_in6_addr(req, RTA_DST, &route->dst.in6);
533 if (r < 0)
534 return log_error_errno(r, "Could not append RTA_DST attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 534, __func__, "Could not append RTA_DST attribute: %m"
) : -abs(_e); })
;
535
536 r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen);
537 if (r < 0)
538 return log_error_errno(r, "Could not set destination prefix length: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 538, __func__, "Could not set destination prefix length: %m"
) : -abs(_e); })
;
539 }
540
541 if (route->src_prefixlen) {
25
Assuming field 'src_prefixlen' is 0
26
Taking false branch
542 if (route->family == AF_INET2)
543 r = sd_netlink_message_append_in_addr(req, RTA_SRC, &route->src.in);
544 else if (route->family == AF_INET610)
545 r = sd_netlink_message_append_in6_addr(req, RTA_SRC, &route->src.in6);
546 if (r < 0)
547 return log_error_errno(r, "Could not append RTA_SRC attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 547, __func__, "Could not append RTA_SRC attribute: %m"
) : -abs(_e); })
;
548
549 r = sd_rtnl_message_route_set_src_prefixlen(req, route->src_prefixlen);
550 if (r < 0)
551 return log_error_errno(r, "Could not set source prefix length: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 551, __func__, "Could not set source prefix length: %m"
) : -abs(_e); })
;
552 }
553
554 if (!in_addr_is_null(route->family, &route->prefsrc)) {
27
Assuming the condition is false
28
Taking false branch
555 if (route->family == AF_INET2)
556 r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc.in);
557 else if (route->family == AF_INET610)
558 r = sd_netlink_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc.in6);
559 if (r < 0)
560 return log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 560, __func__, "Could not append RTA_PREFSRC attribute: %m"
) : -abs(_e); })
;
561 }
562
563 r = sd_rtnl_message_route_set_scope(req, route->scope);
564 if (r < 0)
29
Assuming 'r' is >= 0
30
Taking false branch
565 return log_error_errno(r, "Could not set scope: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 565, __func__, "Could not set scope: %m"
) : -abs(_e); })
;
566
567 r = sd_rtnl_message_route_set_flags(req, route->flags);
568 if (r < 0)
31
Assuming 'r' is >= 0
32
Taking false branch
569 return log_error_errno(r, "Could not set flags: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 569, __func__, "Could not set flags: %m"
) : -abs(_e); })
;
570
571 if (route->table != RT_TABLE_MAIN) {
33
Assuming field 'table' is equal to RT_TABLE_MAIN
34
Taking false branch
572 if (route->table < 256) {
573 r = sd_rtnl_message_route_set_table(req, route->table);
574 if (r < 0)
575 return log_error_errno(r, "Could not set route table: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 575, __func__, "Could not set route table: %m"
) : -abs(_e); })
;
576 } else {
577 r = sd_rtnl_message_route_set_table(req, RT_TABLE_UNSPEC);
578 if (r < 0)
579 return log_error_errno(r, "Could not set route table: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 579, __func__, "Could not set route table: %m"
) : -abs(_e); })
;
580
581 /* Table attribute to allow more than 256. */
582 r = sd_netlink_message_append_data(req, RTA_TABLE, &route->table, sizeof(route->table));
583 if (r < 0)
584 return log_error_errno(r, "Could not append RTA_TABLE attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 584, __func__, "Could not append RTA_TABLE attribute: %m"
) : -abs(_e); })
;
585 }
586 }
587
588 r = sd_netlink_message_append_u32(req, RTA_PRIORITY, route->priority);
589 if (r < 0)
35
Assuming 'r' is >= 0
36
Taking false branch
590 return log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 590, __func__, "Could not append RTA_PRIORITY attribute: %m"
) : -abs(_e); })
;
591
592 r = sd_netlink_message_append_u8(req, RTA_PREF20, route->pref);
593 if (r < 0)
37
Assuming 'r' is >= 0
38
Taking false branch
594 return log_error_errno(r, "Could not append RTA_PREF attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 594, __func__, "Could not append RTA_PREF attribute: %m"
) : -abs(_e); })
;
595
596 if (route->lifetime != USEC_INFINITY((usec_t) -1) && kernel_route_expiration_supported()) {
39
Assuming the condition is true
40
Assuming the condition is false
41
Taking false branch
597 r = sd_netlink_message_append_u32(req, RTA_EXPIRES23,
598 DIV_ROUND_UP(usec_sub_unsigned(route->lifetime, now(clock_boottime_or_monotonic())), USEC_PER_SEC)({ const typeof((usec_sub_unsigned(route->lifetime, now(clock_boottime_or_monotonic
())))) __unique_prefix_X24 = ((usec_sub_unsigned(route->lifetime
, now(clock_boottime_or_monotonic())))); const typeof((((usec_t
) 1000000ULL))) __unique_prefix_Y25 = ((((usec_t) 1000000ULL)
)); (__unique_prefix_X24 / __unique_prefix_Y25 + !!(__unique_prefix_X24
% __unique_prefix_Y25)); })
);
599 if (r < 0)
600 return log_error_errno(r, "Could not append RTA_EXPIRES attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 600, __func__, "Could not append RTA_EXPIRES attribute: %m"
) : -abs(_e); })
;
601 }
602
603 r = sd_rtnl_message_route_set_type(req, route->type);
604 if (r < 0)
42
Assuming 'r' is >= 0
43
Taking false branch
605 return log_error_errno(r, "Could not set route type: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 605, __func__, "Could not set route type: %m"
) : -abs(_e); })
;
606
607 if (!IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended
[20 - sizeof((int[]){RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE
})/sizeof(int)]; switch(route->type) { case RTN_UNREACHABLE
: case RTN_PROHIBIT: case RTN_BLACKHOLE: _found = 1; break; default
: break; } _found; })
) {
44
Control jumps to the 'default' case at line 607
45
Execution continues on line 607
46
Taking true branch
608 r = sd_netlink_message_append_u32(req, RTA_OIF, link->ifindex);
609 if (r < 0)
47
Assuming 'r' is >= 0
48
Taking false branch
610 return log_error_errno(r, "Could not append RTA_OIF attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 610, __func__, "Could not append RTA_OIF attribute: %m"
) : -abs(_e); })
;
611 }
612
613 r = sd_netlink_message_open_container(req, RTA_METRICS);
614 if (r < 0)
49
Assuming 'r' is >= 0
50
Taking false branch
615 return log_error_errno(r, "Could not append RTA_METRICS attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 615, __func__, "Could not append RTA_METRICS attribute: %m"
) : -abs(_e); })
;
616
617 if (route->mtu > 0) {
51
Assuming field 'mtu' is <= 0
52
Taking false branch
618 r = sd_netlink_message_append_u32(req, RTAX_MTURTAX_MTU, route->mtu);
619 if (r < 0)
620 return log_error_errno(r, "Could not append RTAX_MTU attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 620, __func__, "Could not append RTAX_MTU attribute: %m"
) : -abs(_e); })
;
621 }
622
623 if (route->initcwnd > 0) {
53
Assuming field 'initcwnd' is <= 0
54
Taking false branch
624 r = sd_netlink_message_append_u32(req, RTAX_INITCWNDRTAX_INITCWND, route->initcwnd);
625 if (r < 0)
626 return log_error_errno(r, "Could not append RTAX_INITCWND attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 626, __func__, "Could not append RTAX_INITCWND attribute: %m"
) : -abs(_e); })
;
627 }
628
629 if (route->initrwnd > 0) {
55
Assuming field 'initrwnd' is <= 0
56
Taking false branch
630 r = sd_netlink_message_append_u32(req, RTAX_INITRWNDRTAX_INITRWND, route->initrwnd);
631 if (r < 0)
632 return log_error_errno(r, "Could not append RTAX_INITRWND attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 632, __func__, "Could not append RTAX_INITRWND attribute: %m"
) : -abs(_e); })
;
633 }
634
635 if (route->quickack != -1) {
57
Assuming the condition is false
58
Taking false branch
636 r = sd_netlink_message_append_u32(req, RTAX_QUICKACKRTAX_QUICKACK, route->quickack);
637 if (r < 0)
638 return log_error_errno(r, "Could not append RTAX_QUICKACK attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 638, __func__, "Could not append RTAX_QUICKACK attribute: %m"
) : -abs(_e); })
;
639 }
640
641 r = sd_netlink_message_close_container(req);
642 if (r < 0)
59
Assuming 'r' is >= 0
60
Taking false branch
643 return log_error_errno(r, "Could not append RTA_METRICS attribute: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 643, __func__, "Could not append RTA_METRICS attribute: %m"
) : -abs(_e); })
;
644
645 r = sd_netlink_call_async(link->manager->rtnl, req, callback, link, 0, NULL((void*)0));
646 if (r < 0)
61
Assuming 'r' is >= 0
62
Taking false branch
647 return log_error_errno(r, "Could not send rtnetlink message: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 647, __func__, "Could not send rtnetlink message: %m"
) : -abs(_e); })
;
648
649 link_ref(link);
650
651 lifetime = route->lifetime;
652
653 r = route_add(link, route->family, &route->dst, route->dst_prefixlen, route->tos, route->priority, route->table, &route);
63
Calling 'route_add'
87
Returned allocated memory via 8th parameter
654 if (r
87.1
'r' is >= 0
< 0)
88
Taking false branch
655 return log_error_errno(r, "Could not add route: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 655, __func__, "Could not add route: %m"
) : -abs(_e); })
;
656
657 /* TODO: drop expiration handling once it can be pushed into the kernel */
658 route->lifetime = lifetime;
659
660 if (route->lifetime != USEC_INFINITY((usec_t) -1) && !kernel_route_expiration_supported()) {
89
Assuming the condition is false
90
Taking false branch
661 r = sd_event_add_time(link->manager->event, &expire, clock_boottime_or_monotonic(),
662 route->lifetime, 0, route_expire_handler, route);
663 if (r < 0)
664 return log_error_errno(r, "Could not arm expiration timer: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/network/networkd-route.c", 664, __func__, "Could not arm expiration timer: %m"
) : -abs(_e); })
;
665 }
666
667 sd_event_source_unref(route->expire);
668 route->expire = TAKE_PTR(expire)({ typeof(expire) _ptr_ = (expire); (expire) = ((void*)0); _ptr_
; })
;
669
670 return 0;
91
Potential leak of memory pointed to by 'route'
671}
672
673int config_parse_gateway(
674 const char *unit,
675 const char *filename,
676 unsigned line,
677 const char *section,
678 unsigned section_line,
679 const char *lvalue,
680 int ltype,
681 const char *rvalue,
682 void *data,
683 void *userdata) {
684
685 Network *network = userdata;
686 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
687 union in_addr_union buffer;
688 int r, f;
689
690 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 690, __PRETTY_FUNCTION__); } while (0)
;
691 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 691, __PRETTY_FUNCTION__); } while (0)
;
692 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 692, __PRETTY_FUNCTION__); } while (0)
;
693 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 693, __PRETTY_FUNCTION__); } while (0)
;
694 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 694, __PRETTY_FUNCTION__); } while (0)
;
695
696 if (streq(section, "Network")(strcmp((section),("Network")) == 0)) {
697 /* we are not in an Route section, so treat
698 * this as the special '0' section */
699 r = route_new_static(network, NULL((void*)0), 0, &n);
700 } else
701 r = route_new_static(network, filename, section_line, &n);
702
703 if (r < 0)
704 return r;
705
706 r = in_addr_from_string_auto(rvalue, &f, &buffer);
707 if (r < 0) {
708 log_syntax(unit, LOG_ERR, filename, line, r, "Route is invalid, ignoring assignment: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 708,
__func__, "Route is invalid, ignoring assignment: %s", rvalue
) : -abs(_e); })
;
709 return 0;
710 }
711
712 n->family = f;
713 n->gw = buffer;
714 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
715
716 return 0;
717}
718
719int config_parse_preferred_src(
720 const char *unit,
721 const char *filename,
722 unsigned line,
723 const char *section,
724 unsigned section_line,
725 const char *lvalue,
726 int ltype,
727 const char *rvalue,
728 void *data,
729 void *userdata) {
730
731 Network *network = userdata;
732 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
733 union in_addr_union buffer;
734 int r, f;
735
736 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 736, __PRETTY_FUNCTION__); } while (0)
;
737 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 737, __PRETTY_FUNCTION__); } while (0)
;
738 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 738, __PRETTY_FUNCTION__); } while (0)
;
739 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 739, __PRETTY_FUNCTION__); } while (0)
;
740 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 740, __PRETTY_FUNCTION__); } while (0)
;
741
742 r = route_new_static(network, filename, section_line, &n);
743 if (r < 0)
744 return r;
745
746 r = in_addr_from_string_auto(rvalue, &f, &buffer);
747 if (r < 0) {
748 log_syntax(unit, LOG_ERR, filename, line, EINVAL,({ int _level = (3), _e = (22); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 749,
__func__, "Preferred source is invalid, ignoring assignment: %s"
, rvalue) : -abs(_e); })
749 "Preferred source is invalid, ignoring assignment: %s", rvalue)({ int _level = (3), _e = (22); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 749,
__func__, "Preferred source is invalid, ignoring assignment: %s"
, rvalue) : -abs(_e); })
;
750 return 0;
751 }
752
753 n->family = f;
754 n->prefsrc = buffer;
755 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
756
757 return 0;
758}
759
760int config_parse_destination(
761 const char *unit,
762 const char *filename,
763 unsigned line,
764 const char *section,
765 unsigned section_line,
766 const char *lvalue,
767 int ltype,
768 const char *rvalue,
769 void *data,
770 void *userdata) {
771
772 Network *network = userdata;
773 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
774 union in_addr_union buffer;
775 unsigned char prefixlen;
776 int r;
777
778 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 778, __PRETTY_FUNCTION__); } while (0)
;
779 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 779, __PRETTY_FUNCTION__); } while (0)
;
780 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 780, __PRETTY_FUNCTION__); } while (0)
;
781 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 781, __PRETTY_FUNCTION__); } while (0)
;
782 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 782, __PRETTY_FUNCTION__); } while (0)
;
783
784 r = route_new_static(network, filename, section_line, &n);
785 if (r < 0)
786 return r;
787
788 r = in_addr_prefix_from_string(rvalue, AF_INET2, &buffer, &prefixlen);
789 if (r < 0) {
790 r = in_addr_prefix_from_string(rvalue, AF_INET610, &buffer, &prefixlen);
791 if (r < 0) {
792 log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 794,
__func__, "Route %s= prefix is invalid, ignoring assignment: %s"
, lvalue, rvalue) : -abs(_e); })
793 "Route %s= prefix is invalid, ignoring assignment: %s",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 794,
__func__, "Route %s= prefix is invalid, ignoring assignment: %s"
, lvalue, rvalue) : -abs(_e); })
794 lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 794,
__func__, "Route %s= prefix is invalid, ignoring assignment: %s"
, lvalue, rvalue) : -abs(_e); })
;
795 return 0;
796 }
797
798 n->family = AF_INET610;
799 } else
800 n->family = AF_INET2;
801
802 if (streq(lvalue, "Destination")(strcmp((lvalue),("Destination")) == 0)) {
803 n->dst = buffer;
804 n->dst_prefixlen = prefixlen;
805 } else if (streq(lvalue, "Source")(strcmp((lvalue),("Source")) == 0)) {
806 n->src = buffer;
807 n->src_prefixlen = prefixlen;
808 } else
809 assert_not_reached(lvalue)do { log_assert_failed_unreachable_realm(LOG_REALM_SYSTEMD, (
lvalue), "../src/network/networkd-route.c", 809, __PRETTY_FUNCTION__
); } while (0)
;
810
811 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
812 return 0;
813}
814
815int config_parse_route_priority(
816 const char *unit,
817 const char *filename,
818 unsigned line,
819 const char *section,
820 unsigned section_line,
821 const char *lvalue,
822 int ltype,
823 const char *rvalue,
824 void *data,
825 void *userdata) {
826
827 Network *network = userdata;
828 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
829 int r;
830
831 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 831, __PRETTY_FUNCTION__); } while (0)
;
832 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 832, __PRETTY_FUNCTION__); } while (0)
;
833 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 833, __PRETTY_FUNCTION__); } while (0)
;
834 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 834, __PRETTY_FUNCTION__); } while (0)
;
835 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 835, __PRETTY_FUNCTION__); } while (0)
;
836
837 r = route_new_static(network, filename, section_line, &n);
838 if (r < 0)
839 return r;
840
841 r = safe_atou32(rvalue, &n->priority);
842 if (r < 0) {
843 log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 844,
__func__, "Could not parse route priority \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
844 "Could not parse route priority \"%s\", ignoring assignment: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 844,
__func__, "Could not parse route priority \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
;
845 return 0;
846 }
847
848 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
849 return 0;
850}
851
852int config_parse_route_scope(
853 const char *unit,
854 const char *filename,
855 unsigned line,
856 const char *section,
857 unsigned section_line,
858 const char *lvalue,
859 int ltype,
860 const char *rvalue,
861 void *data,
862 void *userdata) {
863
864 Network *network = userdata;
865 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
866 int r;
867
868 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 868, __PRETTY_FUNCTION__); } while (0)
;
869 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 869, __PRETTY_FUNCTION__); } while (0)
;
870 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 870, __PRETTY_FUNCTION__); } while (0)
;
871 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 871, __PRETTY_FUNCTION__); } while (0)
;
872 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 872, __PRETTY_FUNCTION__); } while (0)
;
873
874 r = route_new_static(network, filename, section_line, &n);
875 if (r < 0)
876 return r;
877
878 if (streq(rvalue, "host")(strcmp((rvalue),("host")) == 0))
879 n->scope = RT_SCOPE_HOST;
880 else if (streq(rvalue, "link")(strcmp((rvalue),("link")) == 0))
881 n->scope = RT_SCOPE_LINK;
882 else if (streq(rvalue, "global")(strcmp((rvalue),("global")) == 0))
883 n->scope = RT_SCOPE_UNIVERSE;
884 else {
885 log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route scope: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 885,
__func__, "Unknown route scope: %s", rvalue) : -abs(_e); })
;
886 return 0;
887 }
888
889 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
890 return 0;
891}
892
893int config_parse_route_table(
894 const char *unit,
895 const char *filename,
896 unsigned line,
897 const char *section,
898 unsigned section_line,
899 const char *lvalue,
900 int ltype,
901 const char *rvalue,
902 void *data,
903 void *userdata) {
904
905 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
906 Network *network = userdata;
907 int r;
908
909 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 909, __PRETTY_FUNCTION__); } while (0)
;
910 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 910, __PRETTY_FUNCTION__); } while (0)
;
911 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 911, __PRETTY_FUNCTION__); } while (0)
;
912 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 912, __PRETTY_FUNCTION__); } while (0)
;
913 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 913, __PRETTY_FUNCTION__); } while (0)
;
914
915 r = route_new_static(network, filename, section_line, &n);
916 if (r < 0)
917 return r;
918
919 r = safe_atou32(rvalue, &n->table);
920 if (r < 0) {
921 log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 922,
__func__, "Could not parse route table number \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
922 "Could not parse route table number \"%s\", ignoring assignment: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 922,
__func__, "Could not parse route table number \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
;
923 return 0;
924 }
925
926 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
927 return 0;
928}
929
930int config_parse_gateway_onlink(
931 const char *unit,
932 const char *filename,
933 unsigned line,
934 const char *section,
935 unsigned section_line,
936 const char *lvalue,
937 int ltype,
938 const char *rvalue,
939 void *data,
940 void *userdata) {
941
942 Network *network = userdata;
943 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
944 int r;
945
946 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 946, __PRETTY_FUNCTION__); } while (0)
;
947 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 947, __PRETTY_FUNCTION__); } while (0)
;
948 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 948, __PRETTY_FUNCTION__); } while (0)
;
949 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 949, __PRETTY_FUNCTION__); } while (0)
;
950 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 950, __PRETTY_FUNCTION__); } while (0)
;
951
952 r = route_new_static(network, filename, section_line, &n);
953 if (r < 0)
954 return r;
955
956 r = parse_boolean(rvalue);
957 if (r < 0) {
958 log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 959,
__func__, "Could not parse gateway onlink \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
959 "Could not parse gateway onlink \"%s\", ignoring assignment: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 959,
__func__, "Could not parse gateway onlink \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
;
960 return 0;
961 }
962
963 SET_FLAG(n->flags, RTNH_F_ONLINK, r)(n->flags) = (r) ? ((n->flags) | (4)) : ((n->flags) &
~(4))
;
964 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
965 return 0;
966}
967
968int config_parse_ipv6_route_preference(
969 const char *unit,
970 const char *filename,
971 unsigned line,
972 const char *section,
973 unsigned section_line,
974 const char *lvalue,
975 int ltype,
976 const char *rvalue,
977 void *data,
978 void *userdata) {
979
980 Network *network = userdata;
981 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
982 int r;
983
984 r = route_new_static(network, filename, section_line, &n);
985 if (r < 0)
986 return r;
987
988 if (streq(rvalue, "low")(strcmp((rvalue),("low")) == 0))
989 n->pref = ICMPV6_ROUTER_PREF_LOW0x3;
990 else if (streq(rvalue, "medium")(strcmp((rvalue),("medium")) == 0))
991 n->pref = ICMPV6_ROUTER_PREF_MEDIUM0x0;
992 else if (streq(rvalue, "high")(strcmp((rvalue),("high")) == 0))
993 n->pref = ICMPV6_ROUTER_PREF_HIGH0x1;
994 else {
995 log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route preference: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 995,
__func__, "Unknown route preference: %s", rvalue) : -abs(_e)
; })
;
996 return 0;
997 }
998
999 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
1000 return 0;
1001}
1002
1003int config_parse_route_protocol(
1004 const char *unit,
1005 const char *filename,
1006 unsigned line,
1007 const char *section,
1008 unsigned section_line,
1009 const char *lvalue,
1010 int ltype,
1011 const char *rvalue,
1012 void *data,
1013 void *userdata) {
1014
1015 Network *network = userdata;
1016 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
1017 int r;
1018
1019 r = route_new_static(network, filename, section_line, &n);
1020 if (r < 0)
1021 return r;
1022
1023 if (streq(rvalue, "kernel")(strcmp((rvalue),("kernel")) == 0))
1024 n->protocol = RTPROT_KERNEL2;
1025 else if (streq(rvalue, "boot")(strcmp((rvalue),("boot")) == 0))
1026 n->protocol = RTPROT_BOOT3;
1027 else if (streq(rvalue, "static")(strcmp((rvalue),("static")) == 0))
1028 n->protocol = RTPROT_STATIC4;
1029 else {
1030 r = safe_atou8(rvalue , &n->protocol);
1031 if (r < 0) {
1032 log_syntax(unit, LOG_ERR, filename, line, r, "Could not parse route protocol \"%s\", ignoring assignment: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 1032
, __func__, "Could not parse route protocol \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
;
1033 return 0;
1034 }
1035 }
1036
1037 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
1038 return 0;
1039}
1040
1041int config_parse_route_type(
1042 const char *unit,
1043 const char *filename,
1044 unsigned line,
1045 const char *section,
1046 unsigned section_line,
1047 const char *lvalue,
1048 int ltype,
1049 const char *rvalue,
1050 void *data,
1051 void *userdata) {
1052
1053 Network *network = userdata;
1054 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
1055 int r;
1056
1057 r = route_new_static(network, filename, section_line, &n);
1058 if (r < 0)
1059 return r;
1060
1061 if (streq(rvalue, "unicast")(strcmp((rvalue),("unicast")) == 0))
1062 n->type = RTN_UNICAST;
1063 else if (streq(rvalue, "blackhole")(strcmp((rvalue),("blackhole")) == 0))
1064 n->type = RTN_BLACKHOLE;
1065 else if (streq(rvalue, "unreachable")(strcmp((rvalue),("unreachable")) == 0))
1066 n->type = RTN_UNREACHABLE;
1067 else if (streq(rvalue, "prohibit")(strcmp((rvalue),("prohibit")) == 0))
1068 n->type = RTN_PROHIBIT;
1069 else {
1070 log_syntax(unit, LOG_ERR, filename, line, r, "Could not parse route type \"%s\", ignoring assignment: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 1070
, __func__, "Could not parse route type \"%s\", ignoring assignment: %m"
, rvalue) : -abs(_e); })
;
1071 return 0;
1072 }
1073
1074 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
1075 return 0;
1076}
1077
1078int config_parse_tcp_window(
1079 const char *unit,
1080 const char *filename,
1081 unsigned line,
1082 const char *section,
1083 unsigned section_line,
1084 const char *lvalue,
1085 int ltype,
1086 const char *rvalue,
1087 void *data,
1088 void *userdata) {
1089
1090 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
1091 Network *network = userdata;
1092 uint64_t k;
1093 int r;
1094
1095 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 1095, __PRETTY_FUNCTION__); } while (0)
;
1096 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 1096, __PRETTY_FUNCTION__); } while (0)
;
1097 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 1097, __PRETTY_FUNCTION__); } while (0)
;
1098 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 1098, __PRETTY_FUNCTION__); } while (0)
;
1099 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 1099, __PRETTY_FUNCTION__); } while (0)
;
1100
1101 r = route_new_static(network, filename, section_line, &n);
1102 if (r < 0)
1103 return r;
1104
1105 r = parse_size(rvalue, 1024, &k);
1106 if (r < 0 || k > UINT32_MAX(4294967295U)) {
1107 log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 1108
, __func__, "Could not parse TCP %s \"%s\" bytes, ignoring assignment: %m"
, rvalue, lvalue) : -abs(_e); })
1108 "Could not parse TCP %s \"%s\" bytes, ignoring assignment: %m", rvalue, lvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 1108
, __func__, "Could not parse TCP %s \"%s\" bytes, ignoring assignment: %m"
, rvalue, lvalue) : -abs(_e); })
;
1109 return 0;
1110 }
1111
1112 if (streq(lvalue, "InitialCongestionWindow")(strcmp((lvalue),("InitialCongestionWindow")) == 0))
1113 n->initcwnd = k;
1114 else if (streq(lvalue, "InitialAdvertisedReceiveWindow")(strcmp((lvalue),("InitialAdvertisedReceiveWindow")) == 0))
1115 n->initrwnd = k;
1116 else {
1117 log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse TCP %s: %s", lvalue, rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 1117
, __func__, "Failed to parse TCP %s: %s", lvalue, rvalue) : -
abs(_e); })
;
1118 return 0;
1119 }
1120
1121 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
1122 return 0;
1123}
1124
1125int config_parse_quickack(
1126 const char *unit,
1127 const char *filename,
1128 unsigned line,
1129 const char *section,
1130 unsigned section_line,
1131 const char *lvalue,
1132 int ltype,
1133 const char *rvalue,
1134 void *data,
1135 void *userdata) {
1136
1137 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
1138 Network *network = userdata;
1139 int k, r;
1140
1141 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 1141, __PRETTY_FUNCTION__); } while (0)
;
1142 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 1142, __PRETTY_FUNCTION__); } while (0)
;
1143 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 1143, __PRETTY_FUNCTION__); } while (0)
;
1144 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 1144, __PRETTY_FUNCTION__); } while (0)
;
1145 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 1145, __PRETTY_FUNCTION__); } while (0)
;
1146
1147 r = route_new_static(network, filename, section_line, &n);
1148 if (r < 0)
1149 return r;
1150
1151 k = parse_boolean(rvalue);
1152 if (k < 0) {
1153 log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse TCP quickack, ignoring: %s", rvalue)({ int _level = (3), _e = (k); (log_get_max_level_realm(LOG_REALM_SYSTEMD
) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level
, filename, line, _e, "../src/network/networkd-route.c", 1153
, __func__, "Failed to parse TCP quickack, ignoring: %s", rvalue
) : -abs(_e); })
;
1154 return 0;
1155 }
1156
1157 n->quickack = !!k;
1158 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
1159 return 0;
1160}
1161
1162int config_parse_route_mtu(
1163 const char *unit,
1164 const char *filename,
1165 unsigned line,
1166 const char *section,
1167 unsigned section_line,
1168 const char *lvalue,
1169 int ltype,
1170 const char *rvalue,
1171 void *data,
1172 void *userdata) {
1173
1174 Network *network = userdata;
1175 _cleanup_(route_freep)__attribute__((cleanup(route_freep))) Route *n = NULL((void*)0);
1176 int r;
1177
1178 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-route.c"
, 1178, __PRETTY_FUNCTION__); } while (0)
;
1179 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-route.c"
, 1179, __PRETTY_FUNCTION__); } while (0)
;
1180 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-route.c"
, 1180, __PRETTY_FUNCTION__); } while (0)
;
1181 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-route.c"
, 1181, __PRETTY_FUNCTION__); } while (0)
;
1182 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-route.c"
, 1182, __PRETTY_FUNCTION__); } while (0)
;
1183
1184 r = route_new_static(network, filename, section_line, &n);
1185 if (r < 0)
1186 return r;
1187
1188 r = config_parse_mtu(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &n->mtu, userdata);
1189 if (r < 0)
1190 return r;
1191
1192 TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; });
1193 return 0;
1194}