From 43470308dc21f972c2c7688c6d47303698e3e9eb Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 23 Jan 2019 11:28:59 +0000 Subject: [PATCH] IPv4LL: Remove #defines for functions when IPv4LL is disabled This allows us to optimise the code better and hopefully become less error prone. --- src/dhcpcd.c | 2 ++ src/if.c | 2 ++ src/ipv4.c | 8 ++++++++ src/ipv4ll.h | 6 ------ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 6d99e379..9562af01 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1340,8 +1340,10 @@ dhcpcd_getinterfaces(void *arg) len++; if (D_STATE_RUNNING(ifp)) len++; +#ifdef IPV4LL if (IPV4LL_STATE_RUNNING(ifp)) len++; +#endif if (IPV6_STATE_RUNNING(ifp)) len++; if (RS_STATE_RUNNING(ifp)) diff --git a/src/if.c b/src/if.c index 2aa28190..fabf99f3 100644 --- a/src/if.c +++ b/src/if.c @@ -78,7 +78,9 @@ if_free(struct interface *ifp) if (ifp == NULL) return; +#ifdef IPV4LL ipv4ll_free(ifp); +#endif dhcp_free(ifp); ipv4_free(ifp); dhcp6_free(ifp); diff --git a/src/ipv4.c b/src/ipv4.c index 7d70825a..44f8a15d 100644 --- a/src/ipv4.c +++ b/src/ipv4.c @@ -200,8 +200,10 @@ ipv4_hasaddr(const struct interface *ifp) { const struct dhcp_state *dstate; +#ifdef IPV4LL if (IPV4LL_STATE_RUNNING(ifp)) return 1; +#endif dstate = D_CSTATE(ifp); return (dstate && @@ -425,20 +427,25 @@ bool inet_getroutes(struct dhcpcd_ctx *ctx, struct rt_head *routes) { struct interface *ifp; +#ifdef IPV4LL struct rt def; bool have_default; +#endif TAILQ_FOREACH(ifp, ctx->ifaces, next) { if (!ifp->active) continue; if (inet_dhcproutes(routes, ifp) == -1) return false; +#ifdef IPV4LL if (ipv4ll_subnetroute(routes, ifp) == -1) return false; +#endif if (inet_routerhostroute(routes, ifp) == -1) return false; } +#ifdef IPV4LL /* If there is no default route, see if we can use an IPv4LL one. */ memset(&def, 0, sizeof(def)); def.rt_dest.sa_family = AF_INET; @@ -450,6 +457,7 @@ inet_getroutes(struct dhcpcd_ctx *ctx, struct rt_head *routes) break; } } +#endif return true; } diff --git a/src/ipv4ll.h b/src/ipv4ll.h index 95a6a524..23fad1b1 100644 --- a/src/ipv4ll.h +++ b/src/ipv4ll.h @@ -71,12 +71,6 @@ int ipv4ll_recvrt(int, const struct rt *); void ipv4ll_reset(struct interface *); void ipv4ll_drop(struct interface *); void ipv4ll_free(struct interface *); -#else -#define IPV4LL_STATE_RUNNING(ifp) (0) -#define ipv4ll_subnetroute(route, ifp) (0) -#define ipv4ll_defaultroute(route, ifp) (0) -#define ipv4ll_handlert(a, b, c) (0) -#define ipv4ll_free(a) {} #endif #endif -- 2.47.2