1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

network/dhcp: make DUIDType= take an arbitrary integer

Closes #26745.
This commit is contained in:
Yu Watanabe 2023-08-22 14:32:07 +09:00
parent 2da796cabb
commit 80500bb5d4
3 changed files with 13 additions and 4 deletions

View File

@ -127,7 +127,7 @@
<ulink url="https://tools.ietf.org/html/rfc3315#section-9">RFC 3315</ulink> <ulink url="https://tools.ietf.org/html/rfc3315#section-9">RFC 3315</ulink>
for a description of all the options.</para> for a description of all the options.</para>
<para>The following values are understood: <para>This takes an integer in the range 0…65535, or one of the following string values:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><option>vendor</option></term> <term><option>vendor</option></term>

View File

@ -19,6 +19,7 @@ typedef enum DUIDType {
DUID_TYPE_UUID = 4, DUID_TYPE_UUID = 4,
_DUID_TYPE_MAX, _DUID_TYPE_MAX,
_DUID_TYPE_INVALID = -EINVAL, _DUID_TYPE_INVALID = -EINVAL,
_DUID_TYPE_FORCE_U16 = UINT16_MAX,
} DUIDType; } DUIDType;
/* RFC 3315 section 9.1: /* RFC 3315 section 9.1:

View File

@ -1154,11 +1154,19 @@ int config_parse_duid_type(
type = duid_type_from_string(type_string); type = duid_type_from_string(type_string);
if (type < 0) { if (type < 0) {
log_syntax(unit, LOG_WARNING, filename, line, type, uint16_t t;
r = safe_atou16(type_string, &t);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DUID type '%s', ignoring.", type_string); "Failed to parse DUID type '%s', ignoring.", type_string);
return 0; return 0;
} }
type = t;
assert(type == t); /* Check if type can store uint16_t. */
}
if (!isempty(p)) { if (!isempty(p)) {
usec_t u; usec_t u;