udhcpc: Unconditionally call deconfig script, not only if lease is active
authorPeter Korsgaard <peter@korsgaard.com>
Fri, 26 Aug 2016 16:46:34 +0000 (18:46 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 26 Aug 2016 16:46:34 +0000 (18:46 +0200)
The udhcpc script may be used to setup fallback configuration (E.G. IPv4LL,
fixed IP address, ..) that also needs to be cleaned up on release (E.G.
when SIGUSR2 is called or on shutdown with -R), so unconditionally call
deconfig.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/d6_dhcpc.c
networking/udhcp/dhcpc.c

index 6ff040d9ed9121d9d4021cc0a560c40b1b521071..ddf3412a024c5bff6377a21b10ea9773f5ed5f72 100644 (file)
@@ -800,10 +800,15 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou
        ) {
                bb_error_msg("unicasting a release");
                send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
-               d6_run_script(NULL, "deconfig");
        }
        bb_error_msg("entering released state");
-
+/*
+ * We can be here on: SIGUSR2,
+ * or on exit (SIGTERM) and -R "release on quit" is specified.
+ * Users requested to be notified in all cases, even if not in one
+ * of the states above.
+ */
+       d6_run_script(NULL, "deconfig");
        change_listen_mode(LISTEN_NONE);
        state = RELEASED;
 }
index 8a16e987d412aedddc7201f756882a1418e6e3d1..bef73277ae49b7a734a22fdd4eff742451f93955 100644 (file)
@@ -1129,9 +1129,15 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
                bb_error_msg("unicasting a release of %s to %s",
                                inet_ntoa(temp_addr), buffer);
                send_release(server_addr, requested_ip); /* unicast */
-               udhcp_run_script(NULL, "deconfig");
        }
        bb_error_msg("entering released state");
+/*
+ * We can be here on: SIGUSR2,
+ * or on exit (SIGTERM) and -R "release on quit" is specified.
+ * Users requested to be notified in all cases, even if not in one
+ * of the states above.
+ */
+       udhcp_run_script(NULL, "deconfig");
 
        change_listen_mode(LISTEN_NONE);
        state = RELEASED;
@@ -1813,9 +1819,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                                        temp = udhcp_get_option(&packet, DHCP_SERVER_ID);
                                        if (!temp) {
  non_matching_svid:
-                                               log1("%s with wrong server ID, ignoring packet",
-                                                       "Received DHCP NAK"
-                                               );
+                                               log1("received DHCP NAK with wrong"
+                                                       " server ID, ignoring packet");
                                                continue;
                                        }
                                        move_from_unaligned32(svid, temp);