summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Küttner2025-10-20 16:53:38 +0000
committerÁlvaro Fernández Rojas2025-11-05 07:18:58 +0000
commit775e6c759cfdc54028795c23f83b41215d903e99 (patch)
tree39ca29ba8ff258ce04e580abefa455c6efa20ddb
parent9e414d41e16e31c3b07a5b7f064409b9da0f1174 (diff)
downloadodhcp6c-775e6c759cfdc54028795c23f83b41215d903e99.tar.gz
dhcpv6: return early upon success
Once a "DHCPV6_Success" status is seen, don’t abort on subsequent non-Success to prevent "No Address Available" errors. Signed-off-by: Jerome Küttner <jkuettner-dev@proton.me> Link: https://github.com/openwrt/odhcp6c/pull/90 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
-rw-r--r--src/dhcpv6.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 6aed871..8317d83 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1368,6 +1368,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
uint16_t code = DHCPV6_Success;
uint16_t stype, slen;
uint8_t *sdata;
+ bool dhcpv6_successful_once = false;
// Get and handle status code
dhcpv6_for_each_option(&ia_hdr[1], odata + olen,
stype, slen, sdata) {
@@ -1377,8 +1378,10 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
code = ((int)sdata[0]) << 8 | ((int)sdata[1]);
- if (code == DHCPV6_Success)
+ if (code == DHCPV6_Success) {
+ dhcpv6_successful_once = true;
continue;
+ }
dhcpv6_handle_ia_status_code(orig, ia_hdr,
code, mdata, mlen, handled_status_codes, &ret);
@@ -1387,7 +1390,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
}
}
- if (code != DHCPV6_Success)
+ if (!dhcpv6_successful_once && code != DHCPV6_Success)
continue;
updated_IAs += dhcpv6_parse_ia(ia_hdr, odata + olen, &ret);