From e24ac1cf8c27116705f6abedd89be4d7533fc511 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Mon, 20 Oct 2025 18:29:36 +0200 Subject: [PATCH] dhcpv6: use a per-interface IAID for IA_NA requests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This ensures that the same IAID isn't used when odhcpd is e.g. running on different interfaces (RFC8415, §12). This is more important now that global DUID support has landed [1], meaning that odhcp6c won't typically use per-interface DUIDs. [1] https://github.com/openwrt/openwrt/pull/20359 Signed-off-by: David Härdeman Link: https://github.com/openwrt/odhcp6c/pull/105 Signed-off-by: Álvaro Fernández Rojas --- src/dhcpv6.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dhcpv6.c b/src/dhcpv6.c index fa0c2a1..2075006 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -479,9 +479,11 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) ia_na_entries /= sizeof(*e); struct dhcpv6_ia_hdr hdr_ia_na = { - htons(DHCPV6_OPT_IA_NA), - htons(sizeof(hdr_ia_na) - 4), - htonl(1), 0, 0 + .type = htons(DHCPV6_OPT_IA_NA), + .len = htons(sizeof(hdr_ia_na) - 4), + .iaid = htonl(ifindex), + .t1 = 0, + .t2 = 0, }; struct dhcpv6_ia_addr pa[ia_na_entries]; @@ -1156,7 +1158,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc, continue; // Test ID - if (ia_hdr->iaid != htonl(1) && otype == DHCPV6_OPT_IA_NA) + if (ia_hdr->iaid != htonl(ifindex) && otype == DHCPV6_OPT_IA_NA) continue; uint16_t code = DHCPV6_Success; -- 2.30.2