]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
0ef6f454 LP |
2 | #pragma once |
3 | ||
e5eadf53 | 4 | #include "sd-device.h" |
751dcd8d | 5 | #include "sd-netlink.h" |
07630cea | 6 | |
134e56dc | 7 | #include "condition.h" |
538f15cf | 8 | #include "conf-parser.h" |
0f30bf58 | 9 | #include "cpu-set-util.h" |
07630cea | 10 | #include "ethtool-util.h" |
bd29dfef | 11 | #include "hashmap.h" |
af6f0d42 | 12 | #include "list.h" |
5722fb89 | 13 | #include "net-condition.h" |
ff516b43 | 14 | #include "netif-naming-scheme.h" |
af6f0d42 | 15 | |
afca7ac1 | 16 | typedef struct LinkConfigContext LinkConfigContext; |
ce01c07f | 17 | typedef struct LinkConfig LinkConfig; |
af6f0d42 | 18 | |
54ed9f88 ZJS |
19 | typedef enum MACAddressPolicy { |
20 | MAC_ADDRESS_POLICY_PERSISTENT, | |
21 | MAC_ADDRESS_POLICY_RANDOM, | |
22 | MAC_ADDRESS_POLICY_NONE, | |
23 | _MAC_ADDRESS_POLICY_MAX, | |
2d93c20e | 24 | _MAC_ADDRESS_POLICY_INVALID = -EINVAL, |
54ed9f88 | 25 | } MACAddressPolicy; |
5fde13d7 | 26 | |
613701a4 YW |
27 | typedef struct Link { |
28 | int ifindex; | |
29 | const char *ifname; | |
30 | const char *new_name; | |
9094ae52 | 31 | char **altnames; |
613701a4 YW |
32 | |
33 | LinkConfig *config; | |
34 | sd_device *device; | |
046286e8 | 35 | sd_device *device_db_clone; |
613701a4 YW |
36 | sd_device_action_t action; |
37 | ||
65022cd7 | 38 | char *kind; |
2b5b25f1 | 39 | const char *driver; |
613701a4 YW |
40 | uint16_t iftype; |
41 | uint32_t flags; | |
42 | struct hw_addr_data hw_addr; | |
43 | struct hw_addr_data permanent_hw_addr; | |
44 | unsigned name_assign_type; | |
45 | unsigned addr_assign_type; | |
46 | } Link; | |
47 | ||
ce01c07f | 48 | struct LinkConfig { |
af6f0d42 | 49 | char *filename; |
a2640646 | 50 | char **dropins; |
af6f0d42 | 51 | |
5722fb89 | 52 | NetMatch match; |
1beabe08 | 53 | LIST_HEAD(Condition, conditions); |
af6f0d42 TG |
54 | |
55 | char *description; | |
046286e8 YW |
56 | char **properties; |
57 | char **import_properties; | |
58 | char **unset_properties; | |
9e2b7763 | 59 | struct hw_addr_data hw_addr; |
54ed9f88 | 60 | MACAddressPolicy mac_address_policy; |
5fde13d7 | 61 | NamePolicy *name_policy; |
ef1d2c07 | 62 | NamePolicy *alternative_names_policy; |
43b3a5ef | 63 | char *name; |
a5053a15 | 64 | char **alternative_names; |
d2df0d0e | 65 | char *alias; |
face9fcc YW |
66 | uint32_t txqueues; |
67 | uint32_t rxqueues; | |
ef4a91a7 | 68 | uint32_t txqueuelen; |
4e964aa0 | 69 | uint32_t mtu; |
1e270127 SS |
70 | uint32_t gso_max_segments; |
71 | size_t gso_max_size; | |
50299121 | 72 | uint64_t speed; |
5fde13d7 | 73 | Duplex duplex; |
a39f92d3 | 74 | int autonegotiation; |
5c2316c6 | 75 | uint32_t advertise[N_ADVERTISE]; |
c50404ae | 76 | uint32_t wol; |
d3867133 YW |
77 | char *wol_password_file; |
78 | uint8_t *wol_password; | |
593022fa | 79 | NetDevPort port; |
cc2ff878 | 80 | int features[_NET_DEV_FEAT_MAX]; |
5f945202 | 81 | netdev_channels channels; |
224ded67 | 82 | netdev_ring_param ring; |
a34811e4 YW |
83 | int rx_flow_control; |
84 | int tx_flow_control; | |
85 | int autoneg_flow_control; | |
6c35ea5e | 86 | netdev_coalesce_param coalesce; |
18f84f8a | 87 | uint8_t mdi; |
0f30bf58 | 88 | CPUSet *rps_cpu_mask; |
af6f0d42 | 89 | |
41ce9d76 | 90 | uint32_t sr_iov_num_vfs; |
bd29dfef YW |
91 | OrderedHashmap *sr_iov_by_section; |
92 | ||
418c02c3 | 93 | LIST_FIELDS(LinkConfig, configs); |
af6f0d42 TG |
94 | }; |
95 | ||
afca7ac1 YW |
96 | int link_config_ctx_new(LinkConfigContext **ret); |
97 | LinkConfigContext* link_config_ctx_free(LinkConfigContext *ctx); | |
98 | DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext*, link_config_ctx_free); | |
af6f0d42 | 99 | |
afca7ac1 YW |
100 | int link_load_one(LinkConfigContext *ctx, const char *filename); |
101 | int link_config_load(LinkConfigContext *ctx); | |
102 | bool link_config_should_reload(LinkConfigContext *ctx); | |
af6f0d42 | 103 | |
046286e8 | 104 | int link_new(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, sd_device *device_db_clone, Link **ret); |
613701a4 YW |
105 | Link *link_free(Link *link); |
106 | DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free); | |
107 | ||
108 | int link_get_config(LinkConfigContext *ctx, Link *link); | |
3e00171d | 109 | int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link, bool test); |
847a8a5f | 110 | |
54ed9f88 ZJS |
111 | const char *mac_address_policy_to_string(MACAddressPolicy p) _const_; |
112 | MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_; | |
5fde13d7 | 113 | |
af6f0d42 | 114 | /* gperf lookup function */ |
c9f7b4d3 | 115 | const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length); |
5fde13d7 | 116 | |
046286e8 YW |
117 | CONFIG_PARSER_PROTOTYPE(config_parse_udev_property); |
118 | CONFIG_PARSER_PROTOTYPE(config_parse_udev_property_name); | |
fc27088a | 119 | CONFIG_PARSER_PROTOTYPE(config_parse_ifalias); |
face9fcc | 120 | CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues); |
ef4a91a7 | 121 | CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen); |
d3867133 | 122 | CONFIG_PARSER_PROTOTYPE(config_parse_wol_password); |
54ed9f88 | 123 | CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy); |
538f15cf | 124 | CONFIG_PARSER_PROTOTYPE(config_parse_name_policy); |
ef1d2c07 | 125 | CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy); |
0f30bf58 | 126 | CONFIG_PARSER_PROTOTYPE(config_parse_rps_cpu_mask); |