From: Roy Marples Date: Mon, 1 Jun 2026 20:20:01 +0000 (+0100) Subject: BPF: Improve headers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db3abc18ae1aee74c1ea5a56a474f5a825fe0168;p=thirdparty%2Fdhcpcd.git BPF: Improve headers --- diff --git a/src/bpf.c b/src/bpf.c index 78d99166..1dd6b220 100644 --- a/src/bpf.c +++ b/src/bpf.c @@ -34,21 +34,22 @@ #include #include +#include +#include +#include +#include +#include -#ifdef __linux__ -/* Special BPF snowflake. */ +#include "config.h" +#ifdef USE_LIBPCAP +#include +#elif defined(__linux__) #include #define bpf_insn sock_filter #else #include #endif -#include -#include -#include -#include -#include - #include "arp.h" #include "bpf.h" #include "common.h" @@ -268,7 +269,7 @@ static const struct bpf_insn bpf_arp_ether[] = { /* Make sure the hardware length matches. */ BPF_STMT(BPF_LD + BPF_B + BPF_IND, offsetof(struct arphdr, ar_hln)), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, - sizeof(((struct ether_arp *)0)->arp_sha), 1, 0), + sizeof(((struct ether_header *)0)->ether_shost), 1, 0), BPF_STMT(BPF_RET + BPF_K, 0), }; #define BPF_ARP_ETHER_LEN __arraycount(bpf_arp_ether) @@ -314,8 +315,10 @@ bpf_arp_rw(const struct bpf *bpf, const struct in_addr *ia, bool recv) case ARPHRD_ETHER: memcpy(bp, bpf_arp_ether, sizeof(bpf_arp_ether)); bp += BPF_ARP_ETHER_LEN; - arp_len = sizeof(struct ether_header) + - sizeof(struct ether_arp); + arp_len = sizeof(struct ether_header) + sizeof(struct arphdr) + + ((sizeof(((struct ether_header *)0)->ether_shost) + + sizeof(uint32_t)) * + 2); break; default: errno = EINVAL;