]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix building with different options
authorRoy Marples <roy@marples.name>
Thu, 13 Feb 2025 11:05:10 +0000 (11:05 +0000)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 11:05:10 +0000 (11:05 +0000)
Fixes #458.

Add many build options to the NetBSD target
Set any warnings to be errors as NetBSD should build without
any warnings. DragonFly as well, but we don't have a target for that.

.github/workflows/build.yml
src/dhcp.c
src/if-options.c
src/ipv6.c
src/privsep-inet.c

index 3f4b166f0492efb960392e6241f8dbba26ca385d..aa290fa64c741c0f70d36790f79c61d359db604c 100644 (file)
@@ -20,7 +20,7 @@ jobs:
     - uses: actions/checkout@v2
     
     - name: Configure
-      run: ./configure --prefix=/usr
+      run: ./configure
 
     - name: Build
       run: make
@@ -44,9 +44,7 @@ jobs:
         git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
         cd build
         [ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
-        echo "configure"
-        ./configure --prefix=/usr
-        echo "building"
+        ./configure
         make
 
     - name: Tests
@@ -71,9 +69,7 @@ jobs:
         git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
         cd build
         [ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
-        echo "configure"
-        ./configure --prefix=/usr
-        echo "building"
+        ./configure
         make
 
     - name: Tests
@@ -82,6 +78,18 @@ jobs:
          make tests
 
   netbsd:
+    strategy:
+      matrix:
+        args:
+          -
+          - --disable-ipv4
+          - --disable-arp
+          - --disable-ipv4ll
+          - --disable-ipv6
+          - --disable-dhcp6
+        cppflags:
+          -
+          - -DSMALL
     runs-on: ubuntu-latest
     steps:
     - name: Bootstrap NetBSD-latest
@@ -94,9 +102,7 @@ jobs:
         git clone --depth=1 "${{ github.server_url }}/${{ github.repository }}" build
         cd build
         [ "${{ github.event.pull_request.number }}" = "" ] || (echo "fetching PR ${{ github.event.pull_request.number }}"; git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }} && git checkout "pr-${{ github.event.pull_request.number }}")
-        echo "configure"
-        ./configure --prefix=/usr
-        echo "building"
+        CFLAGS=-Werror CPPFLAGS="${{ matrix.cppflags }}" ./configure ${{ matrix.args }}
         make
 
     - name: Tests
index 504e013180f882154cf17e5ff953ac8abf6561bd..3b8f0198ef1dd41aa6d3f78d8a7a7f7d2a45e039 100644 (file)
@@ -3068,7 +3068,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
        struct dhcp_state *state = D_STATE(ifp);
        struct if_options *ifo = ifp->options;
        struct dhcp_lease *lease = &state->lease;
-       uint8_t type, tmp;
+       uint8_t type;
        struct in_addr addr;
        unsigned int i;
        char *msg;
@@ -3079,6 +3079,9 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
        const uint8_t *auth;
        size_t auth_len;
 #endif
+#ifdef IPV4LL
+       uint8_t tmp;
+#endif
 #ifdef IN_IFF_DUPLICATED
        struct ipv4_addr *ia;
 #endif
index faa22f90250d6fad7a63f6a61a038dcdb7b2f646..d931c36eaabe5ae90e9c0cc2c3fc50370de3f638 100644 (file)
@@ -650,13 +650,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
        ssize_t s;
        struct in_addr addr, addr2;
        in_addr_t *naddr;
-       struct rt *rt;
        const struct dhcp_opt *d, *od;
        uint8_t *request, *require, *no, *reject;
        struct dhcp_opt **dop, *ndop;
        size_t *dop_len, dl, odl;
-       struct vivco *vivco;
-       const struct vivco *vivco_endp = ifo->vivco + ifo->vivco_len;
        struct group *grp;
 #ifdef AUTH
        struct token *token;
@@ -664,17 +661,26 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
 #ifdef _REENTRANT
        struct group grpbuf;
 #endif
+#ifdef INET
+       struct rt *rt;
+#endif
 #ifdef DHCP6
-       size_t sl;
        struct if_ia *ia;
        uint8_t iaid[4];
+#endif
+#if defined(DHCP6) || ((defined(INET) || defined(INET6)) && !defined(SMALL))
+       size_t sl;
+#endif
 #ifndef SMALL
-       struct in6_addr in6addr;
+#ifdef DHCP6
        struct if_sla *sla, *slap;
+#endif
+       struct vivco *vivco;
+       const struct vivco *vivco_endp = ifo->vivco + ifo->vivco_len;
+       struct in6_addr in6addr;
        struct vsio **vsiop = NULL, *vsio;
        size_t *vsio_lenp = NULL, opt_max, opt_header;
        struct vsio_so *vsio_so;
-#endif
 #endif
 
        dop = NULL;
@@ -1308,6 +1314,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                    strncmp(arg, "ms_classless_static_routes=",
                        strlen("ms_classless_static_routes=")) == 0)
                {
+#ifdef INET
                        struct in_addr addr3;
 
                        if (p == NULL) {
@@ -1337,7 +1344,12 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        sa_in_init(&rt->rt_gateway, &addr3);
                        if (rt_proto_add_ctx(&ifo->routes, rt, ctx))
                                add_environ(&ifo->config, arg, 0);
+#else
+                       logerrx("no inet support for option: %s", arg);
+                       return -1;
+#endif
                } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
+#ifdef INET
                        if (p == NULL) {
                                rt_headclear(&ifo->routes, AF_INET);
                                add_environ(&ifo->config, arg, 1);
@@ -1353,6 +1365,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        sa_in_init(&rt->rt_gateway, &addr);
                        if (rt_proto_add_ctx(&ifo->routes, rt, ctx))
                                add_environ(&ifo->config, arg, 0);
+#else
+                       logerrx("no inet support for option: %s", arg);
+                       return -1;
+#endif
                } else if (strncmp(arg, "interface_mtu=",
                    strlen("interface_mtu=")) == 0 ||
                    strncmp(arg, "mtu=", strlen("mtu=")) == 0)
@@ -1366,6 +1382,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                return -1;
                        }
                } else if (strncmp(arg, "ip6_address=", strlen("ip6_address=")) == 0) {
+#ifdef INET6
                        if (p == NULL) {
                                memset(&ifo->req_addr6, 0,
                                    sizeof(ifo->req_addr6));
@@ -1396,6 +1413,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                    sizeof(ifo->req_addr6));
                                return -1;
                        }
+#else
+                       logerrx("no inet6 support for option: %s", arg);
+                       return -1;
+#endif
                } else
                        add_environ(&ifo->config, arg, p == NULL ? 1 : 0);
                break;
@@ -2951,11 +2972,11 @@ free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo)
        struct rt *rt;
 #endif
        struct dhcp_opt *opt;
-       struct vivco *vo;
 #ifdef AUTH
        struct token *token;
 #endif
 #ifndef SMALL
+       struct vivco *vo;
        struct vsio *vsio;
        struct vsio_so *vsio_so;
 #endif
index 5cb74151d11d8e6da5574ba56f502292c76f3b15..4561762b1e78a3f382d5a4d4608b2a69d350d126 100644 (file)
@@ -626,7 +626,7 @@ ipv6_deletedaddr(struct ipv6_addr *ia)
 #endif
 
 #if !defined(DHCP6) || (!defined(PRIVSEP) && defined(SMALL))
-       UNUSED(ia)
+       UNUSED(ia);
 #endif
 }
 
index 1f48033cec2f8f1c551e3c813e9d17dcc32461f9..ad30a5afb0d3536590d7ef35f25df711ace40122 100644 (file)
@@ -215,6 +215,7 @@ ps_inet_startcb(struct ps_process *psp)
        return ret;
 }
 
+#if defined(INET) || defined(DHCP6)
 static bool
 ps_inet_validudp(struct msghdr *msg, uint16_t sport, uint16_t dport)
 {
@@ -233,6 +234,7 @@ ps_inet_validudp(struct msghdr *msg, uint16_t sport, uint16_t dport)
        }
        return true;
 }
+#endif
 
 #ifdef INET6
 static bool