diff options
author | Ronan Pigott <ronan@rjp.ie> | 2024-01-16 08:04:41 +0100 |
---|---|---|
committer | Ronan Pigott <ronan@rjp.ie> | 2024-10-21 18:10:19 +0200 |
commit | 3fd6708cde0fa4283e2335aca288a40a49406f3c (patch) | |
tree | 2f5f397a9b3f99e326044f0696ccd2d8c8589fac /src/libsystemd-network/sd-dhcp-lease.c | |
parent | network: Add serialization for DoT resolvers (diff) | |
download | systemd-3fd6708cde0fa4283e2335aca288a40a49406f3c.tar.xz systemd-3fd6708cde0fa4283e2335aca288a40a49406f3c.zip |
network: Serialize DNR servers
Implement serialization/deserialization for DNR servers. This re-uses
the string format in place for user configuration of DoT servers, and as
a consequence non-DoT servers are discarded when recording the link
configuration, for correctness.
This also enables sd-resolved to use these servers as it would other DNS
servers.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-lease.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-lease.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index 8c46f8f770..1c0cd6829b 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -1290,6 +1290,14 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) { fputc('\n', f); } + sd_dns_resolver *resolvers; + r = sd_dhcp_lease_get_dnr(lease, &resolvers); + if (r > 0) { + fputs("DNR=", f); + serialize_dnr(f, resolvers, r, NULL); + fputc('\n', f); + } + r = sd_dhcp_lease_get_ntp(lease, &addresses); if (r > 0) { fputs("NTP=", f); @@ -1398,6 +1406,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { *next_server = NULL, *broadcast = NULL, *dns = NULL, + *dnr = NULL, *ntp = NULL, *sip = NULL, *pop3 = NULL, @@ -1435,6 +1444,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { "NEXT_SERVER", &next_server, "BROADCAST", &broadcast, "DNS", &dns, + "DNR", &dnr, "NTP", &ntp, "SIP", &sip, "POP3", &pop3, @@ -1537,6 +1547,13 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { lease->servers[SD_DHCP_LEASE_DNS].size = r; } + if (dnr) { + r = deserialize_dnr(&lease->dnr, dnr); + if (r < 0) + log_debug_errno(r, "Failed to deserialize DNR servers %s, ignoring: %m", dnr); + lease->n_dnr = r; + } + if (ntp) { r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_NTP].addr, ntp); if (r < 0) |