From 491cc3eebff53aab5e164bc73f66321a480557fa Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 13 Feb 2025 11:05:10 +0000 Subject: [PATCH] Fix building with different options 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 | 26 ++++++++++++++++---------- src/dhcp.c | 5 ++++- src/if-options.c | 35 ++++++++++++++++++++++++++++------- src/ipv6.c | 2 +- src/privsep-inet.c | 2 ++ 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f4b166f..aa290fa6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/src/dhcp.c b/src/dhcp.c index 504e0131..3b8f0198 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -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 diff --git a/src/if-options.c b/src/if-options.c index faa22f90..d931c36e 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -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 diff --git a/src/ipv6.c b/src/ipv6.c index 5cb74151..4561762b 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -626,7 +626,7 @@ ipv6_deletedaddr(struct ipv6_addr *ia) #endif #if !defined(DHCP6) || (!defined(PRIVSEP) && defined(SMALL)) - UNUSED(ia) + UNUSED(ia); #endif } diff --git a/src/privsep-inet.c b/src/privsep-inet.c index 1f48033c..ad30a5af 100644 --- a/src/privsep-inet.c +++ b/src/privsep-inet.c @@ -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 -- 2.47.2