]>
Commit | Line | Data |
---|---|---|
f579559b TG |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2013 Tom Gundersen <teg@jklm.no> | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #pragma once | |
23 | ||
24 | #include <arpa/inet.h> | |
f579559b TG |
25 | |
26 | #include "sd-event.h" | |
27 | #include "sd-rtnl.h" | |
1346b1f0 | 28 | #include "sd-bus.h" |
f5be5601 | 29 | #include "sd-dhcp-client.h" |
dd43110f | 30 | #include "sd-dhcp-server.h" |
5c1d3fc9 | 31 | #include "sd-ipv4ll.h" |
f579559b TG |
32 | #include "udev.h" |
33 | ||
34 | #include "rtnl-util.h" | |
35 | #include "hashmap.h" | |
36 | #include "list.h" | |
06f021a8 | 37 | #include "set.h" |
2cc412b5 | 38 | #include "condition-util.h" |
f579559b | 39 | |
aba496a5 UTL |
40 | #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU |
41 | ||
1a436809 | 42 | typedef struct NetDev NetDev; |
f579559b TG |
43 | typedef struct Network Network; |
44 | typedef struct Link Link; | |
45 | typedef struct Address Address; | |
46 | typedef struct Route Route; | |
47 | typedef struct Manager Manager; | |
48 | ||
52433f6b | 49 | typedef struct netdev_enslave_callback netdev_enslave_callback; |
02b59d57 | 50 | |
52433f6b | 51 | struct netdev_enslave_callback { |
02b59d57 TG |
52 | sd_rtnl_message_handler_t callback; |
53 | Link *link; | |
54 | ||
52433f6b | 55 | LIST_FIELDS(netdev_enslave_callback, callbacks); |
02b59d57 TG |
56 | }; |
57 | ||
fe6b2d55 TG |
58 | typedef enum MacVlanMode { |
59 | NETDEV_MACVLAN_MODE_PRIVATE = MACVLAN_MODE_PRIVATE, | |
60 | NETDEV_MACVLAN_MODE_VEPA = MACVLAN_MODE_VEPA, | |
61 | NETDEV_MACVLAN_MODE_BRIDGE = MACVLAN_MODE_BRIDGE, | |
62 | NETDEV_MACVLAN_MODE_PASSTHRU = MACVLAN_MODE_PASSTHRU, | |
63 | _NETDEV_MACVLAN_MODE_MAX, | |
64 | _NETDEV_MACVLAN_MODE_INVALID = -1 | |
65 | } MacVlanMode; | |
66 | ||
1a436809 | 67 | typedef enum NetDevKind { |
52433f6b TG |
68 | NETDEV_KIND_BRIDGE, |
69 | NETDEV_KIND_BOND, | |
54abf461 | 70 | NETDEV_KIND_VLAN, |
fe6b2d55 | 71 | NETDEV_KIND_MACVLAN, |
7951dea2 SS |
72 | NETDEV_KIND_IPIP, |
73 | NETDEV_KIND_GRE, | |
74 | NETDEV_KIND_SIT, | |
10142d75 | 75 | NETDEV_KIND_VETH, |
a613382b | 76 | NETDEV_KIND_VTI, |
52433f6b TG |
77 | _NETDEV_KIND_MAX, |
78 | _NETDEV_KIND_INVALID = -1 | |
1a436809 | 79 | } NetDevKind; |
52433f6b | 80 | |
1a436809 | 81 | typedef enum NetDevState { |
52433f6b TG |
82 | NETDEV_STATE_FAILED, |
83 | NETDEV_STATE_CREATING, | |
84 | NETDEV_STATE_READY, | |
2cc7e981 | 85 | NETDEV_STATE_LINGER, |
52433f6b TG |
86 | _NETDEV_STATE_MAX, |
87 | _NETDEV_STATE_INVALID = -1, | |
1a436809 | 88 | } NetDevState; |
52433f6b | 89 | |
1a436809 | 90 | struct NetDev { |
02b59d57 TG |
91 | Manager *manager; |
92 | ||
14b746f7 TG |
93 | int n_ref; |
94 | ||
02b59d57 TG |
95 | char *filename; |
96 | ||
edbb03e9 TG |
97 | Condition *match_host; |
98 | Condition *match_virt; | |
99 | Condition *match_kernel; | |
100 | Condition *match_arch; | |
c0dda186 | 101 | |
02b59d57 | 102 | char *description; |
af4e9e2c | 103 | char *ifname; |
10142d75 | 104 | char *ifname_peer; |
7951dea2 | 105 | size_t mtu; |
1a436809 | 106 | NetDevKind kind; |
02b59d57 | 107 | |
672682a6 | 108 | uint64_t vlanid; |
fe6b2d55 | 109 | int32_t macvlan_mode; |
54abf461 | 110 | |
50add290 | 111 | int ifindex; |
1a436809 | 112 | NetDevState state; |
02b59d57 | 113 | |
a9f434cf | 114 | bool tunnel_pmtudisc; |
7951dea2 SS |
115 | unsigned tunnel_ttl; |
116 | unsigned tunnel_tos; | |
117 | struct in_addr tunnel_local; | |
118 | struct in_addr tunnel_remote; | |
119 | ||
52433f6b | 120 | LIST_HEAD(netdev_enslave_callback, callbacks); |
02b59d57 TG |
121 | }; |
122 | ||
f579559b TG |
123 | struct Network { |
124 | Manager *manager; | |
125 | ||
126 | char *filename; | |
127 | ||
128 | struct ether_addr *match_mac; | |
129 | char *match_path; | |
130 | char *match_driver; | |
131 | char *match_type; | |
132 | char *match_name; | |
2cc412b5 TG |
133 | Condition *match_host; |
134 | Condition *match_virt; | |
135 | Condition *match_kernel; | |
edbb03e9 | 136 | Condition *match_arch; |
f579559b TG |
137 | |
138 | char *description; | |
1a436809 TG |
139 | NetDev *bridge; |
140 | NetDev *bond; | |
7951dea2 | 141 | NetDev *tunnel; |
672682a6 | 142 | Hashmap *vlans; |
fe6b2d55 | 143 | Hashmap *macvlans; |
f5be5601 | 144 | bool dhcp; |
5be4d38e | 145 | bool dhcp_dns; |
bcb7a07e | 146 | bool dhcp_ntp; |
4f882b2a | 147 | bool dhcp_mtu; |
1346b1f0 | 148 | bool dhcp_hostname; |
039ebe6a | 149 | bool dhcp_domainname; |
eb27aeca | 150 | bool dhcp_critical; |
5c1d3fc9 | 151 | bool ipv4ll; |
f579559b | 152 | |
dd43110f TG |
153 | bool dhcp_server; |
154 | ||
f048a16b TG |
155 | LIST_HEAD(Address, static_addresses); |
156 | LIST_HEAD(Route, static_routes); | |
f579559b | 157 | |
6ae115c1 TG |
158 | Hashmap *addresses_by_section; |
159 | Hashmap *routes_by_section; | |
160 | ||
d4920165 | 161 | LIST_HEAD(Address, dns); |
bcb7a07e | 162 | LIST_HEAD(Address, ntp); |
06f021a8 | 163 | |
f579559b TG |
164 | LIST_FIELDS(Network, networks); |
165 | }; | |
166 | ||
167 | struct Address { | |
168 | Network *network; | |
6ae115c1 | 169 | uint64_t section; |
f579559b TG |
170 | |
171 | unsigned char family; | |
172 | unsigned char prefixlen; | |
5c1d3fc9 | 173 | unsigned char scope; |
f579559b TG |
174 | char *label; |
175 | ||
eb0ea358 | 176 | struct in_addr broadcast; |
aba496a5 | 177 | struct ifa_cacheinfo cinfo; |
8cd11a0f | 178 | |
f579559b TG |
179 | union { |
180 | struct in_addr in; | |
181 | struct in6_addr in6; | |
182 | } in_addr; | |
183 | ||
3d3d4255 | 184 | LIST_FIELDS(Address, addresses); |
f579559b TG |
185 | }; |
186 | ||
187 | struct Route { | |
188 | Network *network; | |
6ae115c1 | 189 | uint64_t section; |
f579559b TG |
190 | |
191 | unsigned char family; | |
6ae115c1 | 192 | unsigned char dst_prefixlen; |
5c1d3fc9 UTL |
193 | unsigned char scope; |
194 | uint32_t metrics; | |
f579559b TG |
195 | |
196 | union { | |
197 | struct in_addr in; | |
198 | struct in6_addr in6; | |
199 | } in_addr; | |
200 | ||
6ae115c1 TG |
201 | union { |
202 | struct in_addr in; | |
203 | struct in6_addr in6; | |
204 | } dst_addr; | |
205 | ||
3d3d4255 | 206 | LIST_FIELDS(Route, routes); |
f579559b TG |
207 | }; |
208 | ||
f882c247 | 209 | typedef enum LinkState { |
505f8da7 | 210 | LINK_STATE_INITIALIZING, |
52433f6b | 211 | LINK_STATE_ENSLAVING, |
ef1ba606 TG |
212 | LINK_STATE_SETTING_ADDRESSES, |
213 | LINK_STATE_SETTING_ROUTES, | |
f882c247 | 214 | LINK_STATE_CONFIGURED, |
57bd6899 | 215 | LINK_STATE_UNMANAGED, |
f882c247 | 216 | LINK_STATE_FAILED, |
370e9930 | 217 | LINK_STATE_LINGER, |
f882c247 TG |
218 | _LINK_STATE_MAX, |
219 | _LINK_STATE_INVALID = -1 | |
220 | } LinkState; | |
221 | ||
e375dcde TG |
222 | typedef enum LinkOperationalState { |
223 | LINK_OPERSTATE_UNKNOWN, | |
224 | LINK_OPERSTATE_DORMANT, | |
225 | LINK_OPERSTATE_CARRIER, | |
226 | LINK_OPERSTATE_DEGRADED, | |
227 | LINK_OPERSTATE_ROUTABLE, | |
228 | _LINK_OPERSTATE_MAX, | |
229 | _LINK_OPERSTATE_INVALID = -1 | |
230 | } LinkOperationalState; | |
231 | ||
f579559b TG |
232 | struct Link { |
233 | Manager *manager; | |
234 | ||
14b746f7 TG |
235 | int n_ref; |
236 | ||
0617ffab | 237 | uint64_t ifindex; |
c166a070 | 238 | char *ifname; |
fe8db0c5 | 239 | char *state_file; |
8cd11a0f | 240 | struct ether_addr mac; |
b5db00e5 | 241 | struct udev_device *udev_device; |
f579559b TG |
242 | |
243 | unsigned flags; | |
e375dcde | 244 | uint8_t kernel_operstate; |
f579559b TG |
245 | |
246 | Network *network; | |
f882c247 TG |
247 | |
248 | LinkState state; | |
e375dcde | 249 | LinkOperationalState operstate; |
f882c247 | 250 | |
f5be5601 TG |
251 | unsigned addr_messages; |
252 | unsigned route_messages; | |
52433f6b | 253 | unsigned enslaving; |
f5be5601 | 254 | |
428fd0a7 TG |
255 | LIST_HEAD(Address, addresses); |
256 | ||
a6cc569e TG |
257 | sd_dhcp_client *dhcp_client; |
258 | sd_dhcp_lease *dhcp_lease; | |
68a8723c | 259 | char *lease_file; |
a6cc569e | 260 | uint16_t original_mtu; |
5c1d3fc9 | 261 | sd_ipv4ll *ipv4ll; |
dd43110f TG |
262 | |
263 | sd_dhcp_server *dhcp_server; | |
f579559b TG |
264 | }; |
265 | ||
266 | struct Manager { | |
267 | sd_rtnl *rtnl; | |
268 | sd_event *event; | |
1346b1f0 | 269 | sd_bus *bus; |
f579559b TG |
270 | struct udev *udev; |
271 | struct udev_monitor *udev_monitor; | |
272 | sd_event_source *udev_event_source; | |
0c2f9b84 TG |
273 | sd_event_source *sigterm_event_source; |
274 | sd_event_source *sigint_event_source; | |
f579559b | 275 | |
bbf7c048 TG |
276 | char *state_file; |
277 | ||
f579559b | 278 | Hashmap *links; |
52433f6b | 279 | Hashmap *netdevs; |
f579559b TG |
280 | LIST_HEAD(Network, networks); |
281 | ||
f579559b TG |
282 | usec_t network_dirs_ts_usec; |
283 | }; | |
284 | ||
2ad8416d ZJS |
285 | extern const char* const network_dirs[]; |
286 | ||
f579559b TG |
287 | /* Manager */ |
288 | ||
289 | int manager_new(Manager **ret); | |
290 | void manager_free(Manager *m); | |
291 | ||
02b59d57 TG |
292 | int manager_load_config(Manager *m); |
293 | bool manager_should_reload(Manager *m); | |
294 | ||
505f8da7 | 295 | int manager_rtnl_enumerate_links(Manager *m); |
f579559b | 296 | |
f882c247 | 297 | int manager_rtnl_listen(Manager *m); |
505f8da7 | 298 | int manager_udev_listen(Manager *m); |
1346b1f0 | 299 | int manager_bus_listen(Manager *m); |
f882c247 | 300 | |
bbf7c048 | 301 | int manager_save(Manager *m); |
3bef724f | 302 | |
f579559b TG |
303 | DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); |
304 | #define _cleanup_manager_free_ _cleanup_(manager_freep) | |
305 | ||
1a436809 | 306 | /* NetDev */ |
52433f6b TG |
307 | |
308 | int netdev_load(Manager *manager); | |
2cc7e981 | 309 | void netdev_drop(NetDev *netdev); |
02b59d57 | 310 | |
14b746f7 TG |
311 | NetDev *netdev_unref(NetDev *netdev); |
312 | NetDev *netdev_ref(NetDev *netdev); | |
02b59d57 | 313 | |
14b746f7 TG |
314 | DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref); |
315 | #define _cleanup_netdev_unref_ _cleanup_(netdev_unrefp) | |
02b59d57 | 316 | |
1a436809 | 317 | int netdev_get(Manager *manager, const char *name, NetDev **ret); |
d39edfc7 | 318 | int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *newlink); |
1a436809 | 319 | int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t cb); |
7951dea2 | 320 | int netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback); |
10142d75 | 321 | int netdev_create_veth(NetDev *netdev, sd_rtnl_message_handler_t callback); |
02b59d57 | 322 | |
1a436809 TG |
323 | const char *netdev_kind_to_string(NetDevKind d) _const_; |
324 | NetDevKind netdev_kind_from_string(const char *d) _pure_; | |
52433f6b | 325 | |
fe6b2d55 TG |
326 | const char *macvlan_mode_to_string(MacVlanMode d) _const_; |
327 | MacVlanMode macvlan_mode_from_string(const char *d) _pure_; | |
328 | ||
52433f6b | 329 | int config_parse_netdev_kind(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
02b59d57 | 330 | |
fe6b2d55 TG |
331 | int config_parse_macvlan_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
332 | ||
c0dda186 TG |
333 | /* gperf */ |
334 | const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsigned length); | |
335 | ||
f579559b TG |
336 | /* Network */ |
337 | ||
338 | int network_load(Manager *manager); | |
f579559b TG |
339 | |
340 | void network_free(Network *network); | |
341 | ||
342 | DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free); | |
343 | #define _cleanup_network_free_ _cleanup_(network_freep) | |
344 | ||
505f8da7 TG |
345 | int network_get(Manager *manager, struct udev_device *device, |
346 | const char *ifname, const struct ether_addr *mac, | |
347 | Network **ret); | |
f579559b TG |
348 | int network_apply(Manager *manager, Network *network, Link *link); |
349 | ||
69a93e7d | 350 | int config_parse_netdev(const char *unit, const char *filename, unsigned line, |
02b59d57 TG |
351 | const char *section, unsigned section_line, const char *lvalue, |
352 | int ltype, const char *rvalue, void *data, void *userdata); | |
353 | ||
7951dea2 SS |
354 | int config_parse_tunnel(const char *unit, |
355 | const char *filename, | |
356 | unsigned line, | |
357 | const char *section, | |
358 | unsigned section_line, | |
359 | const char *lvalue, | |
360 | int ltype, | |
361 | const char *rvalue, | |
362 | void *data, | |
363 | void *userdata); | |
364 | ||
365 | int config_parse_tunnel_address(const char *unit, | |
366 | const char *filename, | |
367 | unsigned line, | |
368 | const char *section, | |
369 | unsigned section_line, | |
370 | const char *lvalue, | |
371 | int ltype, | |
372 | const char *rvalue, | |
373 | void *data, | |
374 | void *userdata); | |
375 | ||
02b59d57 | 376 | /* gperf */ |
c0dda186 | 377 | const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length); |
f579559b TG |
378 | |
379 | /* Route */ | |
f048a16b TG |
380 | int route_new_static(Network *network, unsigned section, Route **ret); |
381 | int route_new_dynamic(Route **ret); | |
f579559b | 382 | void route_free(Route *route); |
f882c247 | 383 | int route_configure(Route *route, Link *link, sd_rtnl_message_handler_t callback); |
5c1d3fc9 UTL |
384 | int route_drop(Route *route, Link *link, sd_rtnl_message_handler_t callback); |
385 | ||
f579559b TG |
386 | |
387 | DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free); | |
388 | #define _cleanup_route_free_ _cleanup_(route_freep) | |
389 | ||
390 | int config_parse_gateway(const char *unit, const char *filename, unsigned line, | |
71a61510 TG |
391 | const char *section, unsigned section_line, const char *lvalue, |
392 | int ltype, const char *rvalue, void *data, void *userdata); | |
f579559b | 393 | |
6ae115c1 TG |
394 | int config_parse_destination(const char *unit, const char *filename, unsigned line, |
395 | const char *section, unsigned section_line, const char *lvalue, | |
396 | int ltype, const char *rvalue, void *data, void *userdata); | |
397 | ||
f579559b | 398 | /* Address */ |
f048a16b TG |
399 | int address_new_static(Network *network, unsigned section, Address **ret); |
400 | int address_new_dynamic(Address **ret); | |
f579559b | 401 | void address_free(Address *address); |
f882c247 | 402 | int address_configure(Address *address, Link *link, sd_rtnl_message_handler_t callback); |
aba496a5 | 403 | int address_update(Address *address, Link *link, sd_rtnl_message_handler_t callback); |
407fe036 | 404 | int address_drop(Address *address, Link *link, sd_rtnl_message_handler_t callback); |
9505d3c6 | 405 | bool address_equal(Address *a1, Address *a2); |
f579559b TG |
406 | |
407 | DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free); | |
408 | #define _cleanup_address_free_ _cleanup_(address_freep) | |
409 | ||
3bef724f TG |
410 | int config_parse_dns(const char *unit, const char *filename, unsigned line, |
411 | const char *section, unsigned section_line, const char *lvalue, | |
412 | int ltype, const char *rvalue, void *data, void *userdata); | |
413 | ||
f579559b | 414 | int config_parse_address(const char *unit, const char *filename, unsigned line, |
71a61510 TG |
415 | const char *section, unsigned section_line, const char *lvalue, |
416 | int ltype, const char *rvalue, void *data, void *userdata); | |
f579559b | 417 | |
eb0ea358 TG |
418 | int config_parse_broadcast(const char *unit, const char *filename, unsigned line, |
419 | const char *section, unsigned section_line, const char *lvalue, | |
420 | int ltype, const char *rvalue, void *data, void *userdata); | |
421 | ||
6ae115c1 TG |
422 | int config_parse_label(const char *unit, const char *filename, unsigned line, |
423 | const char *section, unsigned section_line, const char *lvalue, | |
424 | int ltype, const char *rvalue, void *data, void *userdata); | |
425 | ||
f579559b TG |
426 | /* Link */ |
427 | ||
14b746f7 TG |
428 | Link *link_unref(Link *link); |
429 | Link *link_ref(Link *link); | |
11a7f229 | 430 | int link_get(Manager *m, int ifindex, Link **ret); |
505f8da7 | 431 | int link_add(Manager *manager, sd_rtnl_message *message, Link **ret); |
370e9930 | 432 | void link_drop(Link *link); |
f579559b | 433 | |
22936833 | 434 | int link_update(Link *link, sd_rtnl_message *message); |
fbbeb65a | 435 | int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *userdata); |
dd3efc09 | 436 | |
505f8da7 TG |
437 | int link_initialized(Link *link, struct udev_device *device); |
438 | ||
fe8db0c5 TG |
439 | int link_save(Link *link); |
440 | ||
bbf7c048 TG |
441 | bool link_has_carrier(unsigned flags, uint8_t operstate); |
442 | ||
fe8db0c5 TG |
443 | const char* link_state_to_string(LinkState s) _const_; |
444 | LinkState link_state_from_string(const char *s) _pure_; | |
445 | ||
e375dcde TG |
446 | const char* link_operstate_to_string(LinkOperationalState s) _const_; |
447 | LinkOperationalState link_operstate_from_string(const char *s) _pure_; | |
448 | ||
14b746f7 TG |
449 | DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref); |
450 | #define _cleanup_link_unref_ _cleanup_(link_unrefp) | |
3333d748 ZJS |
451 | |
452 | /* Macros which append INTERFACE= to the message */ | |
453 | ||
987efa17 | 454 | #define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__) |
39032b87 ZJS |
455 | #define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__) |
456 | #define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__) | |
457 | #define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__) | |
458 | #define log_warning_link(link, ...) log_full_link(LOG_WARNING, link, ##__VA_ARGS__) | |
459 | #define log_error_link(link, ...) log_full_link(LOG_ERR, link, ##__VA_ARGS__) | |
3333d748 ZJS |
460 | |
461 | #define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__) | |
462 | ||
463 | /* More macros which append INTERFACE= to the message */ | |
464 | ||
987efa17 | 465 | #define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__) |
52433f6b TG |
466 | #define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__) |
467 | #define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__) | |
468 | #define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__) | |
469 | #define log_warning_netdev(netdev, ...) log_full_netdev(LOG_WARNING, netdev,## __VA_ARGS__) | |
470 | #define log_error_netdev(netdev, ...) log_full_netdev(LOG_ERR, netdev, ##__VA_ARGS__) | |
3333d748 | 471 | |
af4e9e2c | 472 | #define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->ifname, __VA_ARGS__) |
3333d748 | 473 | |
af4e9e2c | 474 | #define NETDEV(netdev) "INTERFACE=%s", netdev->ifname |
62870613 ZJS |
475 | #define ADDRESS_FMT_VAL(address) \ |
476 | (address).s_addr & 0xFF, \ | |
477 | ((address).s_addr >> 8) & 0xFF, \ | |
478 | ((address).s_addr >> 16) & 0xFF, \ | |
479 | (address).s_addr >> 24 |