From: Yu Watanabe Date: Sun, 15 Sep 2024 20:00:57 +0000 (+0900) Subject: sd-dhcp6-client: allow to request IA_PD on information requesting mode X-Git-Tag: v257-rc1~220^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=180cc5421d9712fb95a6bbc725dc8ba459360c8b;p=thirdparty%2Fsystemd.git sd-dhcp6-client: allow to request IA_PD on information requesting mode To support RFC 7084, WPD-4. --- diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 3e992d7cadc..5661beeb657 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -767,6 +767,14 @@ 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 30c0e514f86..3f8183c2c6f 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -769,11 +769,6 @@ 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(); diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index 7afd464dc0f..29cbdc95b4a 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -493,6 +493,11 @@ 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,