]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow DHCPv6 support to be compiled out.
authorRoy Marples <roy@marples.name>
Tue, 27 Sep 2016 10:17:39 +0000 (10:17 +0000)
committerRoy Marples <roy@marples.name>
Tue, 27 Sep 2016 10:17:39 +0000 (10:17 +0000)
README
configure
dhcp6.c
dhcp6.h
ipv6nd.c

diff --git a/README b/README
index 7db28cbfe03b59f5e77865a3aa133fb6d659fdfd..e2389015567e186fc6edd4d4f587ad55ae50badd 100644 (file)
--- a/README
+++ b/README
@@ -22,9 +22,10 @@ Other features maybe dropped as and when required.
 dhcpcd can also be made smaller by removing the IPv4 or IPv6 stack:
   *  --disable-inet
   *  --disable-inet6
-Or by removing the following features
+Or by removing the following features:
   *  --disable-auth
   *  --disable-ipv4ll
+  *  --disable-dhcp6
 
 You can also move the embedded extended configuration from the dhcpcd binary
 to an external file (LIBEXECDIR/dhcpcd-definitions.conf)
index fac3cbb8e698336fcaeea5278cf81820e7e664e4..59cce5653cf9e6a692c59527066b2a6b623c2bed 100755 (executable)
--- a/configure
+++ b/configure
@@ -50,6 +50,8 @@ for x do
        --enable-ipv4ll) IPV4LL=yes; INET=yes;;
        --disable-ipv6) INET6=no;;
        --enable-ipv6) INET6=yes;;
+       --disable-dhcp6) DHCP6=no;;
+       --enable-dhcp6) DHCP6=yes;;
        --disable-embedded) EMBEDDED=no;;
        --enable-embedded) EMBEDDED=yes;;
        --disable-auth) AUTH=no;;
@@ -440,16 +442,30 @@ sunos*)
 esac
 
 if [ -z "$INET" -o "$INET" = yes ]; then
+       echo "Enabling INET support"
        echo "CPPFLAGS+=        -DINET" >>$CONFIG_MK
        echo "DHCPCD_SRCS+=     arp.c dhcp.c ipv4.c" >>$CONFIG_MK
 fi
 if [ -z "$IPV4LL" -o "$IPV4LL" = yes ]; then
+       echo "Enabling IPv4LL support"
        echo "CPPFLAGS+=        -DIPV4LL" >>$CONFIG_MK
        echo "DHCPCD_SRCS+=     ipv4ll.c" >>$CONFIG_MK
 fi
 if [ -z "$INET6" -o "$INET6" = yes ]; then
+       echo "Enabling INET6 support"
        echo "CPPFLAGS+=        -DINET6" >>$CONFIG_MK
-       echo "DHCPCD_SRCS+=     ipv6.c ipv6nd.c dhcp6.c" >>$CONFIG_MK
+       echo "DHCPCD_SRCS+=     ipv6.c ipv6nd.c" >>$CONFIG_MK
+fi
+if [ -z "$DHCP6" -o "$DHCP6" = yes ]; then
+       echo "Enabling DHCPv6 support"
+       echo "CPPFLAGS+=        -DDHCP6" >>$CONFIG_MK
+       echo "DHCPCD_SRCS+=     dhcp6.c" >>$CONFIG_MK
+fi
+if [ -z "$AUTH" -o "$AUTH" = yes ]; then
+       echo "Enabling Authentiaction"
+       echo "CPPFLAGS+=        -DAUTH" >>$CONFIG_MK
+       echo "AUTH_SRCS=        auth.c crypt/hmac_md5.c" >>$CONFIG_MK
+       echo "AUTH_SRCS+=       \${MD5_SRC} \${SHA256_SRC}" >>$CONFIG_MK
 fi
 
 echo "Using compiler .. $CC"
@@ -490,13 +506,6 @@ else
        echo "EMBEDDEDINSTALL=  _embeddedinstall" >>$CONFIG_MK
 fi
 
-if [ -z "$AUTH" -o "$AUTH" = yes ]; then
-       echo "Enabling Authentiaction"
-       echo "CPPFLAGS+=        -DAUTH" >>$CONFIG_MK
-       echo "AUTH_SRCS=        auth.c crypt/hmac_md5.c" >>$CONFIG_MK
-       echo "AUTH_SRCS+=       \${MD5_SRC} \${SHA256_SRC}" >>$CONFIG_MK
-fi
-
 if [ "$OS" = linux ]; then
        printf "Testing for nl80211 ... "
        cat <<EOF >_nl80211.c
diff --git a/dhcp6.c b/dhcp6.c
index 3423f767de4b6d9c1f896a2a3244cfc90ec61388..6846f4148d836c984c017532882979b1ff75e547 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -72,6 +72,7 @@
 #define IPV6_RECVPKTINFO IPV6_PKTINFO
 #endif
 
+#ifdef DHCP6
 struct dhcp6_op {
        uint16_t type;
        const char *name;
@@ -3747,3 +3748,4 @@ dhcp6_dump(struct interface *ifp)
        state->reason = "DUMP6";
        return script_runreason(ifp, state->reason);
 }
+#endif
diff --git a/dhcp6.h b/dhcp6.h
index d967caa2dcad0f5c051b7e32ed1c5ac1a210d18e..2fb30f27a0f4034baec0884fdc558c0c4e3aacf7 100644 (file)
--- a/dhcp6.h
+++ b/dhcp6.h
@@ -230,7 +230,7 @@ struct dhcp6_state {
 #define D6_COPTION_DATA(o)                                                    \
     ((const uint8_t *)(o) + sizeof(struct dhcp6_option))
 
-#ifdef INET6
+#ifdef DHCP6
 void dhcp6_printoptions(const struct dhcpcd_ctx *,
     const struct dhcp_opt *, size_t);
 const struct ipv6_addr *dhcp6_iffindaddr(const struct interface *ifp,
@@ -250,14 +250,19 @@ void dhcp6_drop(struct interface *, const char *);
 void dhcp6_dropnondelegates(struct interface *ifp);
 int dhcp6_dump(struct interface *);
 #else
+#define dhcp6_printoptions(a, b, c) {}
+#define dhcp6_iffindaddr(a, b, c) (NULL)
+#define dhcp6_findaddr(a, b, c) (NULL)
 #define dhcp6_find_delegates(a) {}
 #define dhcp6_start(a, b) (0)
 #define dhcp6_reboot(a) {}
 #define dhcp6_renew(a) {}
-#define dhcp6_env(a, b, c, d, e) {}
+#define dhcp6_env(a, b, c, d, e) (0)
 #define dhcp6_free(a) {}
+#define dhcp6_handleifa(a, b) {}
 #define dhcp6_dadcompleted(a) (0)
 #define dhcp6_drop(a, b) {}
+#define dhcp6_dropnondelegates(a) {}
 #define dhcp6_dump(a) (-1)
 #endif
 
index 11415c1f264ec3269d5de1d5499ad7913b2727e5..103b332f4ed3218f53f09501597ca9bd73766e33 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -712,6 +712,19 @@ try_script:
        }
 }
 
+#ifndef DHCP6
+/* If DHCPv6 is compiled out, supply a shim to provide an error message
+ * if IPv6RA requests DHCPv6. */
+#undef dhcp6_start
+static int
+dhcp6_start(__unused struct interface *ifp, __unused enum DH6S init_state)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+#endif
+
 static void
 ipv6nd_handlera(struct dhcpcd_ctx *dctx, struct interface *ifp,
     struct icmp6_hdr *icp, size_t len, int hoplimit)
@@ -1102,13 +1115,19 @@ ipv6nd_handlera(struct dhcpcd_ctx *dctx, struct interface *ifp,
 handle_flag:
        if (!(ifp->options->options & DHCPCD_DHCP6))
                goto nodhcp6;
+/* Only log a DHCPv6 start error if compiled in or debugging is enabled. */
+#ifdef DHCP6
+#define LOG_DHCP6      LOG_ERR
+#else
+#define LOG_DHCP6      LOG_DEBUG
+#endif
        if (rap->flags & ND_RA_FLAG_MANAGED) {
                if (new_data && dhcp6_start(ifp, DH6S_INIT) == -1)
-                       logger(ifp->ctx, LOG_ERR,
+                       logger(ifp->ctx, LOG_DHCP6,
                            "dhcp6_start: %s: %m", ifp->name);
        } else if (rap->flags & ND_RA_FLAG_OTHER) {
                if (new_data && dhcp6_start(ifp, DH6S_INFORM) == -1)
-                       logger(ifp->ctx, LOG_ERR,
+                       logger(ifp->ctx, LOG_DHCP6,
                            "dhcp6_start: %s: %m", ifp->name);
        } else {
                if (new_data)