]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: DHCP4 client ID save in state file
authorSusant Sahani <ssahani@vmware.com>
Mon, 8 Jun 2020 04:39:06 +0000 (06:39 +0200)
committerSusant Sahani <ssahani@vmware.com>
Mon, 8 Jun 2020 05:08:04 +0000 (07:08 +0200)
src/network/networkd-link.c

index 805aff3ab1d5dd3181db9b27c8daa43c53eb7869..eeb5f5e16a135ca676e256cc13e4d62e57623546 100644 (file)
@@ -4354,6 +4354,8 @@ int link_save(Link *link) {
         if (link->dhcp_lease) {
                 struct in_addr address;
                 const char *tz = NULL;
+                size_t client_id_len;
+                const void *client_id;
 
                 assert(link->network);
 
@@ -4368,6 +4370,15 @@ int link_save(Link *link) {
                         fputc('\n', f);
                 }
 
+                r = sd_dhcp_lease_get_client_id(link->dhcp_lease, &client_id, &client_id_len);
+                if (r >= 0) {
+                        _cleanup_free_ char *id = NULL;
+
+                        r = sd_dhcp_client_id_to_string(client_id, client_id_len, &id);
+                        if (r >= 0)
+                                fprintf(f, "DHCP4_CLIENT_ID=%s\n", id);
+                }
+
                 r = dhcp_lease_save(link->dhcp_lease, link->lease_file);
                 if (r < 0)
                         goto fail;