]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add an option to control dhcpcd forking or not if the RA does not contain
authorRoy Marples <roy@marples.name>
Wed, 7 Mar 2012 10:06:45 +0000 (10:06 +0000)
committerRoy Marples <roy@marples.name>
Wed, 7 Mar 2012 10:06:45 +0000 (10:06 +0000)
a RDNSS option.
This involves changing our options to an unsigned long long so we can use
more than 32 bits.

dhcp.c
dhcp.h
dhcpcd.c
dhcpcd.conf.5.in
dhcpcd.h
if-options.c
if-options.h
ipv6rs.c

diff --git a/dhcp.c b/dhcp.c
index 8967343915d8ea6e78316f9fdff48a2a0debee06..cfbc2a0efb7b47dcba8112c661501e26b895ea31 100644 (file)
--- 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 1f3fb66d35c3a310114f39e216be95f0ca3e1292..fb27e71ba891566c42a6f1e074f06227b75d738d 100644 (file)
--- 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 *);
index 0f71e4a67bd29a8e51d0290f084951460c969330..8e6a66d8905429e6506d7cf9d00cd444216a4e36 100644 (file)
--- 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;
index aa94b8a69c69c3e331cb553f476ffd6cd9100c62..a66de9ef1789aab6378e9925fc2a6c7187695b49 100644 (file)
@@ -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 .
index b3cee6f9f6150629e64f2bdf183db0a0c443b6b7..fbb96003b166dd10da36bcac475ae5a8f24074a4 100644 (file)
--- 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;
index 2b507604f68db9e3b0e6ac4847f632d6c4abfb71..864dc85aa3cc863a1ff9c92170d3da46c942c263 100644 (file)
@@ -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;
index 01585c2b3981e7d969334df9741db8d7e58315b5..685de6e04a5071e64ec2219d51f31278c4a297a1 100644 (file)
@@ -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
 #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;
index 4c5f67a88b45dfe9e792b494e7e63f8d4696daab..999c460261578dcd4cfb5a2b321aa8a0eefd48d8 100644 (file)
--- 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);