]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
options: Allow duid to take a value
authorRoy Marples <roy@marples.name>
Wed, 25 Nov 2020 14:19:55 +0000 (14:19 +0000)
committerRoy Marples <roy@marples.name>
Wed, 25 Nov 2020 14:19:55 +0000 (14:19 +0000)
If a value is given, it overrides /var/db/dhcpcd/duid.

src/dhcpcd.8.in
src/dhcpcd.c
src/dhcpcd.conf.5.in
src/if-options.c

index 8c89b209aabc905177d8944ad9526a36b1943982..7533f30baafd549bfdc24b4a492e2cef20f9d187 100644 (file)
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 20, 2020
+.Dd November 25, 2020
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -264,18 +264,29 @@ Use this
 .Ar script
 instead of the default
 .Pa @SCRIPT@ .
-.It Fl D , Fl Fl duid
+.It Fl D , Fl Fl duid Op Ar ll | lt | uuid | value
 Use a DHCP Unique Identifier.
 If a system UUID is available, that will be used to create a DUID-UUID,
 otheriwse if persistent storage is available then a DUID-LLT
 (link local address + time) is generated,
 otherwise DUID-LL is generated (link local address).
+The DUID type can be hinted as an optional parameter if the file
+.Pa @DBDIR@/duid
+does not exist.
+If not
+.Va ll ,
+.Va lt
+or
+.Va uuid
+then
+.Va value
+will be converted from 00:11:22:33 format.
 This, plus the IAID will be used as the
 .Fl I , Fl Fl clientid .
 The DUID generated will be held in
 .Pa @DBDIR@/duid
 and should not be copied to other hosts.
-This file also takes precedence over the above rules.
+This file also takes precedence over the above rules except for setting a value.
 .It Fl d , Fl Fl debug
 Echo debug messages to the stderr and syslog.
 .It Fl E , Fl Fl lastlease
index 71575d1d1912c951bfdb0a3a1d0d0a8cfa02665a..7727a48e6e60d3664dea960513011e28bcb68ad1 100644 (file)
@@ -841,13 +841,17 @@ dhcpcd_initduid(struct dhcpcd_ctx *ctx, struct interface *ifp)
 {
        char buf[DUID_LEN * 3];
 
-       if (ctx->duid != NULL)
+       if (ctx->duid != NULL) {
+               if (ifp == NULL)
+                       goto log;
                return;
+       }
 
        duid_init(ctx, ifp);
        if (ctx->duid == NULL)
                return;
 
+log:
        loginfox("DUID %s",
            hwaddr_ntoa(ctx->duid, ctx->duid_len, buf, sizeof(buf)));
 }
index 1e7a8631a67d9aecb4abd8d06a8b1ee155e5053e..2afb23c0b140954d10f5b24b3ceb44b2d4d2bd6e 100644 (file)
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 25, 2020
+.Dd November 25, 2020
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -211,7 +211,7 @@ is an empty string then
 sends a default
 .Ar clientid
 of the hardware family and the hardware address.
-.It Ic duid Op ll | lt | uuid
+.It Ic duid Op ll | lt | uuid | value
 Use a DHCP Unique Identifier.
 If a system UUID is available, that will be used to create a DUID-UUID,
 otheriwse if persistent storage is available then a DUID-LLT
@@ -220,12 +220,20 @@ otherwise DUID-LL is generated (link local address).
 The DUID type can be hinted as an optional parameter if the file
 .Pa @DBDIR@/duid
 does not exist.
+If not
+.Va ll ,
+.Va lt
+or
+.Va uuid
+then
+.Va value
+will be converted from 00:11:22:33 format.
 This, plus the IAID will be used as the
 .Ic clientid .
 The DUID generated will be held in
 .Pa @DBDIR@/duid
 and should not be copied to other hosts.
-This file also takes precedence over the above rules.
+This file also takes precedence over the above rules except for setting a value.
 .It Ic iaid Ar iaid
 Set the Interface Association Identifier to
 .Ar iaid .
index d15034dde15b8b1bfb35cf4201aaa5b7370c74a0..509db378d5b9063aec3003583adca0219a64a4b5 100644 (file)
@@ -1002,8 +1002,16 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                else if (strcmp(arg, "uuid") == 0)
                        ctx->duid_type = DUID_UUID;
                else {
-                       logwarnx("%s: invalid duid type", arg);
-                       ctx->duid_type = DUID_DEFAULT;
+                       dl = hwaddr_aton(NULL, arg);
+                       if (dl != 0) {
+                               no = realloc(ctx->duid, dl);
+                               if (no == NULL)
+                                       logerrx(__func__);
+                               else {
+                                       ctx->duid = no;
+                                       ctx->duid_len = hwaddr_aton(no, arg);
+                               }
+                       }
                }
                break;
        case 'E':