]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add an option to reconfigure dhcpcd without rebinding.
authorRoy Marples <roy@marples.name>
Fri, 20 Mar 2009 10:21:12 +0000 (10:21 +0000)
committerRoy Marples <roy@marples.name>
Fri, 20 Mar 2009 10:21:12 +0000 (10:21 +0000)
This is primarily for interaction with 3rd party link management, such as PPP.
More work on #159.

dhcpcd.8.in
dhcpcd.c
if-options.c
if-options.h

index a1edeebb16e57e7ea27baec5b989db59cf3e8151..0e169d314c230c2c5843040f0113d1df87223e3f 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 19, 2009
+.Dd March 20, 2009
 .Dt DHCPCD 8 SMM
 .Os
 .Sh NAME
@@ -30,7 +30,7 @@
 .Nd an RFC 2131 compliant DHCP client
 .Sh SYNOPSIS
 .Nm
-.Op Fl bdknpqABDEGKLTV
+.Op Fl bdeknpqABDEGKLTV
 .Op Fl c , -script Ar script
 .Op Fl f , -config Ar file
 .Op Fl h , -hostname Ar hostname
@@ -172,6 +172,13 @@ Echo debug and informational messages to the console.
 Subsequent debug options stop
 .Nm
 from daemonising.
+.It Fl e , -reconfigure
+.Nm
+will re-apply IP address, routing and run
+.Xr dhcpcd-run-hooks 8
+for each interface.
+This is useful so that a 3rd party such as PPP or VPN can change the routing
+table and / or DNS, etc and then instruct dhcpcd to put things back afterwards.
 .It Fl f , -config Ar file
 Specify a config to load instead of
 .Pa @SYSCONFDIR@/dhcpcd.conf .
index 2c08c8ac1053cae39039de2817189188e03f0330..584e31cc2217130f7b8753db32c2160938046210 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -135,7 +135,7 @@ read_pid(void)
 static void
 usage(void)
 {
-       printf("usage: "PACKAGE" [-dknpqxyADEGHKLOTV] [-c script] [-f file ]"
+       printf("usage: "PACKAGE" [-deknpqxyADEGHKLOTV] [-c script] [-f file ]"
            " [-h hostname]\n"
            "              [-i classID ] [-l leasetime] [-m metric]"
            " [-o option] [-r ipaddr]\n"
@@ -1219,6 +1219,12 @@ handle_signal(_unused void *arg)
                syslog(LOG_INFO, "received SIGHUP, releasing lease");
                do_release = 1;
                break;
+       case SIGUSR1:
+               syslog(LOG_INFO, "received SIGUSR, reconfiguring");
+               for (iface = ifaces; iface; iface = iface->next)
+                       if (iface->state->new)
+                               configure(iface);
+               break;
        case SIGPIPE:
                syslog(LOG_WARNING, "received SIGPIPE");
                return;
@@ -1277,7 +1283,8 @@ int
 handle_args(struct fd_list *fd, int argc, char **argv)
 {
        struct interface *ifs, *ifp, *ifl, *ifn, *ift;
-       int do_exit = 0, do_release = 0, do_reboot = 0, opt, oi = 0;
+       int do_exit = 0, do_release = 0, do_reboot = 0, do_reconf = 0;
+       int opt, oi = 0;
        ssize_t len;
        size_t l;
        struct iovec iov[2];
@@ -1354,6 +1361,9 @@ handle_args(struct fd_list *fd, int argc, char **argv)
        while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
        {
                switch (opt) {
+               case 'e':
+                       do_reconf = 1;
+                       break;
                case 'k':
                        do_release = 1;
                        break;
@@ -1400,6 +1410,8 @@ handle_args(struct fd_list *fd, int argc, char **argv)
                        if (ifn) {
                                if (do_reboot)
                                        reconf_reboot(ifn, argc, argv);
+                               else if (do_reconf && ifn->state->new)
+                                       configure(ifn);
                                free_interface(ifp);
                        } else {
                                ifp->next = NULL;
@@ -1445,6 +1457,9 @@ main(int argc, char **argv)
        while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
        {
                switch (opt) {
+               case 'e':
+                       sig = SIGUSR1;
+                       break;
                case 'f':
                        cffile = optarg;
                        break;
index 7d0488449ef4fa9adf2fd444a531b4bc1b1a931d..15e4bfeece17df7e860be92145195ca05eec1dc8 100644 (file)
@@ -49,6 +49,7 @@ const struct option cf_options[] = {
        {"background",      no_argument,       NULL, 'b'},
        {"script",          required_argument, NULL, 'c'},
        {"debug",           no_argument,       NULL, 'd'},
+       {"reconfigure",     no_argument,       NULL, 'e'},
        {"config",          required_argument, NULL, 'f'},
        {"hostname",        optional_argument, NULL, 'h'},
        {"vendorclassid",   optional_argument, NULL, 'i'},
@@ -310,6 +311,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        struct rt *rt;
 
        switch(opt) {
+       case 'e': /* FALLTHROUGH */
        case 'n': /* FALLTHROUGH */
        case 'x': /* FALLTHROUGH */
        case 'T': /* We need to handle non interface options */
index 39c390f343e1106bd3503a3a2f9e8050192ba3a3..64c8bdea6c886a2405e1b0ec702c8167079ef844 100644 (file)
@@ -37,7 +37,7 @@
 
 /* Don't set any optional arguments here so we retain POSIX
  * compatibility with getopt */
-#define IF_OPTS "bc:df:h:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLO:Q:TVX:Z:"
+#define IF_OPTS "bc:def:h:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLN:O:Q:TVX:Z:"
 
 #define DEFAULT_TIMEOUT                30
 #define DEFAULT_REBOOT         10