10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 #include <linux/if_arp.h>
13 #include <linux/module.h>
14 #include <linux/netfilter/x_tables.h>
15 #include <linux/netfilter_bridge/ebtables.h>
29 int key = ((
const unsigned char *)mac)[5];
31 memcpy(((
char *) cmp) + 2, mac, 6);
33 limit = wh->
table[key + 1];
35 for (i = start; i <
limit; i++) {
37 if (cmp[1] == p->
cmp[1] && cmp[0] == p->
cmp[0])
38 if (p->
ip == 0 || p->
ip == ip)
42 for (i = start; i <
limit; i++) {
44 if (cmp[1] == p->
cmp[1] && cmp[0] == p->
cmp[0])
57 for (i = 0; i < 256; i++) {
73 const struct iphdr *ih;
76 ih = skb_header_pointer(skb, 0,
sizeof(_iph), &_iph);
86 ah = skb_header_pointer(skb, 0,
sizeof(_arph), &_arph);
91 bp = skb_header_pointer(skb,
sizeof(
struct arphdr) +
101 static int get_ip_src(
const struct sk_buff *skb,
__be32 *addr)
104 const struct iphdr *ih;
107 ih = skb_header_pointer(skb, 0,
sizeof(_iph), &_iph);
117 ah = skb_header_pointer(skb, 0,
sizeof(_arph), &_arph);
122 bp = skb_header_pointer(skb,
sizeof(
struct arphdr) +
135 const char *dmac, *smac;
143 smac = eth_hdr(skb)->h_source;
144 if (get_ip_src(skb, &sip))
148 if (!ebt_mac_wormhash_contains(wh_src, smac, sip))
152 if (ebt_mac_wormhash_contains(wh_src, smac, sip))
158 dmac = eth_hdr(skb)->h_dest;
159 if (get_ip_dst(skb, &dip))
163 if (!ebt_mac_wormhash_contains(wh_dst, dmac, dip))
167 if (ebt_mac_wormhash_contains(wh_dst, dmac, dip))
190 pr_info(
"wrong size: %d against expected %d, rounded to %Zd\n",
195 if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
196 pr_info(
"dst integrity fail: %x\n", -err);
199 if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
200 pr_info(
"src integrity fail: %x\n", -err);
210 .match = ebt_among_mt,
211 .checkentry = ebt_among_mt_check,
216 static int __init ebt_among_init(
void)
221 static void __exit ebt_among_fini(
void)