1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include "sd-netlink.h"
8 #include "conf-parser.h"
9 #include "cpu-set-util.h"
10 #include "ethtool-util.h"
13 #include "net-condition.h"
14 #include "netif-naming-scheme.h"
16 typedef struct LinkConfigContext LinkConfigContext
;
17 typedef struct LinkConfig LinkConfig
;
19 typedef enum MACAddressPolicy
{
20 MAC_ADDRESS_POLICY_PERSISTENT
,
21 MAC_ADDRESS_POLICY_RANDOM
,
22 MAC_ADDRESS_POLICY_NONE
,
23 _MAC_ADDRESS_POLICY_MAX
,
24 _MAC_ADDRESS_POLICY_INVALID
= -EINVAL
,
35 sd_device
*device_db_clone
;
36 sd_device_action_t action
;
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
;
53 LIST_HEAD(Condition
, conditions
);
57 char **import_properties
;
58 char **unset_properties
;
59 struct hw_addr_data hw_addr
;
60 MACAddressPolicy mac_address_policy
;
61 NamePolicy
*name_policy
;
62 NamePolicy
*alternative_names_policy
;
64 char **alternative_names
;
70 uint32_t gso_max_segments
;
75 uint32_t advertise
[N_ADVERTISE
];
77 char *wol_password_file
;
78 uint8_t *wol_password
;
80 int features
[_NET_DEV_FEAT_MAX
];
81 netdev_channels channels
;
82 netdev_ring_param ring
;
85 int autoneg_flow_control
;
86 netdev_coalesce_param coalesce
;
90 uint32_t sr_iov_num_vfs
;
91 OrderedHashmap
*sr_iov_by_section
;
93 LIST_FIELDS(LinkConfig
, configs
);
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
);
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
);
104 int link_new(LinkConfigContext
*ctx
, sd_netlink
**rtnl
, sd_device
*device
, sd_device
*device_db_clone
, Link
**ret
);
105 Link
*link_free(Link
*link
);
106 DEFINE_TRIVIAL_CLEANUP_FUNC(Link
*, link_free
);
108 int link_get_config(LinkConfigContext
*ctx
, Link
*link
);
109 int link_apply_config(LinkConfigContext
*ctx
, sd_netlink
**rtnl
, Link
*link
, bool test
);
111 const char *mac_address_policy_to_string(MACAddressPolicy p
) _const_
;
112 MACAddressPolicy
mac_address_policy_from_string(const char *p
) _pure_
;
114 /* gperf lookup function */
115 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
117 CONFIG_PARSER_PROTOTYPE(config_parse_udev_property
);
118 CONFIG_PARSER_PROTOTYPE(config_parse_udev_property_name
);
119 CONFIG_PARSER_PROTOTYPE(config_parse_ifalias
);
120 CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues
);
121 CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen
);
122 CONFIG_PARSER_PROTOTYPE(config_parse_wol_password
);
123 CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy
);
124 CONFIG_PARSER_PROTOTYPE(config_parse_name_policy
);
125 CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy
);
126 CONFIG_PARSER_PROTOTYPE(config_parse_rps_cpu_mask
);