]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-link.h
Merge pull request #21653 from yuwata/network-dhcp6pd-unreachable-route-cleanups
[thirdparty/systemd.git] / src / network / networkd-link.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
fc2f9534
LP
2#pragma once
3
80431934 4#include <endian.h>
78404d22 5#include <linux/nl80211.h>
80431934 6
634f0f98 7#include "sd-bus.h"
51517f9e 8#include "sd-device.h"
fc2f9534
LP
9#include "sd-dhcp-client.h"
10#include "sd-dhcp-server.h"
fc2f9534 11#include "sd-dhcp6-client.h"
10fa21c0 12#include "sd-ipv4acd.h"
07630cea 13#include "sd-ipv4ll.h"
3a2ee855 14#include "sd-lldp-rx.h"
c01b9b87 15#include "sd-lldp-tx.h"
07630cea 16#include "sd-ndisc.h"
9d5d0090 17#include "sd-radv.h"
634f0f98 18#include "sd-netlink.h"
fc2f9534 19
b8162cd2 20#include "ether-addr-util.h"
e67ae9f5 21#include "log-link.h"
2cd6b932 22#include "network-util.h"
910feb78 23#include "networkd-util.h"
15761549
YW
24#include "ordered-set.h"
25#include "resolve-util.h"
634f0f98 26#include "set.h"
0b1831c2
TG
27
28typedef enum LinkState {
bd08ce56
YW
29 LINK_STATE_PENDING, /* udev has not initialized the link */
30 LINK_STATE_INITIALIZED, /* udev has initialized the link */
31 LINK_STATE_CONFIGURING, /* configuring addresses, routes, etc. */
32 LINK_STATE_CONFIGURED, /* everything is configured */
33 LINK_STATE_UNMANAGED, /* Unmanaged=yes is set */
34 LINK_STATE_FAILED, /* at least one configuration process failed */
35 LINK_STATE_LINGER, /* RTM_DELLINK for the link has been received */
0b1831c2 36 _LINK_STATE_MAX,
2d93c20e 37 _LINK_STATE_INVALID = -EINVAL,
0b1831c2
TG
38} LinkState;
39
634f0f98
ZJS
40typedef struct Manager Manager;
41typedef struct Network Network;
f24648a6 42typedef struct DUID DUID;
fc2f9534 43
634f0f98 44typedef struct Link {
0b1831c2
TG
45 Manager *manager;
46
cf4b2f99 47 unsigned n_ref;
0b1831c2
TG
48
49 int ifindex;
cbff7170 50 int master_ifindex;
0b1831c2 51 char *ifname;
572b21d9 52 char **alternative_names;
6cad256d 53 char *kind;
b710e6b6 54 unsigned short iftype;
0b1831c2 55 char *state_file;
ca2b7cd8
YW
56 struct hw_addr_data hw_addr;
57 struct hw_addr_data bcast_addr;
ed9fa69f 58 struct hw_addr_data permanent_hw_addr;
a8840714 59 struct hw_addr_data requested_hw_addr;
c601ebf7 60 struct in6_addr ipv6ll_address;
0b1831c2 61 uint32_t mtu;
717ba5fc
YW
62 uint32_t min_mtu;
63 uint32_t max_mtu;
64 uint32_t original_mtu;
51517f9e 65 sd_device *sd_device;
c643bda5 66 char *driver;
0b1831c2 67
8d968fdd 68 /* wlan */
78404d22 69 enum nl80211_iftype wlan_iftype;
8d968fdd 70 char *ssid;
6706ce2f 71 char *previous_ssid;
0894cfe4 72 struct ether_addr bssid;
8d968fdd 73
0b1831c2
TG
74 unsigned flags;
75 uint8_t kernel_operstate;
76
6706ce2f
YW
77 sd_event_source *carrier_lost_timer;
78
0b1831c2
TG
79 Network *network;
80
81 LinkState state;
82 LinkOperationalState operstate;
1678fbb3
YW
83 LinkCarrierState carrier_state;
84 LinkAddressState address_state;
8430841b
L
85 LinkAddressState ipv4_address_state;
86 LinkAddressState ipv6_address_state;
bcdcc596 87 LinkOnlineState online_state;
0b1831c2 88
76c5a0f2 89 unsigned static_address_messages;
354bc760 90 unsigned static_address_label_messages;
e5b35bf6 91 unsigned static_bridge_fdb_messages;
ff9e0783 92 unsigned static_bridge_mdb_messages;
fdeba3f5 93 unsigned static_ipv6_proxy_ndp_messages;
40ca350e 94 unsigned static_neighbor_messages;
76c5a0f2
YW
95 unsigned static_nexthop_messages;
96 unsigned static_route_messages;
0e5ef6be 97 unsigned static_routing_policy_rule_messages;
34658df2 98 unsigned tc_messages;
518cd6b5 99 unsigned sr_iov_messages;
0fa8ee6c 100 unsigned set_link_messages;
baa95d22 101 unsigned set_flags_messages;
71a754f7
YW
102 unsigned create_stacked_netdev_messages;
103 unsigned create_stacked_netdev_after_configured_messages;
0b1831c2 104
cf1d700d 105 Set *addresses;
d1bdafd2 106 Set *neighbors;
1c8e710c 107 Set *routes;
c16c7808 108 Set *nexthops;
c42ff3a1 109
0b1831c2 110 sd_dhcp_client *dhcp_client;
6e537f62 111 sd_dhcp_lease *dhcp_lease;
0b1831c2 112 char *lease_file;
3c9b8860 113 unsigned dhcp4_messages;
dd9b10c8
YW
114 bool dhcp4_route_failed:1;
115 bool dhcp4_route_retrying:1;
bd7e5909 116 bool dhcp4_configured:1;
b22d8a00 117
0b1831c2 118 sd_ipv4ll *ipv4ll;
1c09d84e 119 bool ipv4ll_address_configured:1;
0b1831c2 120
76c5a0f2 121 bool static_addresses_configured:1;
354bc760 122 bool static_address_labels_configured:1;
e5b35bf6 123 bool static_bridge_fdb_configured:1;
ff9e0783 124 bool static_bridge_mdb_configured:1;
fdeba3f5 125 bool static_ipv6_proxy_ndp_configured:1;
40ca350e 126 bool static_neighbors_configured:1;
c16c7808 127 bool static_nexthops_configured:1;
76c5a0f2 128 bool static_routes_configured:1;
0e5ef6be 129 bool static_routing_policy_rules_configured:1;
34658df2 130 bool tc_configured:1;
518cd6b5 131 bool sr_iov_configured:1;
61135582 132 bool activated:1;
440d40dc 133 bool master_set:1;
71a754f7
YW
134 bool stacked_netdevs_created:1;
135 bool stacked_netdevs_after_configured_created:1;
3c9b8860 136
0b1831c2
TG
137 sd_dhcp_server *dhcp_server;
138
1e7a0e21
LP
139 sd_ndisc *ndisc;
140 Set *ndisc_rdnss;
141 Set *ndisc_dnssl;
3b6a3bde
YW
142 unsigned ndisc_messages;
143 bool ndisc_configured:1;
1e7a0e21 144
091214b6
PF
145 sd_radv *radv;
146
0b1831c2 147 sd_dhcp6_client *dhcp6_client;
1633c457 148 sd_dhcp6_lease *dhcp6_lease;
4b409e85 149 Set *dhcp6_pd_prefixes;
3b6a3bde
YW
150 unsigned dhcp6_messages;
151 unsigned dhcp6_pd_messages;
152 bool dhcp6_configured:1;
153 bool dhcp6_pd_configured:1;
ce43e484 154
8e1ad1ea 155 /* This is about LLDP reception */
35778343 156 sd_lldp_rx *lldp_rx;
49699bac 157 char *lldp_file;
0d4ad91d 158
8e1ad1ea 159 /* This is about LLDP transmission */
c01b9b87 160 sd_lldp_tx *lldp_tx;
8e1ad1ea 161
0d4ad91d
AR
162 Hashmap *bound_by_links;
163 Hashmap *bound_to_links;
5f707e12 164 Set *slaves;
a879e1a4
YW
165
166 /* For speed meter */
167 struct rtnl_link_stats64 stats_old, stats_new;
168 bool stats_updated;
bafa9641 169
2a71d57f 170 /* All kinds of DNS configuration the user configured via D-Bus */
e77bd3fd 171 struct in_addr_full **dns;
15761549
YW
172 unsigned n_dns;
173 OrderedSet *search_domains, *route_domains;
174
175 int dns_default_route;
176 ResolveSupport llmnr;
177 ResolveSupport mdns;
178 DnssecMode dnssec_mode;
179 DnsOverTlsMode dns_over_tls_mode;
180 Set *dnssec_negative_trust_anchors;
181
2a71d57f 182 /* Similar, but NTP server configuration */
15761549 183 char **ntp;
634f0f98 184} Link;
0b1831c2 185
302a796f
YW
186typedef int (*link_netlink_message_handler_t)(sd_netlink*, sd_netlink_message*, Link*);
187
7191a57a
YW
188bool link_is_ready_to_configure(Link *link, bool allow_unmanaged);
189
15761549
YW
190void link_ntp_settings_clear(Link *link);
191void link_dns_settings_clear(Link *link);
0b1831c2
TG
192Link *link_unref(Link *link);
193Link *link_ref(Link *link);
2c448c8a 194DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
302a796f 195DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
1046bf9b 196
6eab614d 197int link_get_by_index(Manager *m, int ifindex, Link **ret);
0b54c870 198int link_get_by_name(Manager *m, const char *ifname, Link **ret);
fe321d45 199int link_get_by_hw_addr(Manager *m, const struct hw_addr_data *hw_addr, Link **ret);
81357285 200int link_get_master(Link *link, Link **ret);
0b1831c2 201
79c6e114
YW
202int link_getlink_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
203int link_call_getlink(Link *link, link_netlink_message_handler_t callback);
112a0972 204int link_handle_bound_to_list(Link *link);
14b6bb77 205
b22d8a00 206void link_enter_failed(Link *link);
af9ba57a 207void link_set_state(Link *link, LinkState state);
8012cd39 208void link_check_ready(Link *link);
b22d8a00 209
959f65d3 210void link_update_operstate(Link *link, bool also_update_bond_master);
b22d8a00 211
a61bb41c 212bool link_has_carrier(Link *link);
0b1831c2 213
5e0534f1 214bool link_ipv6_enabled(Link *link);
f8f2f880 215bool link_ipv6ll_enabled(Link *link);
7657ec3e 216int link_ipv6ll_gained(Link *link);
e7ab854c 217
3ca1fab7 218bool link_ipv4ll_enabled(Link *link);
8bc17bb3 219
2a99eed0 220int link_stop_engines(Link *link, bool may_keep_dhcp);
946f8e14 221
0b1831c2
TG
222const char* link_state_to_string(LinkState s) _const_;
223LinkState link_state_from_string(const char *s) _pure_;
224
99b8517c 225int link_reconfigure(Link *link, bool force);
d09a179e 226int link_reconfigure_after_sleep(Link *link);
ad932b15 227
3be9d62a
YW
228int manager_udev_process_link(sd_device_monitor *monitor, sd_device *device, void *userdata);
229int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
7ae55b78
YW
230
231int link_flags_to_string_alloc(uint32_t flags, char **ret);
232const char *kernel_operstate_to_string(int t) _const_;