mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
udev/link-config: rename MACPolicy to MACAddressPolicy
Things are clearer if the same name is used everywhere, and we don't gain much by saving a few bytes.
This commit is contained in:
parent
b1f13b0e75
commit
54ed9f88dc
@ -70,7 +70,7 @@ int main(int argc, char **argv) {
|
||||
test_table(kill_who, KILL_WHO);
|
||||
test_table(locale_variable, VARIABLE_LC);
|
||||
test_table(log_target, LOG_TARGET);
|
||||
test_table(mac_policy, MACPOLICY);
|
||||
test_table(mac_address_policy, MAC_ADDRESS_POLICY);
|
||||
test_table(manager_state, MANAGER_STATE);
|
||||
test_table(manager_timestamp, MANAGER_TIMESTAMP);
|
||||
test_table(mount_exec_command, MOUNT_EXEC_COMMAND);
|
||||
|
@ -19,36 +19,36 @@ struct ConfigPerfItem;
|
||||
%struct-type
|
||||
%includes
|
||||
%%
|
||||
Match.MACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match_mac)
|
||||
Match.OriginalName, config_parse_ifnames, 0, offsetof(link_config, match_name)
|
||||
Match.Path, config_parse_strv, 0, offsetof(link_config, match_path)
|
||||
Match.Driver, config_parse_strv, 0, offsetof(link_config, match_driver)
|
||||
Match.Type, config_parse_strv, 0, offsetof(link_config, match_type)
|
||||
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(link_config, conditions)
|
||||
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(link_config, conditions)
|
||||
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(link_config, conditions)
|
||||
Match.KernelVersion, config_parse_net_condition, CONDITION_KERNEL_VERSION, offsetof(link_config, conditions)
|
||||
Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(link_config, conditions)
|
||||
Link.Description, config_parse_string, 0, offsetof(link_config, description)
|
||||
Link.MACAddressPolicy, config_parse_mac_policy, 0, offsetof(link_config, mac_policy)
|
||||
Link.MACAddress, config_parse_hwaddr, 0, offsetof(link_config, mac)
|
||||
Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy)
|
||||
Link.Name, config_parse_ifname, 0, offsetof(link_config, name)
|
||||
Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias)
|
||||
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu)
|
||||
Link.BitsPerSecond, config_parse_si_size, 0, offsetof(link_config, speed)
|
||||
Link.Duplex, config_parse_duplex, 0, offsetof(link_config, duplex)
|
||||
Link.AutoNegotiation, config_parse_tristate, 0, offsetof(link_config, autonegotiation)
|
||||
Link.WakeOnLan, config_parse_wol, 0, offsetof(link_config, wol)
|
||||
Link.Port, config_parse_port, 0, offsetof(link_config, port)
|
||||
Link.GenericSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GSO])
|
||||
Link.TCPSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO])
|
||||
Link.TCP6SegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO6])
|
||||
Link.UDPSegmentationOffload, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
Link.GenericReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GRO])
|
||||
Link.LargeReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_LRO])
|
||||
Link.RxChannels, config_parse_channel, 0, 0
|
||||
Link.TxChannels, config_parse_channel, 0, 0
|
||||
Link.OtherChannels, config_parse_channel, 0, 0
|
||||
Link.CombinedChannels, config_parse_channel, 0, 0
|
||||
Link.Advertise, config_parse_advertise, 0, 0
|
||||
Match.MACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match_mac)
|
||||
Match.OriginalName, config_parse_ifnames, 0, offsetof(link_config, match_name)
|
||||
Match.Path, config_parse_strv, 0, offsetof(link_config, match_path)
|
||||
Match.Driver, config_parse_strv, 0, offsetof(link_config, match_driver)
|
||||
Match.Type, config_parse_strv, 0, offsetof(link_config, match_type)
|
||||
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(link_config, conditions)
|
||||
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(link_config, conditions)
|
||||
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(link_config, conditions)
|
||||
Match.KernelVersion, config_parse_net_condition, CONDITION_KERNEL_VERSION, offsetof(link_config, conditions)
|
||||
Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(link_config, conditions)
|
||||
Link.Description, config_parse_string, 0, offsetof(link_config, description)
|
||||
Link.MACAddressPolicy, config_parse_mac_address_policy, 0, offsetof(link_config, mac_address_policy)
|
||||
Link.MACAddress, config_parse_hwaddr, 0, offsetof(link_config, mac)
|
||||
Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy)
|
||||
Link.Name, config_parse_ifname, 0, offsetof(link_config, name)
|
||||
Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias)
|
||||
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu)
|
||||
Link.BitsPerSecond, config_parse_si_size, 0, offsetof(link_config, speed)
|
||||
Link.Duplex, config_parse_duplex, 0, offsetof(link_config, duplex)
|
||||
Link.AutoNegotiation, config_parse_tristate, 0, offsetof(link_config, autonegotiation)
|
||||
Link.WakeOnLan, config_parse_wol, 0, offsetof(link_config, wol)
|
||||
Link.Port, config_parse_port, 0, offsetof(link_config, port)
|
||||
Link.GenericSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GSO])
|
||||
Link.TCPSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO])
|
||||
Link.TCP6SegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO6])
|
||||
Link.UDPSegmentationOffload, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
Link.GenericReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GRO])
|
||||
Link.LargeReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_LRO])
|
||||
Link.RxChannels, config_parse_channel, 0, 0
|
||||
Link.TxChannels, config_parse_channel, 0, 0
|
||||
Link.OtherChannels, config_parse_channel, 0, 0
|
||||
Link.CombinedChannels, config_parse_channel, 0, 0
|
||||
Link.Advertise, config_parse_advertise, 0, 0
|
||||
|
@ -139,7 +139,7 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
|
||||
|
||||
*link = (link_config) {
|
||||
.filename = TAKE_PTR(name),
|
||||
.mac_policy = _MACPOLICY_INVALID,
|
||||
.mac_address_policy = _MAC_ADDRESS_POLICY_INVALID,
|
||||
.wol = _WOL_INVALID,
|
||||
.duplex = _DUP_INVALID,
|
||||
.port = _NET_DEV_PORT_INVALID,
|
||||
@ -280,12 +280,12 @@ int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int get_mac(sd_device *device, MACPolicy policy, struct ether_addr *mac) {
|
||||
static int get_mac(sd_device *device, MACAddressPolicy policy, struct ether_addr *mac) {
|
||||
unsigned addr_type;
|
||||
bool want_random = policy == MACPOLICY_RANDOM;
|
||||
bool want_random = policy == MAC_ADDRESS_POLICY_RANDOM;
|
||||
int r;
|
||||
|
||||
assert(IN_SET(policy, MACPOLICY_RANDOM, MACPOLICY_PERSISTENT));
|
||||
assert(IN_SET(policy, MAC_ADDRESS_POLICY_RANDOM, MAC_ADDRESS_POLICY_PERSISTENT));
|
||||
|
||||
r = link_unsigned_attribute(device, "addr_assign_type", &addr_type);
|
||||
if (r < 0)
|
||||
@ -304,7 +304,7 @@ static int get_mac(sd_device *device, MACPolicy policy, struct ether_addr *mac)
|
||||
|
||||
if (want_random == (addr_type == NET_ADDR_RANDOM))
|
||||
return log_device_debug(device, "MAC on the device already matches policy *%s*",
|
||||
mac_policy_to_string(policy));
|
||||
mac_address_policy_to_string(policy));
|
||||
|
||||
if (want_random) {
|
||||
log_device_debug(device, "Using random bytes to generate MAC");
|
||||
@ -444,8 +444,8 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||
log_device_debug(device, "Policies didn't yield a name and Name= is not given, not renaming.");
|
||||
no_rename:
|
||||
|
||||
if (IN_SET(config->mac_policy, MACPOLICY_PERSISTENT, MACPOLICY_RANDOM)) {
|
||||
if (get_mac(device, config->mac_policy, &generated_mac) > 0)
|
||||
if (IN_SET(config->mac_address_policy, MAC_ADDRESS_POLICY_PERSISTENT, MAC_ADDRESS_POLICY_RANDOM)) {
|
||||
if (get_mac(device, config->mac_address_policy, &generated_mac) > 0)
|
||||
mac = &generated_mac;
|
||||
} else
|
||||
mac = config->mac;
|
||||
@ -476,14 +476,14 @@ int link_get_driver(link_config_ctx *ctx, sd_device *device, char **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* const mac_policy_table[_MACPOLICY_MAX] = {
|
||||
[MACPOLICY_PERSISTENT] = "persistent",
|
||||
[MACPOLICY_RANDOM] = "random",
|
||||
[MACPOLICY_NONE] = "none",
|
||||
static const char* const mac_address_policy_table[_MAC_ADDRESS_POLICY_MAX] = {
|
||||
[MAC_ADDRESS_POLICY_PERSISTENT] = "persistent",
|
||||
[MAC_ADDRESS_POLICY_RANDOM] = "random",
|
||||
[MAC_ADDRESS_POLICY_NONE] = "none",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(mac_policy, MACPolicy);
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_mac_policy, mac_policy, MACPolicy,
|
||||
DEFINE_STRING_TABLE_LOOKUP(mac_address_policy, MACAddressPolicy);
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_mac_address_policy, mac_address_policy, MACAddressPolicy,
|
||||
"Failed to parse MAC address policy");
|
||||
|
||||
static const char* const name_policy_table[_NAMEPOLICY_MAX] = {
|
||||
|
@ -12,13 +12,13 @@
|
||||
typedef struct link_config_ctx link_config_ctx;
|
||||
typedef struct link_config link_config;
|
||||
|
||||
typedef enum MACPolicy {
|
||||
MACPOLICY_PERSISTENT,
|
||||
MACPOLICY_RANDOM,
|
||||
MACPOLICY_NONE,
|
||||
_MACPOLICY_MAX,
|
||||
_MACPOLICY_INVALID = -1
|
||||
} MACPolicy;
|
||||
typedef enum MACAddressPolicy {
|
||||
MAC_ADDRESS_POLICY_PERSISTENT,
|
||||
MAC_ADDRESS_POLICY_RANDOM,
|
||||
MAC_ADDRESS_POLICY_NONE,
|
||||
_MAC_ADDRESS_POLICY_MAX,
|
||||
_MAC_ADDRESS_POLICY_INVALID = -1
|
||||
} MACAddressPolicy;
|
||||
|
||||
typedef enum NamePolicy {
|
||||
NAMEPOLICY_KERNEL,
|
||||
@ -44,7 +44,7 @@ struct link_config {
|
||||
|
||||
char *description;
|
||||
struct ether_addr *mac;
|
||||
MACPolicy mac_policy;
|
||||
MACAddressPolicy mac_address_policy;
|
||||
NamePolicy *name_policy;
|
||||
char *name;
|
||||
char *alias;
|
||||
@ -76,11 +76,11 @@ int link_get_driver(link_config_ctx *ctx, sd_device *device, char **ret);
|
||||
const char *name_policy_to_string(NamePolicy p) _const_;
|
||||
NamePolicy name_policy_from_string(const char *p) _pure_;
|
||||
|
||||
const char *mac_policy_to_string(MACPolicy p) _const_;
|
||||
MACPolicy mac_policy_from_string(const char *p) _pure_;
|
||||
const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
|
||||
MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
|
||||
|
||||
/* gperf lookup function */
|
||||
const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_mac_policy);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
|
||||
|
Loading…
Reference in New Issue
Block a user