summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-10-02 13:15:44 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-06 19:50:50 +0200
commit5460bde5c5408d5fd518d5739a679a696a420f40 (patch)
treeb94ecaca3a0d45efdaa479201d546ddaf9e7894c /src/network
parentnetwork: introduce link_serialize_ipv4ll() (diff)
downloadsystemd-5460bde5c5408d5fd518d5739a679a696a420f40.tar.xz
systemd-5460bde5c5408d5fd518d5739a679a696a420f40.zip
network: introduce link_serialize_dhcp6_client()
Diffstat (limited to '')
-rw-r--r--src/network/networkd-dhcp6.c21
-rw-r--r--src/network/networkd-dhcp6.h2
-rw-r--r--src/network/networkd-link.c15
3 files changed, 26 insertions, 12 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 4b99c5f308..c835e5168f 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -1472,6 +1472,27 @@ int dhcp6_configure(Link *link) {
return 0;
}
+int link_serialize_dhcp6_client(Link *link, FILE *f) {
+ _cleanup_free_ char *duid = NULL;
+ uint32_t iaid;
+ int r;
+
+ assert(link);
+
+ if (!link->dhcp6_client)
+ return 0;
+
+ r = sd_dhcp6_client_get_iaid(link->dhcp6_client, &iaid);
+ if (r >= 0)
+ fprintf(f, "DHCP6_CLIENT_IAID=0x%x\n", iaid);
+
+ r = sd_dhcp6_client_duid_as_string(link->dhcp6_client, &duid);
+ if (r >= 0)
+ fprintf(f, "DHCP6_CLIENT_DUID=%s\n", duid);
+
+ return 0;
+}
+
int config_parse_dhcp6_pd_hint(
const char* unit,
const char *filename,
diff --git a/src/network/networkd-dhcp6.h b/src/network/networkd-dhcp6.h
index 214456096d..ae2cbcc988 100644
--- a/src/network/networkd-dhcp6.h
+++ b/src/network/networkd-dhcp6.h
@@ -32,6 +32,8 @@ int dhcp6_configure(Link *link);
int dhcp6_request_address(Link *link, int ir);
int dhcp6_request_prefix_delegation(Link *link);
+int link_serialize_dhcp6_client(Link *link, FILE *f);
+
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_hint);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_client_start_mode);
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index db01654699..864ad1d132 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -3515,18 +3515,9 @@ int link_save(Link *link) {
if (r < 0)
goto fail;
- if (link->dhcp6_client) {
- _cleanup_free_ char *duid = NULL;
- uint32_t iaid;
-
- r = sd_dhcp6_client_get_iaid(link->dhcp6_client, &iaid);
- if (r >= 0)
- fprintf(f, "DHCP6_CLIENT_IAID=0x%x\n", iaid);
-
- r = sd_dhcp6_client_duid_as_string(link->dhcp6_client, &duid);
- if (r >= 0)
- fprintf(f, "DHCP6_CLIENT_DUID=%s\n", duid);
- }
+ r = link_serialize_dhcp6_client(link, f);
+ if (r < 0)
+ goto fail;
r = fflush_and_check(f);
if (r < 0)