odhcp6c: prevent RELEASE at shutdown when -k is set
authorNicolas BESNARD <[email protected]>
Thu, 10 Apr 2025 08:51:54 +0000 (08:51 +0000)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 3 Nov 2025 15:21:24 +0000 (16:21 +0100)
Problem: Based on the README, if -k option is set, a RELEASE message
should not be sent when the process is stopped. RELEASE messages are
also not sent in case of a forced RELEASE or reconfiguration, however.

Solution: Stop the transmission of RELEASE messages when the process is
stopped but allow it for a forced RELEASE or reconfiguration.

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/odhcp6c.c

index ac54ec7b07a4232af75273a07293f3157c7b2cc7..b66c5c323ba340e6e270daacac3b93371eb42c54 100644 (file)
@@ -698,13 +698,13 @@ int main(_unused int argc, char* const argv[])
                                notify_state_change("unbound", 0, true);
                        }
 
-                       if (server_id_len > 0 && (ia_pd_len > 0 || ia_na_len > 0) && config_dhcp->release)
+                       if (server_id_len > 0 && (ia_pd_len > 0 || ia_na_len > 0) && (!signal_term || config_dhcp->release))
                                dhcpv6_send_request(DHCPV6_MSG_RELEASE);
 
                        odhcp6c_clear_state(STATE_IA_NA);
                        odhcp6c_clear_state(STATE_IA_PD);
 
-                       if (!signal_usr2) {
+                       if (signal_term) {
                                terminate = true;
                        } else {
                                signal_usr2 = false;