1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include "sd-netlink.h"
8 #include "conf-parser.h"
9 #include "ethtool-util.h"
11 #include "net-condition.h"
12 #include "netif-naming-scheme.h"
14 typedef struct LinkConfigContext LinkConfigContext
;
15 typedef struct LinkConfig LinkConfig
;
17 typedef enum MACAddressPolicy
{
18 MAC_ADDRESS_POLICY_PERSISTENT
,
19 MAC_ADDRESS_POLICY_RANDOM
,
20 MAC_ADDRESS_POLICY_NONE
,
21 _MAC_ADDRESS_POLICY_MAX
,
22 _MAC_ADDRESS_POLICY_INVALID
= -EINVAL
,
32 sd_device_action_t action
;
37 struct hw_addr_data hw_addr
;
38 struct hw_addr_data permanent_hw_addr
;
39 unsigned name_assign_type
;
40 unsigned addr_assign_type
;
47 LIST_HEAD(Condition
, conditions
);
50 struct hw_addr_data hw_addr
;
51 MACAddressPolicy mac_address_policy
;
52 NamePolicy
*name_policy
;
53 NamePolicy
*alternative_names_policy
;
55 char **alternative_names
;
61 uint32_t gso_max_segments
;
66 uint32_t advertise
[N_ADVERTISE
];
68 char *wol_password_file
;
69 uint8_t *wol_password
;
71 int features
[_NET_DEV_FEAT_MAX
];
72 netdev_channels channels
;
73 netdev_ring_param ring
;
76 int autoneg_flow_control
;
77 netdev_coalesce_param coalesce
;
79 LIST_FIELDS(LinkConfig
, configs
);
82 int link_config_ctx_new(LinkConfigContext
**ret
);
83 LinkConfigContext
* link_config_ctx_free(LinkConfigContext
*ctx
);
84 DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext
*, link_config_ctx_free
);
86 int link_load_one(LinkConfigContext
*ctx
, const char *filename
);
87 int link_config_load(LinkConfigContext
*ctx
);
88 bool link_config_should_reload(LinkConfigContext
*ctx
);
90 int link_new(LinkConfigContext
*ctx
, sd_netlink
**rtnl
, sd_device
*device
, Link
**ret
);
91 Link
*link_free(Link
*link
);
92 DEFINE_TRIVIAL_CLEANUP_FUNC(Link
*, link_free
);
94 int link_get_config(LinkConfigContext
*ctx
, Link
*link
);
95 int link_apply_config(LinkConfigContext
*ctx
, sd_netlink
**rtnl
, Link
*link
);
97 const char *mac_address_policy_to_string(MACAddressPolicy p
) _const_
;
98 MACAddressPolicy
mac_address_policy_from_string(const char *p
) _pure_
;
100 /* gperf lookup function */
101 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
103 CONFIG_PARSER_PROTOTYPE(config_parse_ifalias
);
104 CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues
);
105 CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen
);
106 CONFIG_PARSER_PROTOTYPE(config_parse_wol_password
);
107 CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy
);
108 CONFIG_PARSER_PROTOTYPE(config_parse_name_policy
);
109 CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy
);