1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

udev: move config_parse_ifalias()

This commit is contained in:
Yu Watanabe 2020-10-28 23:55:19 +09:00
parent 796aa313b3
commit fc27088ae7
4 changed files with 44 additions and 43 deletions

View File

@ -24,7 +24,6 @@
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
#include "util.h"
const char *net_get_name_persistent(sd_device *device) {
@ -486,47 +485,6 @@ int config_parse_match_property(
}
}
int config_parse_ifalias(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
char **s = data;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (!isempty(rvalue)) {
*s = mfree(*s);
return 0;
}
if (!ascii_is_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Interface alias is not ASCII clean, ignoring assignment: %s", rvalue);
return 0;
}
if (strlen(rvalue) >= IFALIASZ) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Interface alias is too long, ignoring assignment: %s", rvalue);
return 0;
}
if (free_and_strdup(s, rvalue) < 0)
return log_oom();
return 0;
}
int config_parse_hwaddr(const char *unit,
const char *filename,
unsigned line,

View File

@ -39,7 +39,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_hwaddrs);
CONFIG_PARSER_PROTOTYPE(config_parse_match_strv);
CONFIG_PARSER_PROTOTYPE(config_parse_match_ifnames);
CONFIG_PARSER_PROTOTYPE(config_parse_match_property);
CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
int net_get_unique_predictable_data(sd_device *device, bool use_sysname, uint64_t *result);
const char *net_get_name_persistent(sd_device *device);

View File

@ -30,6 +30,7 @@
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
struct link_config_ctx {
LIST_HEAD(link_config, links);
@ -661,6 +662,48 @@ int link_get_driver(link_config_ctx *ctx, sd_device *device, char **ret) {
return 0;
}
int config_parse_ifalias(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
char **s = data;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (!isempty(rvalue)) {
*s = mfree(*s);
return 0;
}
if (!ascii_is_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Interface alias is not ASCII clean, ignoring assignment: %s", rvalue);
return 0;
}
if (strlen(rvalue) >= IFALIASZ) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Interface alias is too long, ignoring assignment: %s", rvalue);
return 0;
}
if (free_and_strdup(s, rvalue) < 0)
return log_oom();
return 0;
}
static const char* const mac_address_policy_table[_MAC_ADDRESS_POLICY_MAX] = {
[MAC_ADDRESS_POLICY_PERSISTENT] = "persistent",
[MAC_ADDRESS_POLICY_RANDOM] = "random",

View File

@ -93,6 +93,7 @@ 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_ifalias);
CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy);