Bug Summary

File:build-scan/../src/network/networkd-brvlan.c
Warning:line 56, column 9
Value stored to 'i' is never read

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-brvlan.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-brvlan.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2/***
3 Copyright © 2016 BISDN GmbH. All rights reserved.
4***/
5
6#include <netinet/in.h>
7#include <linux1/if_bridge.h>
8#include <stdbool.h>
9
10#include "alloc-util.h"
11#include "conf-parser.h"
12#include "netlink-util.h"
13#include "networkd-brvlan.h"
14#include "networkd-link.h"
15#include "networkd-manager.h"
16#include "networkd-network.h"
17#include "parse-util.h"
18#include "vlan-util.h"
19
20static bool_Bool is_bit_set(unsigned bit, uint32_t scope) {
21 assert(bit < sizeof(scope)*8)do { if ((__builtin_expect(!!(!(bit < sizeof(scope)*8)),0)
)) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("bit < sizeof(scope)*8"
), "../src/network/networkd-brvlan.c", 21, __PRETTY_FUNCTION__
); } while (0)
;
22 return scope & (1 << bit);
23}
24
25static inline void set_bit(unsigned nr, uint32_t *addr) {
26 if (nr < BRIDGE_VLAN_BITMAP_MAX4096)
27 addr[nr / 32] |= (((uint32_t) 1) << (nr % 32));
28}
29
30static int find_next_bit(int i, uint32_t x) {
31 int j;
32
33 if (i >= 32)
34 return -1;
35
36 /* find first bit */
37 if (i < 0)
38 return BUILTIN_FFS_U32(x)__builtin_ffs(x);;
39
40 /* mask off prior finds to get next */
41 j = __builtin_ffs(x >> i);
42 return j ? j + i : 0;
43}
44
45static int append_vlan_info_data(Link *const link, sd_netlink_message *req, uint16_t pvid, const uint32_t *br_vid_bitmap, const uint32_t *br_untagged_bitmap) {
46 struct bridge_vlan_info br_vlan;
47 int i, j, k, r, done, cnt;
48 uint16_t begin, end;
49 bool_Bool untagged = false0;
50
51 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-brvlan.c"
, 51, __PRETTY_FUNCTION__); } while (0)
;
52 assert(req)do { if ((__builtin_expect(!!(!(req)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("req"), "../src/network/networkd-brvlan.c"
, 52, __PRETTY_FUNCTION__); } while (0)
;
53 assert(br_vid_bitmap)do { if ((__builtin_expect(!!(!(br_vid_bitmap)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("br_vid_bitmap"), "../src/network/networkd-brvlan.c"
, 53, __PRETTY_FUNCTION__); } while (0)
;
54 assert(br_untagged_bitmap)do { if ((__builtin_expect(!!(!(br_untagged_bitmap)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("br_untagged_bitmap"), "../src/network/networkd-brvlan.c"
, 54, __PRETTY_FUNCTION__); } while (0)
;
55
56 i = cnt = -1;
Value stored to 'i' is never read
57
58 begin = end = UINT16_MAX(65535);
59 for (k = 0; k < BRIDGE_VLAN_BITMAP_LEN(4096 / 32); k++) {
60 unsigned base_bit;
61 uint32_t vid_map = br_vid_bitmap[k];
62 uint32_t untagged_map = br_untagged_bitmap[k];
63
64 base_bit = k * 32;
65 i = -1;
66 done = 0;
67 do {
68 j = find_next_bit(i, vid_map);
69 if (j > 0) {
70 /* first hit of any bit */
71 if (begin == UINT16_MAX(65535) && end == UINT16_MAX(65535)) {
72 begin = end = j - 1 + base_bit;
73 untagged = is_bit_set(j - 1, untagged_map);
74 goto next;
75 }
76
77 /* this bit is a continuation of prior bits */
78 if (j - 2 + base_bit == end && untagged == is_bit_set(j - 1, untagged_map) && (uint16_t)j - 1 + base_bit != pvid && (uint16_t)begin != pvid) {
79 end++;
80 goto next;
81 }
82 } else
83 done = 1;
84
85 if (begin != UINT16_MAX(65535)) {
86 cnt++;
87 if (done && k < BRIDGE_VLAN_BITMAP_LEN(4096 / 32) - 1)
88 break;
89
90 br_vlan.flags = 0;
91 if (untagged)
92 br_vlan.flags |= BRIDGE_VLAN_INFO_UNTAGGED(1<<2);
93
94 if (begin == end) {
95 br_vlan.vid = begin;
96
97 if (begin == pvid)
98 br_vlan.flags |= BRIDGE_VLAN_INFO_PVID(1<<1);
99
100 r = sd_netlink_message_append_data(req, IFLA_BRIDGE_VLAN_INFO, &br_vlan, sizeof(br_vlan));
101 if (r < 0)
102 return log_link_error_errno(link, r, "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 102, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m")
: log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((3)
)), r, "../src/network/networkd-brvlan.c", 102, __func__, "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m"
); })
;
103 } else {
104 br_vlan.vid = begin;
105 br_vlan.flags |= BRIDGE_VLAN_INFO_RANGE_BEGIN(1<<3);
106
107 r = sd_netlink_message_append_data(req, IFLA_BRIDGE_VLAN_INFO, &br_vlan, sizeof(br_vlan));
108 if (r < 0)
109 return log_link_error_errno(link, r, "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 109, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m")
: log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((3)
)), r, "../src/network/networkd-brvlan.c", 109, __func__, "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m"
); })
;
110
111 br_vlan.vid = end;
112 br_vlan.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN(1<<3);
113 br_vlan.flags |= BRIDGE_VLAN_INFO_RANGE_END(1<<4);
114
115 r = sd_netlink_message_append_data(req, IFLA_BRIDGE_VLAN_INFO, &br_vlan, sizeof(br_vlan));
116 if (r < 0)
117 return log_link_error_errno(link, r, "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 117, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m")
: log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((3)
)), r, "../src/network/networkd-brvlan.c", 117, __func__, "Could not append IFLA_BRIDGE_VLAN_INFO attribute: %m"
); })
;
118 }
119
120 if (done)
121 break;
122 }
123 if (j > 0) {
124 begin = end = j - 1 + base_bit;
125 untagged = is_bit_set(j - 1, untagged_map);
126 }
127
128 next:
129 i = j;
130 } while (!done);
131 }
132 if (!cnt)
133 return -EINVAL22;
134
135 return cnt;
136}
137
138static int set_brvlan_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
139 Link *link = userdata;
140 int r;
141
142 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-brvlan.c"
, 142, __PRETTY_FUNCTION__); } while (0)
;
143
144 r = sd_netlink_message_get_errno(m);
145 if (r < 0 && r != -EEXIST17)
146 log_link_error_errno(link, r, "Could not add VLAN to bridge port: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 146, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not add VLAN to bridge port: %m") : log_internal_realm
(((LOG_REALM_SYSTEMD) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 146, __func__, "Could not add VLAN to bridge port: %m"); })
;
147
148 return 1;
149}
150
151int br_vlan_configure(Link *link, uint16_t pvid, uint32_t *br_vid_bitmap, uint32_t *br_untagged_bitmap) {
152 _cleanup_(sd_netlink_message_unrefp)__attribute__((cleanup(sd_netlink_message_unrefp))) sd_netlink_message *req = NULL((void*)0);
153 int r;
154 uint16_t flags;
155 sd_netlink *rtnl;
156
157 assert(link)do { if ((__builtin_expect(!!(!(link)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link"), "../src/network/networkd-brvlan.c"
, 157, __PRETTY_FUNCTION__); } while (0)
;
158 assert(link->manager)do { if ((__builtin_expect(!!(!(link->manager)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link->manager"), "../src/network/networkd-brvlan.c"
, 158, __PRETTY_FUNCTION__); } while (0)
;
159 assert(br_vid_bitmap)do { if ((__builtin_expect(!!(!(br_vid_bitmap)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("br_vid_bitmap"), "../src/network/networkd-brvlan.c"
, 159, __PRETTY_FUNCTION__); } while (0)
;
160 assert(br_untagged_bitmap)do { if ((__builtin_expect(!!(!(br_untagged_bitmap)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("br_untagged_bitmap"), "../src/network/networkd-brvlan.c"
, 160, __PRETTY_FUNCTION__); } while (0)
;
161 assert(link->network)do { if ((__builtin_expect(!!(!(link->network)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("link->network"), "../src/network/networkd-brvlan.c"
, 161, __PRETTY_FUNCTION__); } while (0)
;
162
163 /* pvid might not be in br_vid_bitmap yet */
164 if (pvid)
165 set_bit(pvid, br_vid_bitmap);
166
167 rtnl = link->manager->rtnl;
168
169 /* create new RTM message */
170 r = sd_rtnl_message_new_link(rtnl, &req, RTM_SETLINKRTM_SETLINK, link->ifindex);
171 if (r < 0)
172 return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 172, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not allocate RTM_SETLINK message: %m") : log_internal_realm
(((LOG_REALM_SYSTEMD) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 172, __func__, "Could not allocate RTM_SETLINK message: %m"
); })
;
173
174 r = sd_rtnl_message_link_set_family(req, PF_BRIDGE7);
175 if (r < 0)
176 return log_link_error_errno(link, r, "Could not set message family: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 176, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not set message family: %m") : log_internal_realm
(((LOG_REALM_SYSTEMD) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 176, __func__, "Could not set message family: %m"); })
;
177
178 r = sd_netlink_message_open_container(req, IFLA_AF_SPEC);
179 if (r < 0)
180 return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 180, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not open IFLA_AF_SPEC container: %m") : log_internal_realm
(((LOG_REALM_SYSTEMD) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 180, __func__, "Could not open IFLA_AF_SPEC container: %m")
; })
;
181
182 /* master needs flag self */
183 if (!link->network->bridge) {
184 flags = BRIDGE_FLAGS_SELF2;
185 sd_netlink_message_append_data(req, IFLA_BRIDGE_FLAGS, &flags, sizeof(uint16_t));
186 }
187
188 /* add vlan info */
189 r = append_vlan_info_data(link, req, pvid, br_vid_bitmap, br_untagged_bitmap);
190 if (r < 0)
191 return log_link_error_errno(link, r, "Could not append VLANs: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 191, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not append VLANs: %m") : log_internal_realm(((LOG_REALM_SYSTEMD
) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 191, __func__, "Could not append VLANs: %m"); })
;
192
193 r = sd_netlink_message_close_container(req);
194 if (r < 0)
195 return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 195, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not close IFLA_AF_SPEC container: %m") : log_internal_realm
(((LOG_REALM_SYSTEMD) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 195, __func__, "Could not close IFLA_AF_SPEC container: %m"
); })
;
196
197 /* send message to the kernel */
198 r = sd_netlink_call_async(rtnl, req, set_brvlan_handler, link, 0, NULL((void*)0));
199 if (r < 0)
200 return log_link_error_errno(link, r, "Could not send rtnetlink message: %m")({ const Link *_l = (link); _l ? log_object_internal(3, r, "../src/network/networkd-brvlan.c"
, 200, __func__, "INTERFACE=", _l->ifname, ((void*)0), ((void
*)0), "Could not send rtnetlink message: %m") : log_internal_realm
(((LOG_REALM_SYSTEMD) << 10 | ((3))), r, "../src/network/networkd-brvlan.c"
, 200, __func__, "Could not send rtnetlink message: %m"); })
;
201
202 return 0;
203}
204
205static int parse_vid_range(const char *rvalue, uint16_t *vid, uint16_t *vid_end) {
206 int r;
207 char *p;
208 char *_rvalue = NULL((void*)0);
209 uint16_t _vid = UINT16_MAX(65535);
210 uint16_t _vid_end = UINT16_MAX(65535);
211
212 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-brvlan.c"
, 212, __PRETTY_FUNCTION__); } while (0)
;
213 assert(vid)do { if ((__builtin_expect(!!(!(vid)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("vid"), "../src/network/networkd-brvlan.c"
, 213, __PRETTY_FUNCTION__); } while (0)
;
214 assert(vid_end)do { if ((__builtin_expect(!!(!(vid_end)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("vid_end"), "../src/network/networkd-brvlan.c"
, 214, __PRETTY_FUNCTION__); } while (0)
;
215
216 _rvalue = strdupa(rvalue)(__extension__ ({ const char *__old = (rvalue); size_t __len =
strlen (__old) + 1; char *__new = (char *) __builtin_alloca (
__len); (char *) memcpy (__new, __old, __len); }))
;
217 p = strchr(_rvalue, '-');
218 if (p) {
219 *p = '\0';
220 p++;
221 r = parse_vlanid(_rvalue, &_vid);
222 if (r < 0)
223 return r;
224
225 if (_vid == 0)
226 return -ERANGE34;
227
228 r = parse_vlanid(p, &_vid_end);
229 if (r < 0)
230 return r;
231
232 if (_vid_end == 0)
233 return -ERANGE34;
234 } else {
235 r = parse_vlanid(_rvalue, &_vid);
236 if (r < 0)
237 return r;
238
239 if (_vid == 0)
240 return -ERANGE34;
241 }
242
243 *vid = _vid;
244 *vid_end = _vid_end;
245 return r;
246}
247
248int config_parse_brvlan_pvid(const char *unit, const char *filename,
249 unsigned line, const char *section,
250 unsigned section_line, const char *lvalue,
251 int ltype, const char *rvalue, void *data,
252 void *userdata) {
253 Network *network = userdata;
254 int r;
255 uint16_t pvid;
256 r = parse_vlanid(rvalue, &pvid);
257 if (r < 0)
258 return r;
259
260 network->pvid = pvid;
261 network->use_br_vlan = true1;
262
263 return 0;
264}
265
266int config_parse_brvlan_vlan(const char *unit, const char *filename,
267 unsigned line, const char *section,
268 unsigned section_line, const char *lvalue,
269 int ltype, const char *rvalue, void *data,
270 void *userdata) {
271 Network *network = userdata;
272 int r;
273 uint16_t vid, vid_end;
274
275 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-brvlan.c"
, 275, __PRETTY_FUNCTION__); } while (0)
;
276 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-brvlan.c"
, 276, __PRETTY_FUNCTION__); } while (0)
;
277 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-brvlan.c"
, 277, __PRETTY_FUNCTION__); } while (0)
;
278 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-brvlan.c"
, 278, __PRETTY_FUNCTION__); } while (0)
;
279 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-brvlan.c"
, 279, __PRETTY_FUNCTION__); } while (0)
;
280
281 r = parse_vid_range(rvalue, &vid, &vid_end);
282 if (r < 0) {
283 log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VLAN, ignoring: %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-brvlan.c", 283
, __func__, "Failed to parse VLAN, ignoring: %s", rvalue) : -
abs(_e); })
;
284 return 0;
285 }
286
287 if (UINT16_MAX(65535) == vid_end)
288 set_bit(vid++, network->br_vid_bitmap);
289 else {
290 if (vid >= vid_end) {
291 log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid VLAN range, ignoring %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-brvlan.c", 291
, __func__, "Invalid VLAN range, ignoring %s", rvalue) : -abs
(_e); })
;
292 return 0;
293 }
294 for (; vid <= vid_end; vid++)
295 set_bit(vid, network->br_vid_bitmap);
296 }
297 network->use_br_vlan = true1;
298 return 0;
299}
300
301int config_parse_brvlan_untagged(const char *unit, const char *filename,
302 unsigned line, const char *section,
303 unsigned section_line, const char *lvalue,
304 int ltype, const char *rvalue, void *data,
305 void *userdata) {
306 Network *network = userdata;
307 int r;
308 uint16_t vid, vid_end;
309
310 assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("filename"), "../src/network/networkd-brvlan.c"
, 310, __PRETTY_FUNCTION__); } while (0)
;
311 assert(section)do { if ((__builtin_expect(!!(!(section)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("section"), "../src/network/networkd-brvlan.c"
, 311, __PRETTY_FUNCTION__); } while (0)
;
312 assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("lvalue"), "../src/network/networkd-brvlan.c"
, 312, __PRETTY_FUNCTION__); } while (0)
;
313 assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rvalue"), "../src/network/networkd-brvlan.c"
, 313, __PRETTY_FUNCTION__); } while (0)
;
314 assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("data"), "../src/network/networkd-brvlan.c"
, 314, __PRETTY_FUNCTION__); } while (0)
;
315
316 r = parse_vid_range(rvalue, &vid, &vid_end);
317 if (r < 0) {
318 log_syntax(unit, LOG_ERR, filename, line, r, "Could not parse VLAN: %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-brvlan.c", 318
, __func__, "Could not parse VLAN: %s", rvalue) : -abs(_e); }
)
;
319 return 0;
320 }
321
322 if (UINT16_MAX(65535) == vid_end) {
323 set_bit(vid, network->br_vid_bitmap);
324 set_bit(vid, network->br_untagged_bitmap);
325 } else {
326 if (vid >= vid_end) {
327 log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid VLAN range, ignoring %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-brvlan.c", 327
, __func__, "Invalid VLAN range, ignoring %s", rvalue) : -abs
(_e); })
;
328 return 0;
329 }
330 for (; vid <= vid_end; vid++) {
331 set_bit(vid, network->br_vid_bitmap);
332 set_bit(vid, network->br_untagged_bitmap);
333 }
334 }
335 network->use_br_vlan = true1;
336 return 0;
337}