summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-03-20 10:21:12 +0000
committerRoy Marples <roy@marples.name>2009-03-20 10:21:12 +0000
commit373e6ce084d5a03c07ddf11ddfc380b4da34fb1b (patch)
treea2b2cf32fe41556c73b70cf7838424e33e0c0427
parent263e8fdd42025e4c1f3bafbad5fdc85d71eb832c (diff)
downloaddhcpcd-373e6ce084d5a03c07ddf11ddfc380b4da34fb1b.tar.xz
Add an option to reconfigure dhcpcd without rebinding.
This is primarily for interaction with 3rd party link management, such as PPP. More work on #159.
-rw-r--r--dhcpcd.8.in11
-rw-r--r--dhcpcd.c19
-rw-r--r--if-options.c2
-rw-r--r--if-options.h2
4 files changed, 29 insertions, 5 deletions
diff --git a/dhcpcd.8.in b/dhcpcd.8.in
index a1edeebb..0e169d31 100644
--- a/dhcpcd.8.in
+++ b/dhcpcd.8.in
@@ -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 .
diff --git a/dhcpcd.c b/dhcpcd.c
index 2c08c8ac..584e31cc 100644
--- 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;
diff --git a/if-options.c b/if-options.c
index 7d048844..15e4bfee 100644
--- a/if-options.c
+++ b/if-options.c
@@ -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 */
diff --git a/if-options.h b/if-options.h
index 39c390f3..64c8bdea 100644
--- a/if-options.h
+++ b/if-options.h
@@ -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