1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include "sd-netlink.h"
8 #include "conf-parser.h"
9 #include "ethtool-util.h"
12 #include "net-condition.h"
13 #include "netif-naming-scheme.h"
15 typedef struct LinkConfigContext LinkConfigContext
;
16 typedef struct LinkConfig LinkConfig
;
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
,
33 sd_device_action_t action
;
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
;
50 LIST_HEAD(Condition
, conditions
);
53 struct hw_addr_data hw_addr
;
54 MACAddressPolicy mac_address_policy
;
55 NamePolicy
*name_policy
;
56 NamePolicy
*alternative_names_policy
;
58 char **alternative_names
;
64 uint32_t gso_max_segments
;
69 uint32_t advertise
[N_ADVERTISE
];
71 char *wol_password_file
;
72 uint8_t *wol_password
;
74 int features
[_NET_DEV_FEAT_MAX
];
75 netdev_channels channels
;
76 netdev_ring_param ring
;
79 int autoneg_flow_control
;
80 netdev_coalesce_param coalesce
;
83 uint32_t sr_iov_num_vfs
;
84 OrderedHashmap
*sr_iov_by_section
;
86 LIST_FIELDS(LinkConfig
, configs
);
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
);
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
);
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
);
101 int link_get_config(LinkConfigContext
*ctx
, Link
*link
);
102 int link_apply_config(LinkConfigContext
*ctx
, sd_netlink
**rtnl
, Link
*link
);
104 const char *mac_address_policy_to_string(MACAddressPolicy p
) _const_
;
105 MACAddressPolicy
mac_address_policy_from_string(const char *p
) _pure_
;
107 /* gperf lookup function */
108 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
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
);