]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Test for ETHERTYPE_IP as the protocol type in the ARP BPF filter.
authorRoy Marples <roy@marples.name>
Tue, 15 Dec 2015 14:45:55 +0000 (14:45 +0000)
committerRoy Marples <roy@marples.name>
Tue, 15 Dec 2015 14:45:55 +0000 (14:45 +0000)
arp.c
bpf-filter.h

diff --git a/arp.c b/arp.c
index b45201f1a7fafe9b5003f227c1a1bd771378e332..a52743314e0f779cb5aef327ab2d7fb72088c34a 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -146,15 +146,18 @@ arp_packet(void *arg)
                /* Families must match */
                if (ar.ar_hrd != htons(ifp->family))
                        continue;
+#if 0
+               /* These checks are enforced in the BPF filter. */
                /* Protocol must be IP. */
                if (ar.ar_pro != htons(ETHERTYPE_IP))
                        continue;
-               if (ar.ar_pln != sizeof(arm.sip.s_addr))
-                       continue;
                /* Only these types are recognised */
                if (ar.ar_op != htons(ARPOP_REPLY) &&
                    ar.ar_op != htons(ARPOP_REQUEST))
                        continue;
+#endif
+               if (ar.ar_pln != sizeof(arm.sip.s_addr))
+                       continue;
 
                /* Get pointers to the hardware addreses */
                hw_s = arp_buffer + sizeof(ar);
index de9b277e71f3c9fd554cb2ceb26dee358cd00f55..c8b027a4ed15e25ed35545f9bcf4cb1e80dc6d37 100644 (file)
@@ -34,8 +34,11 @@ static const struct bpf_insn arp_bpf_filter [] = {
 #ifndef BPF_SKIPTYPE
        /* Make sure this is an ARP packet... */
        BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
-       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_ARP, 0, 4),
+       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_ARP, 0, 6),
 #endif
+       /* Make sure this is for IP ... */
+       BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 16 + BPF_ETHCOOK),
+       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 4),
        /* Make sure this is an ARP REQUEST... */
        BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20 + BPF_ETHCOOK),
        BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REQUEST, 1, 0),