From d7afeea2b9650c64fcf915cbb3369577247b96ed Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Wed, 1 Oct 2025 23:38:13 +0200 Subject: [PATCH] dhcpv6c: fix illegal DHCPV6_OPT_FQDN MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some message types e.g. DHCPV6_MSG_INFO_REQ contained DHCPV6_CLIENT_FQDN (39) which is illegal. See Client FQDN RFC4704: https://www.rfc-editor.org/rfc/rfc4704#section-5 A client MUST only include the Client FQDN option in SOLICIT, REQUEST, RENEW, or REBIND messages. https://www.rfc-editor.org/rfc/rfc4704#section-6 Servers MUST only include a Client FQDN option in ADVERTISE and REPLY messages... Do not send it unless the message type is appropriate. Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcp6c/pull/100 Signed-off-by: Álvaro Fernández Rojas --- src/dhcpv6.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 5bf1ff4..28a2de2 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -582,8 +582,32 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) !(client_options & DHCPV6_ACCEPT_RECONFIGURE)) iov[IOV_RECONF_ACCEPT].iov_len = 0; - if (!(client_options & DHCPV6_CLIENT_FQDN)) + if (!(client_options & DHCPV6_CLIENT_FQDN)) { iov[IOV_FQDN].iov_len = 0; + } else { + switch (type) { + /* rfc4704 §5 + A client MUST only include the Client FQDN option in SOLICIT, + REQUEST, RENEW, or REBIND messages. + */ + case DHCPV6_MSG_SOLICIT: + case DHCPV6_MSG_REQUEST: + case DHCPV6_MSG_RENEW: + case DHCPV6_MSG_REBIND: + /* rfc4704 §6 + Servers MUST only include a Client FQDN option in ADVERTISE and REPLY + messages... + case DHCPV6_MSG_ADVERT: + case DHCPV6_MSG_REPLY: + */ + /* leave FQDN as-is */ + break; + default: + /* remaining MSG types cannot contain client FQDN */ + iov[IOV_FQDN].iov_len = 0; + break; + } + } struct sockaddr_in6 srv = {AF_INET6, htons(DHCPV6_SERVER_PORT), 0, ALL_DHCPV6_RELAYS, ifindex}; -- 2.30.2