]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP6: T1, T2, vltime and pltime SHOULD be zero from client messages
authorRoy Marples <roy@marples.name>
Mon, 29 Aug 2022 16:58:18 +0000 (17:58 +0100)
committerRoy Marples <roy@marples.name>
Mon, 29 Aug 2022 17:01:17 +0000 (18:01 +0100)
See RFC 8415 21.4, 21.6, 21.21 and 21.22.
As such it's impossible to request a lease time as such and we
MUST use the vltimes and pltimes sent by the server.

This addresses the concern in #116 but does fix it as it's not a dhcpcd
problem.

src/dhcp6.c
src/dhcpcd.conf.5.in

index 1a319a7d528cd65476814c5168b813ef86b2b6dd..8d0271ea46166d76f6ad5ba9065fbcd5e22472e0 100644 (file)
@@ -962,6 +962,8 @@ dhcp6_makemessage(struct interface *ifp)
                else
                        ia_na_len = sizeof(ia_na);
                memcpy(ia_na.iaid, ifia->iaid, sizeof(ia_na.iaid));
+               /* RFC 8415 21.4 and 21.21 state that T1 and T2 should be zero.
+                * An RFC compliant server MUST ignore them anyway. */
                ia_na.t1 = 0;
                ia_na.t2 = 0;
                COPYIN(ifia->ia_type, &ia_na, ia_na_len);
@@ -980,11 +982,16 @@ dhcp6_makemessage(struct interface *ifp)
                                continue;
                        if (ap->ia_type == D6_OPTION_IA_PD) {
 #ifndef SMALL
-                               struct dhcp6_pd_addr pdp;
+                               struct dhcp6_pd_addr pdp = {
+                                   .prefix_len = ap->prefix_len,
+                                   /*
+                                    * RFC 8415 21.22 states that the
+                                    * valid and preferred lifetimes sent by
+                                    * the client SHOULD be zero and MUST
+                                    * be ignored by the server.
+                                    */
+                               };
 
-                               pdp.pltime = htonl(ap->prefix_pltime);
-                               pdp.vltime = htonl(ap->prefix_vltime);
-                               pdp.prefix_len = ap->prefix_len;
                                /* pdp.prefix is not aligned, so copy it in. */
                                memcpy(&pdp.prefix, &ap->prefix, sizeof(pdp.prefix));
                                COPYIN(D6_OPTION_IAPREFIX, &pdp, sizeof(pdp));
@@ -1019,11 +1026,16 @@ dhcp6_makemessage(struct interface *ifp)
                                }
 #endif
                        } else {
-                               struct dhcp6_ia_addr ia;
+                               struct dhcp6_ia_addr ia = {
+                                   .addr = ap->addr,
+                                   /*
+                                    * RFC 8415 21.6 states that the
+                                    * valid and preferred lifetimes sent by
+                                    * the client SHOULD be zero and MUST
+                                    * be ignored by the server.
+                                    */
+                               };
 
-                               ia.addr = ap->addr;
-                               ia.pltime = htonl(ap->prefix_pltime);
-                               ia.vltime = htonl(ap->prefix_vltime);
                                COPYIN(D6_OPTION_IA_ADDR, &ia, sizeof(ia));
                                ia_na_len = (uint16_t)
                                    (ia_na_len + sizeof(o) + sizeof(ia));
index 1c1f59ed06400b3193b05a1143b5bed54adda258..f00df3e1999329193e4a019f38bd4b3f9462d6a9 100644 (file)
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 24, 2022
+.Dd August 29, 2022
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -461,7 +461,7 @@ Enables IPv6 Router Advertisement solicitation.
 This is on by default, but is documented here in the case where it is disabled
 globally but needs to be enabled for one interface.
 .It Ic leasetime Ar seconds
-Request a lease time of
+Request DHCP a lease time of
 .Ar seconds .
 .Ar -1
 represents an infinite lease time.
@@ -469,6 +469,8 @@ By default
 .Nm dhcpcd
 does not request any lease time and leaves it in the hands of the
 DHCP server.
+It is not possible to request a DHCPv6 lease time as this is not RFC compliant.
+See RFC 8415 21.4, 21.6, 21.21 and 21.22.
 .It Ic link_rcvbuf Ar size
 Override the size of the link receive buffer from the kernel default.
 While