rpcd-mod-luci: handle DHCPv6 leases in dnsmasq lease file
authore9hack <e9hack@gmail.com>
Sun, 3 Nov 2019 08:05:37 +0000 (09:05 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sun, 3 Nov 2019 16:56:58 +0000 (17:56 +0100)
For DHCPv6, the second entry of a lease is the IAID. The parsing code
expects a MAC instead of a IAID.

Reported-by: Hartmut Birr <e9hack@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libs/rpcd-mod-luci/src/luci.c

index 245ca636bede0eb55db059819d1381ad17a7bafd..91f6798d79620dfd6f7e1be63d9f6f97ded8b1d5 100644 (file)
@@ -435,9 +435,6 @@ lease_next(void)
 
                        ea = ether_aton(p);
 
-                       if (!ea)
-                               continue;
-
                        p = strtok(NULL, " \t\n");
 
                        if (p && inet_pton(AF_INET6, p, &e.addr.in6))
@@ -447,6 +444,9 @@ lease_next(void)
                        else
                                continue;
 
+                       if (!ea && e.af != AF_INET6)
+                               continue;
+
                        e.hostname = strtok(NULL, " \t\n");
                        e.duid     = strtok(NULL, " \t\n");
 
@@ -459,7 +459,11 @@ lease_next(void)
                        if (!strcmp(e.duid, "*"))
                                e.duid = NULL;
 
-                       e.mac = *ea;
+                       if (!ea && e.duid)
+                               ea = duid2ea(e.duid);
+
+                       if (ea)
+                               e.mac = *ea;
 
                        return &e;
                }