]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/net/link-config.h
Merge pull request #25168 from valentindavid/valentindavid/umount-move-recursive...
[thirdparty/systemd.git] / src / udev / net / link-config.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "sd-device.h"
5 #include "sd-netlink.h"
6
7 #include "condition.h"
8 #include "conf-parser.h"
9 #include "ethtool-util.h"
10 #include "hashmap.h"
11 #include "list.h"
12 #include "net-condition.h"
13 #include "netif-naming-scheme.h"
14
15 typedef struct LinkConfigContext LinkConfigContext;
16 typedef struct LinkConfig LinkConfig;
17
18 typedef enum MACAddressPolicy {
19 MAC_ADDRESS_POLICY_PERSISTENT,
20 MAC_ADDRESS_POLICY_RANDOM,
21 MAC_ADDRESS_POLICY_NONE,
22 _MAC_ADDRESS_POLICY_MAX,
23 _MAC_ADDRESS_POLICY_INVALID = -EINVAL,
24 } MACAddressPolicy;
25
26 typedef struct Link {
27 int ifindex;
28 const char *ifname;
29 const char *new_name;
30
31 LinkConfig *config;
32 sd_device *device;
33 sd_device_action_t action;
34
35 char *kind;
36 char *driver;
37 uint16_t iftype;
38 uint32_t flags;
39 struct hw_addr_data hw_addr;
40 struct hw_addr_data permanent_hw_addr;
41 unsigned name_assign_type;
42 unsigned addr_assign_type;
43 } Link;
44
45 struct LinkConfig {
46 char *filename;
47 char **dropins;
48
49 NetMatch match;
50 LIST_HEAD(Condition, conditions);
51
52 char *description;
53 struct hw_addr_data hw_addr;
54 MACAddressPolicy mac_address_policy;
55 NamePolicy *name_policy;
56 NamePolicy *alternative_names_policy;
57 char *name;
58 char **alternative_names;
59 char *alias;
60 uint32_t txqueues;
61 uint32_t rxqueues;
62 uint32_t txqueuelen;
63 uint32_t mtu;
64 uint32_t gso_max_segments;
65 size_t gso_max_size;
66 uint64_t speed;
67 Duplex duplex;
68 int autonegotiation;
69 uint32_t advertise[N_ADVERTISE];
70 uint32_t wol;
71 char *wol_password_file;
72 uint8_t *wol_password;
73 NetDevPort port;
74 int features[_NET_DEV_FEAT_MAX];
75 netdev_channels channels;
76 netdev_ring_param ring;
77 int rx_flow_control;
78 int tx_flow_control;
79 int autoneg_flow_control;
80 netdev_coalesce_param coalesce;
81 uint8_t mdi;
82
83 uint32_t sr_iov_num_vfs;
84 OrderedHashmap *sr_iov_by_section;
85
86 LIST_FIELDS(LinkConfig, configs);
87 };
88
89 int link_config_ctx_new(LinkConfigContext **ret);
90 LinkConfigContext* link_config_ctx_free(LinkConfigContext *ctx);
91 DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext*, link_config_ctx_free);
92
93 int link_load_one(LinkConfigContext *ctx, const char *filename);
94 int link_config_load(LinkConfigContext *ctx);
95 bool link_config_should_reload(LinkConfigContext *ctx);
96
97 int link_new(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, Link **ret);
98 Link *link_free(Link *link);
99 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
100
101 int link_get_config(LinkConfigContext *ctx, Link *link);
102 int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link);
103
104 const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
105 MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
106
107 /* gperf lookup function */
108 const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
109
110 CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
111 CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues);
112 CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen);
113 CONFIG_PARSER_PROTOTYPE(config_parse_wol_password);
114 CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
115 CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
116 CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy);