]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow IPv4LL to be compiled out.
authorRoy Marples <roy@marples.name>
Tue, 20 Sep 2016 09:29:39 +0000 (09:29 +0000)
committerRoy Marples <roy@marples.name>
Tue, 20 Sep 2016 09:29:39 +0000 (09:29 +0000)
README
configure
dhcp.c
ipv4.c
ipv4ll.c
ipv4ll.h
script.c

diff --git a/README b/README
index 79c709e1473765c6071ff5bb37510668ea43cc81..24554101cc24940322d6361c9d5318b2b8329145 100644 (file)
--- a/README
+++ b/README
@@ -19,8 +19,12 @@ Currently this just removes non important options out of
 dhcpcd-definitions.conf, the custom logger and
 support for DHCPv6 Prefix Delegation.
 Other features maybe dropped as and when required.
-dhcpcd can also be made smaller by removing Authentication support with
---disable-auth.
+dhcpcd can also be made smaller by removing the IPv4 or IPv6 stack:
+  *  --disable-inet
+  *  --disable-inet6
+Or by removing the following features
+  *  --disable-auth
+  *  --disable-ipv4ll
 
 If you're cross compiling you may need set the platform if OS is different
 from the host.
index 4b43f3c5b633d903e88c34ede44cfc6fdc635ba7..fac3cbb8e698336fcaeea5278cf81820e7e664e4 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,6 +7,7 @@ exec 3>config.log
 # Ensure that we do not inherit these from env
 HOOKSET=false
 INET=
+IPV4LL=
 INET6=
 ARC4RANDOM=
 CLOSEFROM=
@@ -45,6 +46,8 @@ for x do
        --enable-static) STATIC=yes;;
        --disable-ipv4) INET=no;;
        --enable-ipv4) INET=yes;;
+       --disable-ipv4ll) IPV4LL=no;;
+       --enable-ipv4ll) IPV4LL=yes; INET=yes;;
        --disable-ipv6) INET6=no;;
        --enable-ipv6) INET6=yes;;
        --disable-embedded) EMBEDDED=no;;
@@ -438,7 +441,11 @@ esac
 
 if [ -z "$INET" -o "$INET" = yes ]; then
        echo "CPPFLAGS+=        -DINET" >>$CONFIG_MK
-       echo "DHCPCD_SRCS+=     arp.c dhcp.c ipv4.c ipv4ll.c" >>$CONFIG_MK
+       echo "DHCPCD_SRCS+=     arp.c dhcp.c ipv4.c" >>$CONFIG_MK
+fi
+if [ -z "$IPV4LL" -o "$IPV4LL" = yes ]; then
+       echo "CPPFLAGS+=        -DIPV4LL" >>$CONFIG_MK
+       echo "DHCPCD_SRCS+=     ipv4ll.c" >>$CONFIG_MK
 fi
 if [ -z "$INET6" -o "$INET6" = yes ]; then
        echo "CPPFLAGS+=        -DINET6" >>$CONFIG_MK
diff --git a/dhcp.c b/dhcp.c
index 9bfb7b2c0a210c2ad79fba39ed8928a605740d06..f6e1d163229322fc64dd5f8cfea9b02e75566252 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1845,9 +1845,11 @@ dhcp_discover(void *arg)
        if (ifo->fallback)
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    ifo->reboot, dhcp_fallback, ifp);
+#ifdef IPV4LL
        else if (ifo->options & DHCPCD_IPV4LL)
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    ifo->reboot, ipv4ll_start, ifp);
+#endif
        if (ifo->options & DHCPCD_REQUEST)
                logger(ifp->ctx, LOG_INFO,
                    "%s: soliciting a DHCP lease (requesting %s)",
@@ -2510,10 +2512,12 @@ dhcp_reboot(struct interface *ifp)
        state->lease.server.s_addr = 0;
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 
+#ifdef IPV4LL
        /* Need to add this before dhcp_expire and friends. */
        if (!ifo->fallback && ifo->options & DHCPCD_IPV4LL)
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    ifo->reboot, ipv4ll_start, ifp);
+#endif
 
        if (ifo->options & DHCPCD_LASTLEASE && state->lease.frominfo)
                eloop_timeout_add_sec(ifp->ctx->eloop,
@@ -2907,6 +2911,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                            "%s: message: %s", ifp->name, msg);
                        free(msg);
                }
+#ifdef IPV4LL
                if (state->state == DHS_DISCOVER &&
                    get_option_uint8(ifp->ctx, &tmp, bootp, bootp_len,
                    DHO_AUTOCONFIGURE) == 0)
@@ -2931,6 +2936,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                        eloop_timeout_add_sec(ifp->ctx->eloop,
                            DHCP_MAX, dhcp_discover, ifp);
                }
+#endif
                return;
        }
 
@@ -3581,11 +3587,13 @@ dhcp_start1(void *arg)
                }
        }
 
+#ifdef IPV4LL
        if (!(ifo->options & DHCPCD_DHCP)) {
                if (ifo->options & DHCPCD_IPV4LL)
                        ipv4ll_start(ifp);
                return;
        }
+#endif
 
        if (state->offer == NULL || !IS_DHCP(state->offer))
                dhcp_discover(ifp);
diff --git a/ipv4.c b/ipv4.c
index 1da40ad0f89bf2d7f387d1f3bc3f6e01633258ef..837fb8864377f9b578cc08fc09d6d984e98ceb86 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -196,14 +196,14 @@ int
 ipv4_hasaddr(const struct interface *ifp)
 {
        const struct dhcp_state *dstate;
-       const struct ipv4ll_state *istate;
+
+       if (IPV4LL_STATE_RUNNING(ifp))
+               return 1;
 
        dstate = D_CSTATE(ifp);
-       istate = IPV4LL_CSTATE(ifp);
-       return ((dstate &&
+       return (dstate &&
            dstate->added == STATE_ADDED &&
-           dstate->addr != NULL) ||
-           (istate && istate->addr));
+           dstate->addr != NULL);
 }
 
 void
index 9570665f7fd4d1a483c746fd496ba874145fcc54..f73637b0e5b7d31955e2bb0461df8936914f2347 100644 (file)
--- a/ipv4ll.c
+++ b/ipv4ll.c
@@ -52,6 +52,7 @@ static const struct in_addr inaddr_llbcast = {
        .s_addr = HTONL(LINKLOCAL_BCAST)
 };
 
+#ifdef IPV4LL
 static in_addr_t
 ipv4ll_pickaddr(struct arp_state *astate)
 {
@@ -490,3 +491,4 @@ ipv4ll_handlert(struct dhcpcd_ctx *ctx, __unused int cmd, const struct rt *rt)
        return 0;
 }
 #endif
+#endif
index 5f7cee88650ba4a1f31f01b1b1483f77cf260c4b..34a185ff6f97627c63a82084fac5ec785f4da6c2 100644 (file)
--- a/ipv4ll.h
+++ b/ipv4ll.h
 #ifndef IPV4LL_H
 #define IPV4LL_H
 
-#ifdef INET
-#include "arp.h"
-
-#define LINKLOCAL_ADDR 0xa9fe0000
-#define LINKLOCAL_MASK IN_CLASSB_NET
-#define LINKLOCAL_BCAST        (LINKLOCAL_ADDR | ~LINKLOCAL_MASK)
+#define        LINKLOCAL_ADDR          0xa9fe0000
+#define        LINKLOCAL_MASK          IN_CLASSB_NET
+#define        LINKLOCAL_BCAST         (LINKLOCAL_ADDR | ~LINKLOCAL_MASK)
 
 #ifndef IN_LINKLOCAL
 # define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == LINKLOCAL_ADDR)
 #endif
 
+#ifdef IPV4LL
+#include "arp.h"
+
 struct ipv4ll_state {
        struct ipv4_addr *addr;
        struct arp_state *arp;
@@ -48,11 +48,11 @@ struct ipv4ll_state {
        uint8_t down;
 };
 
-#define IPV4LL_STATE(ifp)                                                     \
+#define        IPV4LL_STATE(ifp)                                                      \
        ((struct ipv4ll_state *)(ifp)->if_data[IF_DATA_IPV4LL])
-#define IPV4LL_CSTATE(ifp)                                                    \
+#define        IPV4LL_CSTATE(ifp)                                                     \
        ((const struct ipv4ll_state *)(ifp)->if_data[IF_DATA_IPV4LL])
-#define IPV4LL_STATE_RUNNING(ifp)                                             \
+#define        IPV4LL_STATE_RUNNING(ifp)                                              \
        (IPV4LL_CSTATE((ifp)) && !IPV4LL_CSTATE((ifp))->down &&                \
        (IPV4LL_CSTATE((ifp))->addr != NULL))
 
@@ -65,16 +65,19 @@ void ipv4ll_handle_failure(void *);
 #ifdef HAVE_ROUTE_METRIC
 int ipv4ll_handlert(struct dhcpcd_ctx *, int, const struct rt *);
 #else
-#define ipv4ll_handlert(a, b, c) (0)
+#define        ipv4ll_handlert(a, b, c)        (0)
 #endif
 
-#define ipv4ll_free(ifp) ipv4ll_freedrop((ifp), 0);
-#define ipv4ll_drop(ifp) ipv4ll_freedrop((ifp), 1);
+#define        ipv4ll_free(ifp) ipv4ll_freedrop((ifp), 0);
+#define        ipv4ll_drop(ifp) ipv4ll_freedrop((ifp), 1);
 void ipv4ll_freedrop(struct interface *, int);
 #else
-#define IPV4LL_STATE_RUNNING(ifp) (0)
-#define ipv4ll_free(a) {}
-#define ipv4ll_drop(a) {}
+#define        IPV4LL_STATE_RUNNING(ifp)       (0)
+#define        ipv4ll_subnet_route(ifp)        (NULL)
+#define        ipv4ll_default_route(ifp)       (NULL)
+#define        ipv4ll_handlert(a, b, c)        (0)
+#define        ipv4ll_free(a)                  {}
+#define        ipv4ll_drop(a)                  {}
 #endif
 
 #endif
index 5b60d3077347161ecae99bec7498a8babb19998f..c5c09f68e06958a1313a34a1dccf9bb53165248b 100644 (file)
--- a/script.c
+++ b/script.c
@@ -236,8 +236,10 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
 #ifdef INET
        int dhcp, ipv4ll;
        const struct dhcp_state *state;
+#ifdef IPV4LL
        const struct ipv4ll_state *istate;
 #endif
+#endif
 #ifdef INET6
        const struct dhcp6_state *d6_state;
        int static6, dhcp6, ra;
@@ -246,8 +248,10 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
 #ifdef INET
        dhcp = ipv4ll = 0;
        state = D_STATE(ifp);
+#ifdef IPV4LL
        istate = IPV4LL_CSTATE(ifp);
 #endif
+#endif
 #ifdef INET6
        static6 = dhcp6 = ra = 0;
        d6_state = D6_CSTATE(ifp);
@@ -261,8 +265,10 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
                        ra = 1;
 #endif
 #ifdef INET
+#ifdef IPV4LL
                else if (istate && istate->addr != NULL)
                        ipv4ll = 1;
+#endif
                else
                        dhcp = 1;
 #endif
@@ -285,8 +291,10 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
                /* This space left intentionally blank */
        }
 #ifdef INET
+#ifdef IPV4LL
        else if (strcmp(reason, "IPV4LL") == 0)
                ipv4ll = 1;
+#endif
        else
                dhcp = 1;
 #endif
@@ -359,8 +367,10 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
        } else if (1 == 2 /* appease ifdefs */
 #ifdef INET
            || (dhcp && state && state->new)
+#ifdef IPV4LL
            || (ipv4ll && IPV4LL_STATE_RUNNING(ifp))
 #endif
+#endif
 #ifdef INET6
            || (static6 && IPV6_STATE_RUNNING(ifp))
            || (dhcp6 && d6_state && d6_state->new)
@@ -462,6 +472,7 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
 
 dumplease:
 #ifdef INET
+#ifdef IPV4LL
        if (ipv4ll) {
                n = ipv4ll_env(NULL, NULL, ifp);
                if (n > 0) {
@@ -476,6 +487,7 @@ dumplease:
                        elen += (size_t)n;
                }
        }
+#endif
        if (dhcp && state && state->new) {
                n = dhcp_env(NULL, NULL, state->new, state->new_len, ifp);
                if (n > 0) {
@@ -631,11 +643,13 @@ send_interface(struct fd_list *fd, const struct interface *ifp)
                if (send_interface1(fd, ifp, d->reason) == -1)
                        retval = -1;
        }
+#ifdef IPV4LL
        if (IPV4LL_STATE_RUNNING(ifp)) {
                if (send_interface1(fd, ifp, "IPV4LL") == -1)
                        retval = -1;
        }
 #endif
+#endif
 
 #ifdef INET6
        if (IPV6_STATE_RUNNING(ifp)) {