]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
bpf: only interested in direct conflict (sender) or ARP probes.
authorRoy Marples <roy@marples.name>
Fri, 10 Mar 2017 08:36:26 +0000 (08:36 +0000)
committerRoy Marples <roy@marples.name>
Fri, 10 Mar 2017 08:36:26 +0000 (08:36 +0000)
bpf.c

diff --git a/bpf.c b/bpf.c
index c3e2ff58ad2111e50add553a613a06dcd299fbcc..73e83e28f0a542f77075b131cf859ab5c867ee9c 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -417,7 +417,7 @@ static const struct bpf_insn bpf_arp_filter [] = {
        BPF_STMT(BPF_RET + BPF_K, 0),
 };
 #define bpf_arp_filter_len     __arraycount(bpf_arp_filter)
-#define bpf_arp_extra          ((ARP_ADDRS_MAX * 2) * 2) + 2
+#define bpf_arp_extra          (((ARP_ADDRS_MAX + 1) * 2) * 2) + 2
 
 int
 bpf_arp(struct interface *ifp, int fd)
@@ -473,6 +473,13 @@ bpf_arp(struct interface *ifp, int fd)
                        bp++;
                }
 
+               /* If we didn't match sender, then we're only interested in
+                * ARP probes to us, so check the null host sender. */
+               BPF_SET_JUMP(bp, BPF_JMP + BPF_JEQ + BPF_K, INADDR_ANY, 1, 0);
+               bp++;
+               BPF_SET_STMT(bp, BPF_RET + BPF_K, 0);
+               bp++;
+
                /* Match target protocol address */
                BPF_SET_STMT(bp, BPF_LD + BPF_W + BPF_IND,
                             (sizeof(struct arphdr)