dhcpv6: fix incorrect IA type being printed in syslog
authorNicolas BESNARD <[email protected]>
Fri, 11 Apr 2025 09:50:07 +0000 (09:50 +0000)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 3 Nov 2025 15:21:24 +0000 (16:21 +0100)
Problem: If a status error code is received, "IA_NA" is always written
to syslog.

Cause: IA header type is not converted from network byte order to host
byte order.

Solution: Use ntohs() to convert to host byte order.

Signed-off-by: Nicolas BESNARD <[email protected]>
Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcp6c/pull/106
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv6.c

index 2640b776c62a5cc016090a0e0b4507b2600bae9b..26276d5da9dd36573d58ce0c86728117a0da75f9 100644 (file)
@@ -1875,7 +1875,7 @@ static void dhcpv6_handle_ia_status_code(const enum dhcpv6_msg orig,
                const void *status_msg, const int len,
                bool handled_status_codes[_DHCPV6_Status_Max], int *ret)
 {
-       dhcpv6_log_status_code(code, ia_hdr->type == DHCPV6_OPT_IA_NA ?
+       dhcpv6_log_status_code(code, ntohs(ia_hdr->type) == DHCPV6_OPT_IA_NA ?
                "IA_NA" : "IA_PD", status_msg, len);
 
        switch (code) {