]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: allow to request IA_PD on information requesting mode
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Sep 2024 20:00:57 +0000 (05:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Oct 2024 09:23:59 +0000 (18:23 +0900)
To support RFC 7084, WPD-4.

src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-dhcp6-lease.c
src/libsystemd-network/test-dhcp6-client.c

index 3e992d7cadcdb56872f72a94aef672e7e1da4cc5..5661beeb657a968dc57f9fbe7aa96b645d659830 100644 (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:
index 30c0e514f86fe411246d3e76efa22054a229651e..3f8183c2c6fd5ba5fc981b6387323bc8b00edc38 100644 (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();
index 7afd464dc0ff6ee0e92232e695bf5e2aabb350c1..29cbdc95b4a2192d7ef271cf25c17344061af46a 100644 (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,