]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/dhcp: make DUIDType= take an arbitrary integer
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Aug 2023 05:32:07 +0000 (14:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Aug 2023 10:55:27 +0000 (19:55 +0900)
Closes #26745.

man/networkd.conf.xml
src/libsystemd-network/dhcp-identifier.h
src/network/networkd-dhcp-common.c

index bf597cac2ecb0e70ccb5d792e95d07e5fd77bd9a..f25083cc69ccd389cccd719cfe728041743d98cd 100644 (file)
         <ulink url="https://tools.ietf.org/html/rfc3315#section-9">RFC 3315</ulink>
         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>
           <varlistentry>
             <term><option>vendor</option></term>
index efb266ef804553914ff98150fe169e1136c6f34e..7b36f92e7fa33ec24f335a8416ba1472e61a892f 100644 (file)
@@ -19,6 +19,7 @@ typedef enum DUIDType {
         DUID_TYPE_UUID      = 4,
         _DUID_TYPE_MAX,
         _DUID_TYPE_INVALID  = -EINVAL,
+        _DUID_TYPE_FORCE_U16 = UINT16_MAX,
 } DUIDType;
 
 /* RFC 3315 section 9.1:
index 8bd20ea21cbb70b641bb78fcb25e47894b8261bd..5b5b251e61ed259c5622dffd778e4a411e0d05e0 100644 (file)
@@ -1154,9 +1154,17 @@ int config_parse_duid_type(
 
         type = duid_type_from_string(type_string);
         if (type < 0) {
-                log_syntax(unit, LOG_WARNING, filename, line, type,
-                           "Failed to parse DUID type '%s', ignoring.", type_string);
-                return 0;
+                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);
+                        return 0;
+                }
+
+                type = t;
+                assert(type == t); /* Check if type can store uint16_t. */
         }
 
         if (!isempty(p)) {