summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-10-22 18:00:12 +0200
committerGitHub <noreply@github.com>2024-10-22 18:00:12 +0200
commit119252343e891eb7673fab3911469b3111e61ae5 (patch)
tree3f253bc0021cc4d56dfbe904b8d687a80ac2ba92 /src/libsystemd-network
parentresolved: validate noerror response for CNAMEs (diff)
parentman: suggest to use DHCPv6Client= when upstream provides RA with the Managed ... (diff)
downloadsystemd-119252343e891eb7673fab3911469b3111e61ae5.tar.xz
systemd-119252343e891eb7673fab3911469b3111e61ae5.zip
Merge pull request #34848 from yuwata/network-dhcpv6-do-not-request-ia-pd-on-info-req
network/dhcp6: do not request IA_PD on information requesting mode
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c8
-rw-r--r--src/libsystemd-network/sd-dhcp6-lease.c40
-rw-r--r--src/libsystemd-network/test-dhcp6-client.c5
3 files changed, 11 insertions, 42 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 5661beeb65..3e992d7cad 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -767,14 +767,6 @@ int dhcp6_client_send_message(sd_dhcp6_client *client) {
switch (client->state) {
case DHCP6_STATE_INFORMATION_REQUEST:
- /* RFC 7084 section 4.2 (https://datatracker.ietf.org/doc/html/rfc7084#section-4.2)
- * WPD-4: By default, the IPv6 CE router MUST initiate DHCPv6 prefix delegation when either
- * the M or O flags are set to 1 in a received Router Advertisement (RA) message. */
- if (FLAGS_SET(client->request_ia, DHCP6_REQUEST_IA_PD)) {
- r = dhcp6_option_append_ia(&buf, &offset, (client->lease ? client->lease->ia_pd : NULL) ?: &client->ia_pd);
- if (r < 0)
- return r;
- }
break;
case DHCP6_STATE_SOLICITATION:
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c
index 647dea88bd..bc054c42b2 100644
--- a/src/libsystemd-network/sd-dhcp6-lease.c
+++ b/src/libsystemd-network/sd-dhcp6-lease.c
@@ -72,32 +72,6 @@ static void dhcp6_lease_set_lifetime(sd_dhcp6_lease *lease) {
lease->lifetime_t2 = t2;
}
-static void dhcp6_client_set_information_refresh_time(sd_dhcp6_client *client, sd_dhcp6_lease *lease, usec_t irt) {
- usec_t t1 = USEC_INFINITY, t2 = USEC_INFINITY, min_valid_lt = USEC_INFINITY;
-
- if (lease->ia_pd) {
- t1 = be32_sec_to_usec(lease->ia_pd->header.lifetime_t1, /* max_as_infinity = */ true);
- t2 = be32_sec_to_usec(lease->ia_pd->header.lifetime_t2, /* max_as_infinity = */ true);
-
- LIST_FOREACH(addresses, a, lease->ia_pd->addresses)
- min_valid_lt = MIN(min_valid_lt, be32_sec_to_usec(a->iapdprefix.lifetime_valid, /* max_as_infinity = */ true));
-
- if (t2 == 0 || t2 > min_valid_lt) {
- /* If T2 is zero or longer than the minimum valid lifetime of the prefixes,
- * then adjust lifetime with it. */
- t1 = min_valid_lt / 2;
- t2 = min_valid_lt / 10 * 8;
- }
-
- /* Adjust the received information refresh time with T1. */
- irt = MIN(irt, t1);
- }
-
- client->information_refresh_time_usec = MAX(irt, IRT_MINIMUM);
- log_dhcp6_client(client, "New information request will be refused in %s.",
- FORMAT_TIMESPAN(client->information_refresh_time_usec, USEC_PER_SEC));
-}
-
#define DEFINE_GET_TIME_FUNCTIONS(name, val) \
int sd_dhcp6_lease_get_##name( \
sd_dhcp6_lease *lease, \
@@ -888,6 +862,11 @@ static int dhcp6_lease_parse_message(
case SD_DHCP6_OPTION_IA_PD: {
_cleanup_(dhcp6_ia_freep) DHCP6IA *ia = NULL;
+ if (client->state == DHCP6_STATE_INFORMATION_REQUEST) {
+ log_dhcp6_client(client, "Ignoring IA PD option in information requesting mode.");
+ break;
+ }
+
r = dhcp6_option_parse_ia(client, client->ia_pd.header.id, optcode, optlen, optval, &ia);
if (r == -ENOMEM)
return log_oom_debug();
@@ -993,9 +972,12 @@ static int dhcp6_lease_parse_message(
"The client ID in %s message does not match. Ignoring.",
dhcp6_message_type_to_string(message->type));
- if (client->state == DHCP6_STATE_INFORMATION_REQUEST)
- dhcp6_client_set_information_refresh_time(client, lease, irt);
- else {
+ if (client->state == DHCP6_STATE_INFORMATION_REQUEST) {
+ client->information_refresh_time_usec = MAX(irt, IRT_MINIMUM);
+ log_dhcp6_client(client, "New information request will be refused in %s.",
+ FORMAT_TIMESPAN(client->information_refresh_time_usec, USEC_PER_SEC));
+
+ } else {
r = dhcp6_lease_get_serverid(lease, NULL, NULL);
if (r < 0)
return log_dhcp6_client_errno(client, r, "%s has no server id",
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index 9f28ec8bec..882c04afbb 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -490,11 +490,6 @@ static const uint8_t msg_information_request[] = {
DHCP6_MESSAGE_INFORMATION_REQUEST,
/* Transaction ID */
0x0f, 0xb4, 0xe5,
- /* IA_PD */
- 0x00, SD_DHCP6_OPTION_IA_PD, 0x00, 0x0c,
- IA_ID_BYTES,
- 0x00, 0x00, 0x00, 0x00, /* lifetime T1 */
- 0x00, 0x00, 0x00, 0x00, /* lifetime T2 */
/* MUD URL */
/* ORO */
0x00, SD_DHCP6_OPTION_ORO, 0x00, 0x0c,