]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix the persistent option.
authorRoy Marples <roy@marples.name>
Sun, 25 Aug 2013 10:22:48 +0000 (10:22 +0000)
committerRoy Marples <roy@marples.name>
Sun, 25 Aug 2013 10:22:48 +0000 (10:22 +0000)
dhcp6.c
dhcpcd.c
dhcpcd.conf.5.in
if-options.h
ipv4.c
ipv6.c
ipv6nd.c

diff --git a/dhcp6.c b/dhcp6.c
index 9f4a14ae94367834e91c76e09bdfada24ae30bab..54978446f006bf94e0faccf25deba6f060c2d66f 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -2421,7 +2421,9 @@ dhcp6_freedrop(struct interface *ifp, int drop, const char *reason)
         * this.
         */
        if (ifp->options &&
-           ifp->options->options & (DHCPCD_STOPPING | DHCPCD_RELEASE))
+           ifp->options->options & (DHCPCD_STOPPING | DHCPCD_RELEASE) &&
+           (ifp->options->options & (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+           (DHCPCD_EXITING | DHCPCD_PERSISTENT))
                dhcp6_delete_delegates(ifp);
 
        state = D6_STATE(ifp);
@@ -2432,7 +2434,11 @@ dhcp6_freedrop(struct interface *ifp, int drop, const char *reason)
                        unlink(state->leasefile);
                }
                dhcp6_freedrop_addrs(ifp, drop, NULL);
-               if (drop && state->new) {
+               if (drop && state->new &&
+                   (ifp->options->options &
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT))
+               {
                        if (reason == NULL)
                                reason = "STOP6";
                        script_runreason(ifp, reason);
index 3a8102ac545294d6dc423caf575203b03fdb3d20..d410c4a06b5b093d058a70ba19393749ca3d28ee 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -747,6 +747,7 @@ handle_signal(int sig, siginfo_t *siginfo, __unused void *context)
                        break;
                if (do_release)
                        ifp->options->options |= DHCPCD_RELEASE;
+               ifp->options->options |= DHCPCD_EXITING;
                stop_interface(ifp);
        }
        exit(EXIT_FAILURE);
@@ -884,6 +885,7 @@ handle_args(struct fd_list *fd, int argc, char **argv)
                                continue;
                        if (do_release)
                                ifp->options->options |= DHCPCD_RELEASE;
+                       ifp->options->options |= DHCPCD_EXITING;
                        stop_interface(ifp);
                }
                return 0;
index 24e833cfdaa3f0c92c44f005e7071aff7d14d28e..bdbd65bfc5f49a066e1e571f5620d689047d0bd9 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 25, 2013
+.Dd August 25, 2013
 .Dt DHCPCD.CONF 5 SMM
 .Os
 .Sh NAME
@@ -134,6 +134,12 @@ is generated, otherwise DUID-LL is generated (link local address).
 The DUID-LLT generated will be held in
 .Pa @SYSCONFDIR@/dhcpcd.duid
 and should not be copied to other hosts.
+.It Ic persistent
+.Nm dhcpcd
+normally de-configures the interface and configuration when it exits.
+Sometimes, this isn't desirable if, for example, you have root mounted over
+NFS.
+You can use this option to stop this from happening.
 .It Ic fallback Ar profile
 Fallback to using this profile if DHCP fails.
 This allows you to configure a static profile instead of using ZeroConf.
index a00dd769a3964def6b3fbe92081e033065c96fb5..9eb768cae5f76b514fd60313c4cf06caba3f0da3 100644 (file)
@@ -95,6 +95,7 @@
 #define DHCPCD_STOPPING                        (1ULL << 41)
 #define DHCPCD_DEPARTED                        (1ULL << 42)
 #define DHCPCD_HOSTNAME_SHORT          (1ULL << 43)
+#define DHCPCD_EXITING                 (1ULL << 44)
 
 extern const struct option cf_options[];
 
diff --git a/ipv4.c b/ipv4.c
index 845f3860dc888069c63d057622da5413e6a0f9bc..4d497fb28e24f5c9278a7830523eee917cd46b29 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -608,7 +608,9 @@ ipv4_applyaddr(void *arg)
        lease = &state->lease;
 
        if (dhcp == NULL) {
-               if (!(ifo->options & DHCPCD_PERSISTENT)) {
+               if ((ifo->options & (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT))
+               {
                        ipv4_buildroutes();
                        if (state->addr.s_addr != 0)
                                delete_address(ifp);
diff --git a/ipv6.c b/ipv6.c
index 84e3e156039bf66490c61fd70040f8d1dbd868cf..19da0ab386317cb3f4c39b9eefe49dbe97490afb 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -457,7 +457,10 @@ ipv6_freedrop_addrs(struct ipv6_addrhead *addrs, int drop,
                 * This is safe because the RA is removed from the list
                 * before we are called. */
                if (drop && ap->flags & IPV6_AF_ADDED &&
-                   !ipv6nd_addrexists(ap) && !dhcp6_addrexists(ap))
+                   !ipv6nd_addrexists(ap) && !dhcp6_addrexists(ap) &&
+                   (ap->iface->options->options &
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT))
                {
                        syslog(LOG_INFO, "%s: deleting address %s",
                            ap->iface->name, ap->saddr);
@@ -1026,7 +1029,9 @@ ipv6_buildroutes(void)
                                /* no need to add it back to our routing table
                                 * as we delete an exiting route when we add
                                 * a new one */
-                       else
+                       else if ((rt->iface->options->options &
+                               (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+                               (DHCPCD_EXITING | DHCPCD_PERSISTENT))
                                d_route(rt);
                }
                free(rt);
index 38486b1259ec1395be8b3bbc6067c684b5fd2b1d..8f372b0db5ecc66272ba58f20175bc17531e713e 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -1268,7 +1268,10 @@ ipv6nd_drop(struct interface *ifp)
                        ipv6nd_drop_ra(rap);
                }
                ipv6_buildroutes();
-               script_runreason(ifp, "ROUTERADVERT");
+               if ((ifp->options->options &
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+                   (DHCPCD_EXITING | DHCPCD_PERSISTENT))
+                       script_runreason(ifp, "ROUTERADVERT");
        }
 }
 static void