summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-03-07 10:06:45 +0000
committerRoy Marples <roy@marples.name>2012-03-07 10:06:45 +0000
commit61dd6cf9ab7dfbdf6dac4e4517517448c02003b2 (patch)
treea3a8c0c9033d800ab0e23e4fd699e6ca7c293ae3
parent59b38886f9e00950b4b83d67d115f3f8cd120f4f (diff)
downloaddhcpcd-61dd6cf9ab7dfbdf6dac4e4517517448c02003b2.tar.xz
Add an option to control dhcpcd forking or not if the RA does not contain
a RDNSS option. This involves changing our options to an unsigned long long so we can use more than 32 bits.
-rw-r--r--dhcp.c2
-rw-r--r--dhcp.h5
-rw-r--r--dhcpcd.c2
-rw-r--r--dhcpcd.conf.5.in14
-rw-r--r--dhcpcd.h2
-rw-r--r--if-options.c12
-rw-r--r--if-options.h65
-rw-r--r--ipv6rs.c7
8 files changed, 66 insertions, 43 deletions
diff --git a/dhcp.c b/dhcp.c
index 89673439..cfbc2a0e 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -772,7 +772,7 @@ route_netmask(uint32_t ip_in)
* Otherwise we add static routes and then routers. */
struct rt *
get_option_routes(const struct dhcp_message *dhcp,
- const char *ifname, int *opts)
+ const char *ifname, unsigned long long *opts)
{
const uint8_t *p;
const uint8_t *e;
diff --git a/dhcp.h b/dhcp.h
index 1f3fb66d..fb27e71b 100644
--- a/dhcp.h
+++ b/dhcp.h
@@ -1,6 +1,6 @@
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2011 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -186,7 +186,8 @@ int get_option_uint8(uint8_t *, const struct dhcp_message *, uint8_t);
#define is_bootp(m) (m && \
!IN_LINKLOCAL(htonl((m)->yiaddr)) && \
get_option_uint8(NULL, m, DHO_MESSAGETYPE) == -1)
-struct rt *get_option_routes(const struct dhcp_message *, const char *, int *);
+struct rt *get_option_routes(const struct dhcp_message *, const char *,
+ unsigned long long *);
ssize_t decode_rfc3397(char *, ssize_t, int, const uint8_t *);
ssize_t configure_env(char **, const char *, const struct dhcp_message *,
const struct if_options *);
diff --git a/dhcpcd.c b/dhcpcd.c
index 0f71e4a6..8e6a66d8 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -80,7 +80,7 @@ const char copyright[] = "Copyright (c) 2006-2012 Roy Marples";
#define RELEASE_DELAY_S 0
#define RELEASE_DELAY_NS 10000000
-int options = 0;
+unsigned long long options = 0;
int pidfd = -1;
struct interface *ifaces = NULL;
int ifac = 0;
diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in
index aa94b8a6..a66de9ef 100644
--- a/dhcpcd.conf.5.in
+++ b/dhcpcd.conf.5.in
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2006-2011 Roy Marples
+.\" Copyright (c) 2006-2012 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 15, 2011
+.Dd March 7, 2012
.Dt DHCPCD.CONF 5 SMM
.Os
.Sh NAME
@@ -144,6 +144,16 @@ encodes the FQDN hostname as specified in
.It Ic interface Ar interface
Subsequent options are only parsed for this
.Ar interface .
+.It Ic ipv6ra_fork
+By default, when
+.Nm dhcpcd
+receives an IPv6 RA,
+.Nm dhcpcd
+will only fork to the background if the RA contains at least one unexpired
+RDNSS option.
+Set this option so to make
+.Nm dhcpcd
+always fork on an RA.
.It Ic leasetime Ar seconds
Request a leasetime of
.Ar seconds .
diff --git a/dhcpcd.h b/dhcpcd.h
index b3cee6f9..fbb96003 100644
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -143,7 +143,7 @@ struct interface {
};
extern int pidfd;
-extern int options;
+extern unsigned long long options;
extern int ifac;
extern char **ifav;
extern int ifdc;
diff --git a/if-options.c b/if-options.c
index 2b507604..864dc85a 100644
--- a/if-options.c
+++ b/if-options.c
@@ -1,6 +1,6 @@
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2011 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -54,6 +54,7 @@
#define O_FALLBACK O_BASE + 2
#define O_DESTINATION O_BASE + 3
#define O_NOIPV6RS O_BASE + 4
+#define O_IPV6_RA_FORK O_BASE + 5
const struct option cf_options[] = {
{"background", no_argument, NULL, 'b'},
@@ -105,6 +106,7 @@ const struct option cf_options[] = {
{"destination", required_argument, NULL, O_DESTINATION},
{"fallback", required_argument, NULL, O_FALLBACK},
{"noipv6rs", no_argument, NULL, O_NOIPV6RS},
+ {"ipv6ra_fork", no_argument, NULL, O_IPV6_RA_FORK},
{NULL, 0, NULL, '\0'}
};
@@ -743,7 +745,10 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
ifo->fallback = xstrdup(arg);
break;
case O_NOIPV6RS:
- ifo->options &=~ DHCPCD_IPV6RS;
+ ifo->options &= ~DHCPCD_IPV6RS;
+ break;
+ case O_IPV6_RA_FORK:
+ ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS;
break;
default:
return 0;
@@ -789,7 +794,8 @@ read_config(const char *file,
/* Seed our default options */
ifo = xzalloc(sizeof(*ifo));
ifo->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE | DHCPCD_LINK;
- ifo->options |= DHCPCD_ARP | DHCPCD_IPV4LL | DHCPCD_IPV6RS;
+ ifo->options |= DHCPCD_ARP | DHCPCD_IPV4LL;
+ ifo->options |= DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS;
ifo->timeout = DEFAULT_TIMEOUT;
ifo->reboot = DEFAULT_REBOOT;
ifo->metric = -1;
diff --git a/if-options.h b/if-options.h
index 01585c2b..685de6e0 100644
--- a/if-options.h
+++ b/if-options.h
@@ -1,6 +1,6 @@
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2011 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -48,36 +48,37 @@
#define USERCLASS_MAX_LEN 255
#define VENDOR_MAX_LEN 255
-#define DHCPCD_ARP (1 << 0)
-#define DHCPCD_RELEASE (1 << 1)
-#define DHCPCD_DOMAIN (1 << 2)
-#define DHCPCD_GATEWAY (1 << 3)
-#define DHCPCD_STATIC (1 << 4)
-#define DHCPCD_DEBUG (1 << 5)
-#define DHCPCD_LASTLEASE (1 << 7)
-#define DHCPCD_INFORM (1 << 8)
-#define DHCPCD_REQUEST (1 << 9)
-#define DHCPCD_IPV4LL (1 << 10)
-#define DHCPCD_DUID (1 << 11)
-#define DHCPCD_PERSISTENT (1 << 12)
-#define DHCPCD_DAEMONISE (1 << 14)
-#define DHCPCD_DAEMONISED (1 << 15)
-#define DHCPCD_TEST (1 << 16)
-#define DHCPCD_MASTER (1 << 17)
-#define DHCPCD_HOSTNAME (1 << 18)
-#define DHCPCD_CLIENTID (1 << 19)
-#define DHCPCD_LINK (1 << 20)
-#define DHCPCD_QUIET (1 << 21)
-#define DHCPCD_BACKGROUND (1 << 22)
-#define DHCPCD_VENDORRAW (1 << 23)
-#define DHCPCD_TIMEOUT_IPV4LL (1 << 24)
-#define DHCPCD_WAITIP (1 << 25)
-#define DHCPCD_WAITUP (1 << 26)
-#define DHCPCD_CSR_WARNED (1 << 27)
-#define DHCPCD_XID_HWADDR (1 << 28)
-#define DHCPCD_BROADCAST (1 << 29)
-#define DHCPCD_DUMPLEASE (1 << 30)
-#define DHCPCD_IPV6RS (1 << 31)
+#define DHCPCD_ARP (1ULL << 0)
+#define DHCPCD_RELEASE (1ULL << 1)
+#define DHCPCD_DOMAIN (1ULL << 2)
+#define DHCPCD_GATEWAY (1ULL << 3)
+#define DHCPCD_STATIC (1ULL << 4)
+#define DHCPCD_DEBUG (1ULL << 5)
+#define DHCPCD_LASTLEASE (1ULL << 7)
+#define DHCPCD_INFORM (1ULL << 8)
+#define DHCPCD_REQUEST (1ULL << 9)
+#define DHCPCD_IPV4LL (1ULL << 10)
+#define DHCPCD_DUID (1ULL << 11)
+#define DHCPCD_PERSISTENT (1ULL << 12)
+#define DHCPCD_DAEMONISE (1ULL << 14)
+#define DHCPCD_DAEMONISED (1ULL << 15)
+#define DHCPCD_TEST (1ULL << 16)
+#define DHCPCD_MASTER (1ULL << 17)
+#define DHCPCD_HOSTNAME (1ULL << 18)
+#define DHCPCD_CLIENTID (1ULL << 19)
+#define DHCPCD_LINK (1ULL << 20)
+#define DHCPCD_QUIET (1ULL << 21)
+#define DHCPCD_BACKGROUND (1ULL << 22)
+#define DHCPCD_VENDORRAW (1ULL << 23)
+#define DHCPCD_TIMEOUT_IPV4LL (1ULL << 24)
+#define DHCPCD_WAITIP (1ULL << 25)
+#define DHCPCD_WAITUP (1ULL << 26)
+#define DHCPCD_CSR_WARNED (1ULL << 27)
+#define DHCPCD_XID_HWADDR (1ULL << 28)
+#define DHCPCD_BROADCAST (1ULL << 29)
+#define DHCPCD_DUMPLEASE (1ULL << 30)
+#define DHCPCD_IPV6RS (1ULL << 31)
+#define DHCPCD_IPV6RA_REQRDNSS (1ULL << 32)
extern const struct option cf_options[];
@@ -90,7 +91,7 @@ struct if_options {
uint32_t leasetime;
time_t timeout;
time_t reboot;
- int options;
+ unsigned long long options;
struct in_addr req_addr;
struct in_addr req_mask;
diff --git a/ipv6rs.c b/ipv6rs.c
index 4c5f67a8..999c4602 100644
--- a/ipv6rs.c
+++ b/ipv6rs.c
@@ -468,7 +468,8 @@ ipv6rs_handledata(_unused void *arg)
'\0';
} else
opt = xstrdup(cbp);
- has_dns = 1;
+ if (lifetime > 0)
+ has_dns = 1;
}
op += sizeof(addr.s6_addr);
}
@@ -535,6 +536,10 @@ ipv6rs_handledata(_unused void *arg)
if (options & DHCPCD_TEST)
exit(EXIT_SUCCESS);
+ /* If we don't require RDNSS then set has_dns = 1 so we fork */
+ if (!(ifp->state->options->options & DHCPCD_IPV6RA_REQRDNSS))
+ has_dns = 1;
+
if (has_dns)
delete_q_timeout(0, handle_exit_timeout, NULL);
delete_timeouts(ifp, NULL);