diff options
author | Tom Gundersen <teg@jklm.no> | 2014-05-18 22:04:14 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-05-19 18:14:56 +0200 |
commit | 7374f9d87c710bc1ae3bfdb78a191a31c72d29b9 (patch) | |
tree | 002dc391d83b3df8cec25c8cf2ccffe1aa9eb753 /src/network | |
parent | 09bee74d7a5f266b175baa19892fa84a9da51d7f (diff) |
networkd: link - serialize DNS information
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-link.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 87a8d9f4ca..8ce2dbd39c 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1976,6 +1976,27 @@ int link_update(Link *link, sd_rtnl_message *m) { return link_update_flags(link, m); } +static void serialize_addresses(FILE *f, const char *key, Address *address) { + Address *ad; + + assert(f); + assert(key); + + if (!address) + return; + + fprintf(f, "%s=", key); + + LIST_FOREACH(addresses, ad, address) { + char buf[INET6_ADDRSTRLEN]; + + if (inet_ntop(address->family, &address->in_addr, buf, INET6_ADDRSTRLEN)) + fprintf(f, "%s%s", buf, (ad->addresses_next) ? " ": ""); + } + + fputs("\n", f); +} + int link_save(Link *link) { _cleanup_free_ char *temp_path = NULL; _cleanup_fclose_ FILE *f = NULL; @@ -2017,12 +2038,18 @@ int link_save(Link *link) { "FLAGS=%u\n", admin_state, oper_state, link->flags); + if (link->network) + serialize_addresses(f, "DNS", link->network->dns); + if (link->dhcp_lease) { r = dhcp_lease_save(link->dhcp_lease, link->lease_file); if (r < 0) goto finish; - fprintf(f, "DHCP_LEASE=%s\n", link->lease_file); + fprintf(f, + "DHCP_LEASE=%s\n" + "DHCP_USE_DNS=%s\n", + link->lease_file, yes_no(link->network->dhcp_dns)); } else unlink(link->lease_file); |