sd-dhcp6-client: allow to request IA_PD on information requesting mode

To support RFC 7084, WPD-4.
This commit is contained in:
Yu Watanabe
2024-09-16 05:00:57 +09:00
parent 8fead9c9e4
commit 180cc5421d
3 changed files with 13 additions and 5 deletions

View File

@@ -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:

View File

@@ -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();

View File

@@ -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,