From eacd1dacfa17c4cfa62f804d3744554cb477e25a Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 1 Feb 2021 16:32:01 +0100 Subject: [PATCH 1/2] device: preserve the DHCPv6 mode when renewing the lease (cherry picked from commit 14600548158f8159847ba06a3f2f5eef2bb52881) --- src/devices/nm-device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4144c2a1b9..de93f2233c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -9862,13 +9862,16 @@ gboolean nm_device_dhcp6_renew(NMDevice *self, gboolean release) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + NMNDiscDHCPLevel mode; g_return_val_if_fail(priv->dhcp_data_6.client != NULL, FALSE); _LOGI(LOGD_DHCP6, "DHCPv6 lease renewal requested"); /* Terminate old DHCP instance and release the old lease */ + mode = priv->dhcp6.mode; dhcp6_cleanup(self, CLEANUP_TYPE_DECONFIGURE, release); + priv->dhcp6.mode = mode; /* Start DHCP again on the interface */ return dhcp6_start(self, FALSE); From cf6c9253f6cabc1be802a83b2809c39df8c6fcb6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 1 Feb 2021 18:02:37 +0100 Subject: [PATCH 2/2] dhcp: fix requesting prefixes in stateless mode According to RFC3315 section 15.12, Information-request messages can't include a IA option (such as IA_NA or IA_PD). When doing stateless DHCPv6, we start the client in the appropriate mode to issue an Information-request message: with "-S" for dhclient or calling sd_dhcp6_client_set_information_request(TRUE) for systemd. However, if we need a prefix later, the client must be restarted to ask the prefix. Currently both dhclient and systemd clients are still configured to send an Information-request with prefixes. Fix that. (cherry picked from commit 6ed95bd8e53f5ae274b726bc3fcd78b00058621f) --- src/dhcp/nm-dhcp-dhclient.c | 6 ++++++ src/dhcp/nm-dhcp-systemd.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 260f400e3e..5dc1e9ec67 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -437,6 +437,12 @@ dhclient_start(NMDhcpClient *client, if (addr_family == AF_INET6) { g_ptr_array_add(argv, (gpointer) "-6"); + + if (prefixes > 0 && nm_streq0(mode_opt, "-S")) { + /* -S is incompatible with -P, only use the latter */ + mode_opt = NULL; + } + if (mode_opt) g_ptr_array_add(argv, (gpointer) mode_opt); while (prefixes--) diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c index f929722377..09d11713ee 100644 --- a/src/dhcp/nm-dhcp-systemd.c +++ b/src/dhcp/nm-dhcp-systemd.c @@ -969,8 +969,11 @@ ip6_start(NMDhcpClient * client, _LOGT("dhcp-client6: set %p", sd_client); - if (nm_dhcp_client_get_info_only(client)) - sd_dhcp6_client_set_information_request(sd_client, 1); + if (nm_dhcp_client_get_info_only(client)) { + sd_dhcp6_client_set_address_request(sd_client, 0); + if (needed_prefixes == 0) + sd_dhcp6_client_set_information_request(sd_client, 1); + } r = sd_dhcp6_client_set_iaid(sd_client, nm_dhcp_client_get_iaid(client)); if (r < 0) {