I am working on an iptables rule to match a range of MAC addresses from within the PREROUTING table; my implementation uses the BPF matching option from iptables-extensions. Here is an example of an expression that should match drop a MAC address of aa:bb:cc:dd:ee:ff, matching all bytes.
((ether[6:4] & 0xffffffff) = (0xaabbccdd & 0xffffffff)) && ((ether[10:2] & 0xffff) = (0xeeff & 0xffff))
Based on the output of tcpdump -nn, this expression seems to be correct.
When sent through tcpdump -ddd or the nfbpf_compile utility, the resulting bytecode is used to create an iptables rule.
iptables -t raw -A PREROUTING -i br0 -m bpf --bytecode "BYTECODE OUTPUT" -j DROP
My issue is that when this rule is made in the PREROUTING table (which needs to be done), packets are only infrequently dropped; most packets make it through the filter. If the rule is made in the INPUT table, packets seem to be blocked successfully.
Why is this happening?