changeset 4173:e336de0ca5ae draft

bpf: remove the BPF_FREE flag ARP code can just try and free the istate if no astates left after finishing the read loop.
author Roy Marples <roy@marples.name>
date Wed, 25 Oct 2017 09:15:10 +0100
parents 9298bf22c505
children 79133872da0b
files src/arp.c src/bpf.h
diffstat 2 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/arp.c	Wed Oct 25 00:23:29 2017 +0100
+++ b/src/arp.c	Wed Oct 25 09:15:10 2017 +0100
@@ -194,13 +194,12 @@
 	if (TAILQ_FIRST(&state->arp_states) == NULL) {
 		arp_close(ifp);
 		if (state->bpf_flags & BPF_READING)
-			state->bpf_flags |= BPF_EOF | BPF_FREE;
+			state->bpf_flags |= BPF_EOF;
 		else {
 			free(state);
 			ifp->if_data[IF_DATA_ARP] = NULL;
 		}
 	} else {
-		state->bpf_flags &= BPF_FREE;
 		if (bpf_arp(ifp, state->bpf_fd) == -1)
 			logerr(__func__);
 	}
@@ -235,8 +234,8 @@
 	}
 	if (state != NULL) {
 		state->bpf_flags &= ~BPF_READING;
-		if (state->bpf_flags & BPF_FREE)
-			arp_tryfree(ifp);
+		/* Try and free the state if nothing left to do. */
+		arp_tryfree(ifp);
 	}
 }
 
--- a/src/bpf.h	Wed Oct 25 00:23:29 2017 +0100
+++ b/src/bpf.h	Wed Oct 25 09:15:10 2017 +0100
@@ -28,10 +28,9 @@
 #ifndef BPF_HEADER
 #define BPF_HEADER
 
-#define	BPF_EOF			(1U << 0)
-#define	BPF_PARTIALCSUM		(1U << 1)
-#define	BPF_READING		(1U << 2)
-#define	BPF_FREE		(1U << 3)
+#define	BPF_READING		(1U << 0)
+#define	BPF_EOF			(1U << 1)
+#define	BPF_PARTIALCSUM		(1U << 2)
 
 #include "dhcpcd.h"