network: DHCP4 client ID save in state file

This commit is contained in:
Susant Sahani 2020-06-08 06:39:06 +02:00
parent 7887e58051
commit 5dfaf89b5b
1 changed files with 11 additions and 0 deletions

View 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;