]> git.proxmox.com Git - systemd.git/blame - src/network/networkd-network.h
bump version to 252.11-pve1
[systemd.git] / src / network / networkd-network.h
CommitLineData
a032b68d 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
d9dfd233
MP
2#pragma once
3
e1f67bc7
MB
4#include <linux/nl80211.h>
5
aa27b158 6#include "sd-bus.h"
6e866b33 7#include "sd-device.h"
ea0999c9 8#include "sd-lldp-tx.h"
aa27b158 9
e1f67bc7 10#include "bridge.h"
d9dfd233 11#include "condition.h"
b012e921 12#include "conf-parser.h"
aa27b158 13#include "hashmap.h"
ea0999c9 14#include "ipoib.h"
3a6ce677 15#include "net-condition.h"
e1f67bc7 16#include "netdev.h"
8b3d4ff0 17#include "networkd-bridge-vlan.h"
f2dec872
BR
18#include "networkd-dhcp-common.h"
19#include "networkd-dhcp4.h"
a10f5d05 20#include "networkd-dhcp6.h"
f5caa8fa 21#include "networkd-ipv6ll.h"
f2dec872 22#include "networkd-lldp-rx.h"
46cdbd49 23#include "networkd-ndisc.h"
1d42b86d 24#include "networkd-radv.h"
a032b68d 25#include "networkd-sysctl.h"
d9dfd233 26#include "networkd-util.h"
bb4f798a 27#include "ordered-set.h"
b012e921 28#include "resolve-util.h"
a10f5d05 29#include "socket-netlink.h"
d9dfd233 30
f2dec872
BR
31typedef enum KeepConfiguration {
32 KEEP_CONFIGURATION_NO = 0,
33 KEEP_CONFIGURATION_DHCP_ON_START = 1 << 0,
34 KEEP_CONFIGURATION_DHCP_ON_STOP = 1 << 1,
35 KEEP_CONFIGURATION_DHCP = KEEP_CONFIGURATION_DHCP_ON_START | KEEP_CONFIGURATION_DHCP_ON_STOP,
36 KEEP_CONFIGURATION_STATIC = 1 << 2,
37 KEEP_CONFIGURATION_YES = KEEP_CONFIGURATION_DHCP | KEEP_CONFIGURATION_STATIC,
38 _KEEP_CONFIGURATION_MAX,
3a6ce677 39 _KEEP_CONFIGURATION_INVALID = -EINVAL,
f2dec872 40} KeepConfiguration;
1d42b86d 41
3a6ce677
BR
42typedef enum ActivationPolicy {
43 ACTIVATION_POLICY_UP,
44 ACTIVATION_POLICY_ALWAYS_UP,
45 ACTIVATION_POLICY_MANUAL,
46 ACTIVATION_POLICY_ALWAYS_DOWN,
47 ACTIVATION_POLICY_DOWN,
48 ACTIVATION_POLICY_BOUND,
49 _ACTIVATION_POLICY_MAX,
50 _ACTIVATION_POLICY_INVALID = -EINVAL,
51} ActivationPolicy;
52
aa27b158
MP
53typedef struct Manager Manager;
54
a10f5d05
MB
55typedef struct NetworkDHCPServerEmitAddress {
56 bool emit;
57 struct in_addr *addresses;
58 size_t n_addresses;
59} NetworkDHCPServerEmitAddress;
60
d9dfd233
MP
61struct Network {
62 Manager *manager;
63
a032b68d
MB
64 unsigned n_ref;
65
d9dfd233 66 char *name;
a032b68d 67 char *filename;
ea0999c9 68 Hashmap *stats_by_path;
a032b68d 69 char *description;
d9dfd233 70
a032b68d 71 /* [Match] section */
3a6ce677 72 NetMatch match;
bb4f798a 73 LIST_HEAD(Condition, conditions);
d9dfd233 74
a032b68d 75 /* Master or stacked netdevs */
ea0999c9 76 bool keep_master;
3a6ce677 77 NetDev *batadv;
d9dfd233
MP
78 NetDev *bridge;
79 NetDev *bond;
5a920b42 80 NetDev *vrf;
f2dec872 81 NetDev *xfrm;
d9dfd233 82 Hashmap *stacked_netdevs;
3a6ce677 83 char *batadv_name;
bb4f798a
MB
84 char *bridge_name;
85 char *bond_name;
86 char *vrf_name;
87 Hashmap *stacked_netdev_names;
d9dfd233 88
a032b68d 89 /* [Link] section */
ea0999c9 90 struct hw_addr_data hw_addr;
a032b68d 91 uint32_t mtu;
ea0999c9 92 int32_t group;
a032b68d
MB
93 int arp;
94 int multicast;
95 int allmulticast;
3a6ce677 96 int promiscuous;
a032b68d 97 bool unmanaged;
626cb2db 98 int required_for_online; /* Is this network required to be considered online? */
a032b68d 99 LinkOperationalStateRange required_operstate_for_online;
8b3d4ff0 100 AddressFamily required_family_for_online;
3a6ce677 101 ActivationPolicy activation_policy;
a032b68d
MB
102
103 /* misc settings */
104 bool configure_without_carrier;
ea0999c9
MB
105 bool ignore_carrier_loss_set;
106 usec_t ignore_carrier_loss_usec; /* timespan */
a032b68d
MB
107 KeepConfiguration keep_configuration;
108 char **bind_carrier;
109 bool default_route_on_device;
3a6ce677 110 AddressFamily ip_masquerade;
a032b68d 111
d9dfd233 112 /* DHCP Client Support */
c5fca32e 113 AddressFamily dhcp;
f5e65279 114 DHCPClientIdentifier dhcp_client_identifier;
8b3d4ff0
MB
115 DUID dhcp_duid;
116 uint32_t dhcp_iaid;
117 bool dhcp_iaid_set;
d9dfd233 118 char *dhcp_vendor_class_identifier;
a10f5d05 119 char *dhcp_mudurl;
b012e921 120 char **dhcp_user_class;
4c89c718 121 char *dhcp_hostname;
ea0999c9 122 char *dhcp_label;
f2dec872 123 uint64_t dhcp_max_attempts;
478ed938 124 uint32_t dhcp_route_metric;
a10f5d05 125 bool dhcp_route_metric_set;
2897b343 126 uint32_t dhcp_route_table;
ea0999c9 127 bool dhcp_route_table_set;
a10f5d05 128 uint32_t dhcp_fallback_lease_lifetime;
46cdbd49 129 uint32_t dhcp_route_mtu;
2897b343 130 uint16_t dhcp_client_port;
e1f67bc7 131 int dhcp_critical;
a032b68d 132 int dhcp_ip_service_type;
f5e65279 133 bool dhcp_anonymize;
4c89c718 134 bool dhcp_send_hostname;
8b3d4ff0 135 int dhcp_broadcast;
2897b343 136 bool dhcp_use_dns;
a10f5d05 137 bool dhcp_use_dns_set;
f2dec872 138 bool dhcp_routes_to_dns;
2897b343 139 bool dhcp_use_ntp;
a10f5d05 140 bool dhcp_use_ntp_set;
8b3d4ff0 141 bool dhcp_routes_to_ntp;
e1f67bc7 142 bool dhcp_use_sip;
2897b343 143 bool dhcp_use_mtu;
4c89c718 144 bool dhcp_use_routes;
a10f5d05 145 int dhcp_use_gateway;
4c89c718 146 bool dhcp_use_timezone;
2897b343 147 bool dhcp_use_hostname;
ea0999c9 148 bool dhcp_use_6rd;
f2dec872 149 bool dhcp_send_release;
46cdbd49 150 bool dhcp_send_decline;
2897b343 151 DHCPUseDomains dhcp_use_domains;
8b3d4ff0 152 bool dhcp_use_domains_set;
a10f5d05
MB
153 Set *dhcp_deny_listed_ip;
154 Set *dhcp_allow_listed_ip;
e1f67bc7
MB
155 Set *dhcp_request_options;
156 OrderedHashmap *dhcp_client_send_options;
a10f5d05 157 OrderedHashmap *dhcp_client_send_vendor_options;
086111aa 158 char *dhcp_netlabel;
f2dec872 159
8b3d4ff0 160 /* DHCPv6 Client support */
3a6ce677 161 bool dhcp6_use_address;
ea0999c9 162 bool dhcp6_use_pd_prefix;
f2dec872 163 bool dhcp6_use_dns;
a10f5d05 164 bool dhcp6_use_dns_set;
3a6ce677 165 bool dhcp6_use_hostname;
f2dec872 166 bool dhcp6_use_ntp;
a10f5d05 167 bool dhcp6_use_ntp_set;
086111aa 168 bool dhcp6_use_rapid_commit;
8b3d4ff0
MB
169 DHCPUseDomains dhcp6_use_domains;
170 bool dhcp6_use_domains_set;
171 uint32_t dhcp6_iaid;
172 bool dhcp6_iaid_set;
173 bool dhcp6_iaid_set_explicitly;
174 DUID dhcp6_duid;
ea0999c9
MB
175 uint8_t dhcp6_pd_prefix_length;
176 struct in6_addr dhcp6_pd_prefix_hint;
a10f5d05
MB
177 char *dhcp6_mudurl;
178 char **dhcp6_user_class;
179 char **dhcp6_vendor_class;
ea0999c9 180 DHCP6ClientStartMode dhcp6_client_start_mode;
a10f5d05
MB
181 OrderedHashmap *dhcp6_client_send_options;
182 OrderedHashmap *dhcp6_client_send_vendor_options;
183 Set *dhcp6_request_options;
086111aa 184 char *dhcp6_netlabel;
d9dfd233
MP
185
186 /* DHCP Server Support */
187 bool dhcp_server;
8b3d4ff0
MB
188 bool dhcp_server_bind_to_interface;
189 unsigned char dhcp_server_address_prefixlen;
190 struct in_addr dhcp_server_address;
191 int dhcp_server_uplink_index;
192 char *dhcp_server_uplink_name;
193 struct in_addr dhcp_server_relay_target;
194 char *dhcp_server_relay_agent_circuit_id;
195 char *dhcp_server_relay_agent_remote_id;
a10f5d05 196 NetworkDHCPServerEmitAddress dhcp_server_emit[_SD_DHCP_LEASE_SERVER_TYPE_MAX];
aa27b158 197 bool dhcp_server_emit_router;
ea0999c9 198 struct in_addr dhcp_server_router;
d9dfd233
MP
199 bool dhcp_server_emit_timezone;
200 char *dhcp_server_timezone;
201 usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
202 uint32_t dhcp_server_pool_offset;
203 uint32_t dhcp_server_pool_size;
a032b68d
MB
204 OrderedHashmap *dhcp_server_send_options;
205 OrderedHashmap *dhcp_server_send_vendor_options;
f5caa8fa
MB
206 struct in_addr dhcp_server_boot_server_address;
207 char *dhcp_server_boot_server_name;
208 char *dhcp_server_boot_filename;
d9dfd233 209
8f232108 210 /* link-local addressing support */
c5fca32e 211 AddressFamily link_local;
a10f5d05 212 IPv6LinkLocalAddressGenMode ipv6ll_address_gen_mode;
8b3d4ff0 213 struct in6_addr ipv6ll_stable_secret;
086111aa 214 struct in_addr ipv4ll_start_address;
d9dfd233
MP
215 bool ipv4ll_route;
216
a032b68d 217 /* IPv6 RA support */
1d42b86d 218 RADVPrefixDelegation router_prefix_delegation;
81c58355
MB
219 usec_t router_lifetime_usec;
220 uint8_t router_preference;
221 bool router_managed;
222 bool router_other_information;
52ad194e
MB
223 bool router_emit_dns;
224 bool router_emit_domains;
f5e65279
MB
225 usec_t router_dns_lifetime_usec;
226 struct in6_addr *router_dns;
227 unsigned n_router_dns;
bb4f798a 228 OrderedSet *router_search_domains;
ea0999c9
MB
229 int router_uplink_index;
230 char *router_uplink_name;
231
232 /* DHCP Prefix Delegation support */
233 int dhcp_pd;
234 bool dhcp_pd_announce;
235 bool dhcp_pd_assign;
236 bool dhcp_pd_manage_temporary_address;
237 int64_t dhcp_pd_subnet_id;
238 uint32_t dhcp_pd_route_metric;
239 Set *dhcp_pd_tokens;
240 int dhcp_pd_uplink_index;
241 char *dhcp_pd_uplink_name;
086111aa 242 char *dhcp_pd_netlabel;
a10f5d05 243
d9dfd233 244 /* Bridge Support */
b012e921
MB
245 int use_bpdu;
246 int hairpin;
f5caa8fa 247 int isolated;
b012e921
MB
248 int fast_leave;
249 int allow_port_to_be_root;
250 int unicast_flood;
bb4f798a 251 int multicast_flood;
6e866b33 252 int multicast_to_unicast;
bb4f798a
MB
253 int neighbor_suppression;
254 int learning;
f2dec872
BR
255 int bridge_proxy_arp;
256 int bridge_proxy_arp_wifi;
81c58355
MB
257 uint32_t cost;
258 uint16_t priority;
f2dec872 259 MulticastRouter multicast_router;
d9dfd233 260
a032b68d 261 /* Bridge VLAN */
8a584da2 262 bool use_br_vlan;
5a920b42
MP
263 uint16_t pvid;
264 uint32_t br_vid_bitmap[BRIDGE_VLAN_BITMAP_LEN];
265 uint32_t br_untagged_bitmap[BRIDGE_VLAN_BITMAP_LEN];
266
b012e921 267 /* CAN support */
a10f5d05 268 uint32_t can_bitrate;
b012e921 269 unsigned can_sample_point;
ea0999c9
MB
270 nsec_t can_time_quanta_ns;
271 uint32_t can_propagation_segment;
272 uint32_t can_phase_buffer_segment_1;
273 uint32_t can_phase_buffer_segment_2;
274 uint32_t can_sync_jump_width;
a10f5d05
MB
275 uint32_t can_data_bitrate;
276 unsigned can_data_sample_point;
ea0999c9
MB
277 nsec_t can_data_time_quanta_ns;
278 uint32_t can_data_propagation_segment;
279 uint32_t can_data_phase_buffer_segment_1;
280 uint32_t can_data_phase_buffer_segment_2;
281 uint32_t can_data_sync_jump_width;
b012e921 282 usec_t can_restart_us;
ea0999c9
MB
283 uint32_t can_control_mode_mask;
284 uint32_t can_control_mode_flags;
285 uint16_t can_termination;
286 bool can_termination_set;
287
288 /* IPoIB support */
289 IPoIBMode ipoib_mode;
290 int ipoib_umcast;
b012e921 291
a032b68d 292 /* sysctl settings */
c5fca32e 293 AddressFamily ip_forward;
a10f5d05 294 int ipv4_accept_local;
3a6ce677 295 int ipv4_route_localnet;
db2df898
MP
296 int ipv6_dad_transmits;
297 int ipv6_hop_limit;
aa27b158 298 int proxy_arp;
b012e921 299 uint32_t ipv6_mtu;
a032b68d
MB
300 IPv6PrivacyExtensions ipv6_privacy_extensions;
301 int ipv6_proxy_ndp;
302 Set *ipv6_proxy_ndp_addresses;
6300502b 303
a032b68d
MB
304 /* IPv6 accept RA */
305 int ipv6_accept_ra;
5a920b42 306 bool ipv6_accept_ra_use_dns;
ea0999c9
MB
307 bool ipv6_accept_ra_use_gateway;
308 bool ipv6_accept_ra_use_route_prefix;
bb4f798a
MB
309 bool ipv6_accept_ra_use_autonomous_prefix;
310 bool ipv6_accept_ra_use_onlink_prefix;
ea0999c9 311 bool ipv6_accept_ra_use_mtu;
2897b343
MP
312 bool active_slave;
313 bool primary_slave;
5a920b42 314 DHCPUseDomains ipv6_accept_ra_use_domains;
a10f5d05 315 IPv6AcceptRAStartDHCP6Client ipv6_accept_ra_start_dhcp6_client;
8a584da2 316 uint32_t ipv6_accept_ra_route_table;
8b3d4ff0
MB
317 bool ipv6_accept_ra_route_table_set;
318 uint32_t ipv6_accept_ra_route_metric;
319 bool ipv6_accept_ra_route_metric_set;
3a6ce677
BR
320 Set *ndisc_deny_listed_router;
321 Set *ndisc_allow_listed_router;
a10f5d05 322 Set *ndisc_deny_listed_prefix;
3a6ce677
BR
323 Set *ndisc_allow_listed_prefix;
324 Set *ndisc_deny_listed_route_prefix;
325 Set *ndisc_allow_listed_route_prefix;
ea0999c9 326 Set *ndisc_tokens;
086111aa 327 char *ndisc_netlabel;
5a920b42 328
a10f5d05 329 /* LLDP support */
aa27b158 330 LLDPMode lldp_mode; /* LLDP reception */
ea0999c9
MB
331 sd_lldp_multicast_mode_t lldp_multicast_mode; /* LLDP transmission */
332 char *lldp_mudurl; /* LLDP MUD URL */
d9dfd233 333
a032b68d 334 OrderedHashmap *addresses_by_section;
d9dfd233 335 Hashmap *routes_by_section;
e1f67bc7 336 Hashmap *nexthops_by_section;
8b3d4ff0
MB
337 Hashmap *bridge_fdb_entries_by_section;
338 Hashmap *bridge_mdb_entries_by_section;
6e866b33 339 Hashmap *neighbors_by_section;
81c58355
MB
340 Hashmap *address_labels_by_section;
341 Hashmap *prefixes_by_section;
e1f67bc7 342 Hashmap *route_prefixes_by_section;
f5e65279 343 Hashmap *rules_by_section;
8b3d4ff0 344 Hashmap *dhcp_static_leases_by_section;
f5caa8fa
MB
345 Hashmap *qdiscs_by_section;
346 Hashmap *tclasses_by_section;
a10f5d05 347 OrderedHashmap *sr_iov_by_section;
d9dfd233 348
6e866b33 349 /* All kinds of DNS configuration */
a10f5d05 350 struct in_addr_full **dns;
2897b343 351 unsigned n_dns;
bb4f798a 352 OrderedSet *search_domains, *route_domains;
6e866b33 353 int dns_default_route;
d9dfd233 354 ResolveSupport llmnr;
4c89c718
MP
355 ResolveSupport mdns;
356 DnssecMode dnssec_mode;
b012e921 357 DnsOverTlsMode dns_over_tls_mode;
4c89c718 358 Set *dnssec_negative_trust_anchors;
d9dfd233 359
a032b68d 360 /* NTP */
6e866b33 361 char **ntp;
d9dfd233
MP
362};
363
f2dec872
BR
364Network *network_ref(Network *network);
365Network *network_unref(Network *network);
366DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
d9dfd233 367
e1f67bc7
MB
368int network_load(Manager *manager, OrderedHashmap **networks);
369int network_reload(Manager *manager);
370int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename);
bb4f798a 371int network_verify(Network *network);
d9dfd233 372
ea0999c9
MB
373int manager_build_dhcp_pd_subnet_ids(Manager *manager);
374
d9dfd233 375int network_get_by_name(Manager *manager, const char *name, Network **ret);
f5e65279 376void network_apply_anonymize_if_set(Network *network);
d9dfd233 377
812752cc 378bool network_has_static_ipv6_configurations(Network *network);
aa27b158 379
bb4f798a 380CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev);
b012e921 381CONFIG_PARSER_PROTOTYPE(config_parse_tunnel);
f2dec872
BR
382CONFIG_PARSER_PROTOTYPE(config_parse_domains);
383CONFIG_PARSER_PROTOTYPE(config_parse_dns);
b012e921 384CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
b012e921 385CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors);
b012e921 386CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
bb4f798a 387CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
8b3d4ff0 388CONFIG_PARSER_PROTOTYPE(config_parse_required_family_for_online);
f2dec872 389CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
3a6ce677 390CONFIG_PARSER_PROTOTYPE(config_parse_activation_policy);
8b3d4ff0 391CONFIG_PARSER_PROTOTYPE(config_parse_link_group);
ea0999c9 392CONFIG_PARSER_PROTOTYPE(config_parse_ignore_carrier_loss);
d9dfd233 393
2897b343 394const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
d9dfd233 395
f2dec872
BR
396const char* keep_configuration_to_string(KeepConfiguration i) _const_;
397KeepConfiguration keep_configuration_from_string(const char *s) _pure_;
a10f5d05 398
3a6ce677
BR
399const char* activation_policy_to_string(ActivationPolicy i) _const_;
400ActivationPolicy activation_policy_from_string(const char *s) _pure_;