]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - src/network/networkd-link.h
network: disable kernel creating prefix route when RouteTable= is set
[thirdparty/systemd.git] / src / network / networkd-link.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: LGPL-2.1+ */
2#pragma once
3
4#include <endian.h>
5
6#include "sd-bus.h"
7#include "sd-device.h"
8#include "sd-dhcp-client.h"
9#include "sd-dhcp-server.h"
10#include "sd-dhcp6-client.h"
11#include "sd-ipv4ll.h"
12#include "sd-lldp.h"
13#include "sd-ndisc.h"
14#include "sd-radv.h"
15#include "sd-netlink.h"
16
17#include "list.h"
18#include "log-link.h"
19#include "network-util.h"
20#include "networkd-util.h"
21#include "ordered-set.h"
22#include "resolve-util.h"
23#include "set.h"
24
25typedef enum LinkState {
26 LINK_STATE_PENDING, /* udev has not initialized the link */
27 LINK_STATE_INITIALIZED, /* udev has initialized the link */
28 LINK_STATE_CONFIGURING, /* configuring addresses, routes, etc. */
29 LINK_STATE_CONFIGURED, /* everything is configured */
30 LINK_STATE_UNMANAGED, /* Unmanaged=yes is set */
31 LINK_STATE_FAILED, /* at least one configuration process failed */
32 LINK_STATE_LINGER, /* RTM_DELLINK for the link has been received */
33 _LINK_STATE_MAX,
34 _LINK_STATE_INVALID = -1
35} LinkState;
36
37typedef struct Manager Manager;
38typedef struct Network Network;
39typedef struct Address Address;
40typedef struct DUID DUID;
41
42typedef struct Link {
43 Manager *manager;
44
45 unsigned n_ref;
46
47 int ifindex;
48 int master_ifindex;
49 char *ifname;
50 char *kind;
51 unsigned short iftype;
52 char *state_file;
53 struct ether_addr mac;
54 struct in6_addr ipv6ll_address;
55 uint32_t mtu;
56 sd_device *sd_device;
57
58 unsigned flags;
59 uint8_t kernel_operstate;
60
61 Network *network;
62
63 LinkState state;
64 LinkOperationalState operstate;
65 LinkCarrierState carrier_state;
66 LinkAddressState address_state;
67
68 unsigned address_messages;
69 unsigned address_label_messages;
70 unsigned neighbor_messages;
71 unsigned route_messages;
72 unsigned routing_policy_rule_messages;
73 unsigned routing_policy_rule_remove_messages;
74 unsigned enslaving;
75
76 Set *addresses;
77 Set *addresses_foreign;
78 Set *routes;
79 Set *routes_foreign;
80
81 bool addresses_configured;
82 bool addresses_ready;
83
84 sd_dhcp_client *dhcp_client;
85 sd_dhcp_lease *dhcp_lease, *dhcp_lease_old;
86 Set *dhcp_routes;
87 char *lease_file;
88 uint32_t original_mtu;
89 unsigned dhcp4_messages;
90 bool dhcp4_configured:1;
91 bool dhcp6_configured:1;
92
93 unsigned ndisc_messages;
94 bool ndisc_configured;
95
96 sd_ipv4ll *ipv4ll;
97 bool ipv4ll_address:1;
98 bool ipv4ll_route:1;
99
100 bool neighbors_configured:1;
101 bool static_routes_configured:1;
102 bool routing_policy_rules_configured:1;
103 bool setting_mtu:1;
104
105 LIST_HEAD(Address, pool_addresses);
106
107 sd_dhcp_server *dhcp_server;
108
109 sd_ndisc *ndisc;
110 Set *ndisc_rdnss;
111 Set *ndisc_dnssl;
112
113 sd_radv *radv;
114
115 sd_dhcp6_client *dhcp6_client;
116
117 /* This is about LLDP reception */
118 sd_lldp *lldp;
119 char *lldp_file;
120
121 /* This is about LLDP transmission */
122 unsigned lldp_tx_fast; /* The LLDP txFast counter (See 802.1ab-2009, section 9.2.5.18) */
123 sd_event_source *lldp_emit_event_source;
124
125 Hashmap *bound_by_links;
126 Hashmap *bound_to_links;
127 Set *slaves;
128
129 /* For speed meter */
130 struct rtnl_link_stats64 stats_old, stats_new;
131 bool stats_updated;
132
133 int sysctl_ipv6_enabled;
134
135 /* All kinds of DNS configuration */
136 struct in_addr_data *dns;
137 unsigned n_dns;
138 OrderedSet *search_domains, *route_domains;
139
140 int dns_default_route;
141 ResolveSupport llmnr;
142 ResolveSupport mdns;
143 DnssecMode dnssec_mode;
144 DnsOverTlsMode dns_over_tls_mode;
145 Set *dnssec_negative_trust_anchors;
146
147 char **ntp;
148} Link;
149
150typedef int (*link_netlink_message_handler_t)(sd_netlink*, sd_netlink_message*, Link*);
151
152DUID *link_get_duid(Link *link);
153int get_product_uuid_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error);
154
155void link_ntp_settings_clear(Link *link);
156void link_dns_settings_clear(Link *link);
157Link *link_unref(Link *link);
158Link *link_ref(Link *link);
159DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
160DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
161
162int link_get(Manager *m, int ifindex, Link **ret);
163int link_add(Manager *manager, sd_netlink_message *message, Link **ret);
164void link_drop(Link *link);
165
166int link_down(Link *link, link_netlink_message_handler_t callback);
167
168void link_enter_failed(Link *link);
169int link_initialized(Link *link, sd_device *device);
170
171void link_set_state(Link *link, LinkState state);
172void link_check_ready(Link *link);
173
174void link_update_operstate(Link *link, bool also_update_bond_master);
175int link_update(Link *link, sd_netlink_message *message);
176
177void link_dirty(Link *link);
178void link_clean(Link *link);
179int link_save(Link *link);
180
181int link_carrier_reset(Link *link);
182bool link_has_carrier(Link *link);
183
184int link_ipv6ll_gained(Link *link, const struct in6_addr *address);
185
186int link_set_mtu(Link *link, uint32_t mtu);
187
188bool link_ipv4ll_enabled(Link *link, AddressFamilyBoolean mask);
189
190int link_stop_clients(Link *link, bool may_keep_dhcp);
191
192const char* link_state_to_string(LinkState s) _const_;
193LinkState link_state_from_string(const char *s) _pure_;
194
195uint32_t link_get_vrf_table(Link *link);
196uint32_t link_get_dhcp_route_table(Link *link);
197uint32_t link_get_ipv6_accept_ra_route_table(Link *link);
198int link_request_set_routes(Link *link);
199
200int link_sysctl_ipv6_enabled(Link *link);
201
202#define ADDRESS_FMT_VAL(address) \
203 be32toh((address).s_addr) >> 24, \
204 (be32toh((address).s_addr) >> 16) & 0xFFu, \
205 (be32toh((address).s_addr) >> 8) & 0xFFu, \
206 be32toh((address).s_addr) & 0xFFu