networkd: merge DNS and NTP entries when exporting

In the state files, do not distinguish where the various entries came from
(static or DHCP), but include them all in the same list.
This commit is contained in:
Tom Gundersen
2014-07-23 23:54:51 +02:00
parent 36d054aae0
commit b0e39c8284
9 changed files with 56 additions and 156 deletions
+1 -6
View File
@@ -339,21 +339,16 @@ int net_parse_inaddr(const char *address, int *family, void *dst) {
return 0;
}
void serialize_in_addrs(FILE *f, const char *key, const struct in_addr *addresses, size_t size) {
void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size) {
unsigned i;
assert(f);
assert(key);
assert(addresses);
assert(size);
fprintf(f, "%s=", key);
for (i = 0; i < size; i++)
fprintf(f, "%s%s", inet_ntoa(addresses[i]),
(i < (size - 1)) ? " ": "");
fputs("\n", f);
}
int deserialize_in_addrs(struct in_addr **ret, const char *string) {
+1 -1
View File
@@ -67,7 +67,7 @@ int net_parse_inaddr(const char *address, int *family, void *dst);
int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]);
const char *net_get_name(struct udev_device *device);
void serialize_in_addrs(FILE *f, const char *key, const struct in_addr *addresses, size_t size);
void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size);
int deserialize_in_addrs(struct in_addr **addresses, const char *string);
int deserialize_in6_addrs(struct in6_addr **addresses, const char *string);
+6 -2
View File
@@ -629,13 +629,17 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
if (r >= 0)
fprintf(f, "MTU=%" PRIu16 "\n", mtu);
fputs("DNS=", f);
r = sd_dhcp_lease_get_dns(lease, &addresses);
if (r >= 0)
serialize_in_addrs(f, "DNS", addresses, r);
serialize_in_addrs(f, addresses, r);
fputs("\n", f);
fputs("NTP=", f);
r = sd_dhcp_lease_get_ntp(lease, &addresses);
if (r >= 0)
serialize_in_addrs(f, "NTP", addresses, r);
serialize_in_addrs(f, addresses, r);
fputs("\n", f);
r = sd_dhcp_lease_get_domainname(lease, &string);
if (r >= 0)