changeset 5232:d09c879cc4d5 draft

Fix compile for prior on NetBSD
author Roy Marples <roy@marples.name>
date Tue, 19 May 2020 16:37:10 +0100
parents a2c342295221
children 6e39cfd0227b
files src/bpf.c src/dhcp.c src/if-bsd.c src/if.c
diffstat 4 files changed, 15 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/bpf.c	Tue May 19 16:19:05 2020 +0100
+++ b/src/bpf.c	Tue May 19 16:37:10 2020 +0100
@@ -162,8 +162,13 @@
 	int fd_opts;
 #endif
 
+	bpf = calloc(1, sizeof(*bpf));
+	if (bpf == NULL)
+		return NULL;
+	bpf->bpf_ifp = ifp;
+
 #ifdef _PATH_BPF
-	fd = open(_PATH_BPF, O_RDWR | O_NONBLOCK
+	bpf->bpf_fd = open(_PATH_BPF, O_RDWR | O_NONBLOCK
 #ifdef O_CLOEXEC
 		| O_CLOEXEC
 #endif
@@ -172,11 +177,6 @@
 	char device[32];
 	int n = 0;
 
-	bpf = calloc(1, sizeof(*bpf));
-	if (bpf == NULL)
-		return NULL;
-	bpf->bpf_ifp = ifp;
-
 	do {
 		snprintf(device, sizeof(device), "/dev/bpf%d", n++);
 		bpf->bpf_fd = open(device, O_RDWR | O_NONBLOCK
--- a/src/dhcp.c	Tue May 19 16:19:05 2020 +0100
+++ b/src/dhcp.c	Tue May 19 16:37:10 2020 +0100
@@ -2072,7 +2072,14 @@
 #endif
 
 #ifdef ARP
-#ifndef KERNEL_RFC5227
+#ifdef KERNEL_RFC5227
+static void
+dhcp_arp_announced(struct arp_state *state)
+{
+
+	arp_free(state);
+}
+#else
 static void
 dhcp_arp_defend_failed(struct arp_state *astate)
 {
@@ -2200,14 +2207,6 @@
 }
 #endif
 
-#ifdef KERNEL_RFC5227
-static void
-dhcp_arp_announced(struct arp_state *state)
-{
-
-	arp_free(state);
-}
-#endif /* KERNEL_RFC5227 */
 #endif /* ARP */
 
 void
--- a/src/if-bsd.c	Tue May 19 16:19:05 2020 +0100
+++ b/src/if-bsd.c	Tue May 19 16:37:10 2020 +0100
@@ -175,7 +175,7 @@
 #ifdef SO_RERROR
 	n = 1;
 	if (setsockopt(ctx->link_fd, SOL_SOCKET, SO_RERROR, &n,sizeof(n)) == -1)
-		goto errexit;
+		logerr("%s: SO_RERROR", __func__);
 #endif
 
 	/* Ignore our own route(4) messages.
--- a/src/if.c	Tue May 19 16:19:05 2020 +0100
+++ b/src/if.c	Tue May 19 16:37:10 2020 +0100
@@ -884,9 +884,6 @@
 #if !defined(HAVE_SOCK_CLOEXEC) || !defined(HAVE_SOCK_NONBLOCK)
 	int xflags, xtype = type;
 #endif
-#ifdef SO_RERROR
-	int on;
-#endif
 
 #ifndef HAVE_SOCK_CLOEXEC
 	if (xtype & SOCK_CLOEXEC)