summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-11-23 14:03:08 +0100
committerThomas Haller <thaller@redhat.com>2018-11-29 07:48:20 +0100
commitf2f44a7acaeec4681d37c3cffffb5601c2e421f2 (patch)
tree2fce584d8af5743e0489ca6f52790a2ba3268cd8
parent0ae18f06804b9c67aebd3970856273e8d8cc9bf0 (diff)
downloadNetworkManager-f2f44a7acaeec4681d37c3cffffb5601c2e421f2.tar.gz
dhcp: always explicitly set IAID of internal DHCPv6 client
During start, sd_dhcp6_client would call client_ensure_iaid(), to initialize the IAID. First of all, the IAID is important to us, we should not leave the used IAID up to an implementation detail. In the future, we possibly want to make this configurable. The problem is that client_ensure_iaid() calls dhcp_identifier_set_iaid() which looks up the interface name via if_indextoname() (in our fork). The problem is that dhcp_identifier_set_iaid() looks up information by quering the system, which makes it hard for testing and also makes it unpredictable. It's better to use our implementation nm_utils_create_dhcp_iaid(), which is solely based on the interface-name, which is given as a well defined parameter to the DHCP client instance.
-rw-r--r--src/dhcp/nm-dhcp-systemd.c12
-rw-r--r--src/systemd/src/libsystemd-network/sd-dhcp6-client.c2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index c33de3accd..bba0cde34a 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -894,6 +894,7 @@ ip6_start (NMDhcpClient *client,
nm_auto (sd_dhcp6_client_unrefp) sd_dhcp6_client *sd_client = NULL;
GBytes *hwaddr;
const char *hostname;
+ const char *iface;
int r, i;
const guint8 *duid_arr;
gsize duid_len;
@@ -928,6 +929,17 @@ ip6_start (NMDhcpClient *client,
if (nm_dhcp_client_get_info_only (client))
sd_dhcp6_client_set_information_request (sd_client, 1);
+ iface = nm_dhcp_client_get_iface (client);
+
+ r = sd_dhcp6_client_set_iaid (sd_client,
+ nm_utils_create_dhcp_iaid (TRUE,
+ (const guint8 *) iface,
+ strlen (iface)));
+ if (r < 0) {
+ nm_utils_error_set_errno (error, r, "failed to set IAID: %s");
+ return FALSE;
+ }
+
r = sd_dhcp6_client_set_duid (sd_client,
unaligned_read_be16 (&duid_arr[0]),
&duid_arr[2],
diff --git a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
index a1c9da7303..e39b185f2e 100644
--- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c
@@ -262,7 +262,6 @@ int sd_dhcp6_client_set_duid(
return dhcp6_client_set_duid_internal(client, duid_type, duid, duid_len, 0);
}
-#if 0 /* NM_IGNORED */
int sd_dhcp6_client_set_duid_llt(
sd_dhcp6_client *client,
usec_t llt_time) {
@@ -279,7 +278,6 @@ int sd_dhcp6_client_set_iaid(sd_dhcp6_client *client, uint32_t iaid) {
return 0;
}
-#endif /* NM_IGNORED */
int sd_dhcp6_client_set_fqdn(
sd_dhcp6_client *client,