diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-08-07 13:57:48 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-08-08 10:15:00 +0900 |
commit | 0cf7c3fd215229e106304ff59e20654237726d28 (patch) | |
tree | d2e6f276cfd0d15a645727944169bab242df1b53 /src/network/networkd-conf.c | |
parent | 7e90a499ab1d5648c9169b5991b117d36fc59fad (diff) | |
download | systemd-0cf7c3fd215229e106304ff59e20654237726d28.tar.gz |
network: accept additional time-value after ':' when DUIDType=link-layer-time
Diffstat (limited to 'src/network/networkd-conf.c')
-rw-r--r-- | src/network/networkd-conf.c | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/src/network/networkd-conf.c b/src/network/networkd-conf.c index 05bbc0b3e9..334ffc3c57 100644 --- a/src/network/networkd-conf.c +++ b/src/network/networkd-conf.c @@ -31,7 +31,74 @@ static const char* const duid_type_table[_DUID_TYPE_MAX] = { [DUID_TYPE_UUID] = "uuid", }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(duid_type, DUIDType); -DEFINE_CONFIG_PARSE_ENUM(config_parse_duid_type, duid_type, DUIDType, "Failed to parse DUID type"); + +int config_parse_duid_type( + 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) { + + _cleanup_free_ char *type_string = NULL; + const char *p = rvalue; + DUID *duid = data; + DUIDType type; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(duid); + + r = extract_first_word(&p, &type_string, ":", 0); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Invalid syntax, ignoring: %s", rvalue); + return 0; + } + if (r == 0) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Failed to extract DUID type from '%s', ignoring.", rvalue); + return 0; + } + + type = duid_type_from_string(type_string); + if (type < 0) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Failed to parse DUID type '%s', ignoring.", type_string); + return 0; + } + + if (!isempty(p)) { + usec_t u; + + if (type != DUID_TYPE_LLT) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Invalid syntax, ignoring: %s", rvalue); + return 0; + } + + r = parse_timestamp(p, &u); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse timestamp, ignoring: %s", p); + return 0; + } + + duid->llt_time = u; + } + + duid->type = type; + + return 0; +} int config_parse_duid_rawdata( const char *unit, |