Skip to content

Commit

Permalink
Fix building with different options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rsmarples authored Feb 13, 2025
1 parent 4d583c4 commit 491cc3e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 19 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2

- name: Configure
run: ./configure --prefix=/usr
run: ./configure

- name: Build
run: make
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
35 changes: 28 additions & 7 deletions src/if-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,31 +650,37 @@ 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;
#endif
#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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ ipv6_deletedaddr(struct ipv6_addr *ia)
#endif

#if !defined(DHCP6) || (!defined(PRIVSEP) && defined(SMALL))
UNUSED(ia)
UNUSED(ia);
#endif
}

Expand Down
2 changes: 2 additions & 0 deletions src/privsep-inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -233,6 +234,7 @@ ps_inet_validudp(struct msghdr *msg, uint16_t sport, uint16_t dport)
}
return true;
}
#endif

#ifdef INET6
static bool
Expand Down

0 comments on commit 491cc3e

Please sign in to comment.