From: Roy Marples Date: Mon, 29 Aug 2022 16:58:18 +0000 (+0100) Subject: DHCP6: T1, T2, vltime and pltime SHOULD be zero from client messages X-Git-Tag: v10.0.0~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f86349e4919bb323342fff34f00bb1c2eb60d26;p=thirdparty%2Fdhcpcd.git DHCP6: T1, T2, vltime and pltime SHOULD be zero from client messages 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. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 1a319a7d..8d0271ea 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -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)); diff --git a/src/dhcpcd.conf.5.in b/src/dhcpcd.conf.5.in index 1c1f59ed..f00df3e1 100644 --- a/src/dhcpcd.conf.5.in +++ b/src/dhcpcd.conf.5.in @@ -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