spi-topcliff-pch: Fix issue for transmitting over 4KByte
[zen-stable.git] / net / ipv4 / netfilter / arptable_filter.c
blob79ca5e70d49774e074613fe2c55cee941386542a
1 /*
2 * Filtering ARP tables module.
4 * Copyright (C) 2002 David S. Miller (davem@redhat.com)
6 */
8 #include <linux/module.h>
9 #include <linux/netfilter/x_tables.h>
10 #include <linux/netfilter_arp/arp_tables.h>
11 #include <linux/slab.h>
13 MODULE_LICENSE("GPL");
14 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
15 MODULE_DESCRIPTION("arptables filter table");
17 #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
18 (1 << NF_ARP_FORWARD))
20 static const struct xt_table packet_filter = {
21 .name = "filter",
22 .valid_hooks = FILTER_VALID_HOOKS,
23 .me = THIS_MODULE,
24 .af = NFPROTO_ARP,
25 .priority = NF_IP_PRI_FILTER,
28 /* The work comes in here from netfilter.c */
29 static unsigned int
30 arptable_filter_hook(unsigned int hook, struct sk_buff *skb,
31 const struct net_device *in, const struct net_device *out,
32 int (*okfn)(struct sk_buff *))
34 const struct net *net = dev_net((in != NULL) ? in : out);
36 return arpt_do_table(skb, hook, in, out, net->ipv4.arptable_filter);
39 static struct nf_hook_ops *arpfilter_ops __read_mostly;
41 static int __net_init arptable_filter_net_init(struct net *net)
43 struct arpt_replace *repl;
45 repl = arpt_alloc_initial_table(&packet_filter);
46 if (repl == NULL)
47 return -ENOMEM;
48 net->ipv4.arptable_filter =
49 arpt_register_table(net, &packet_filter, repl);
50 kfree(repl);
51 if (IS_ERR(net->ipv4.arptable_filter))
52 return PTR_ERR(net->ipv4.arptable_filter);
53 return 0;
56 static void __net_exit arptable_filter_net_exit(struct net *net)
58 arpt_unregister_table(net->ipv4.arptable_filter);
61 static struct pernet_operations arptable_filter_net_ops = {
62 .init = arptable_filter_net_init,
63 .exit = arptable_filter_net_exit,
66 static int __init arptable_filter_init(void)
68 int ret;
70 ret = register_pernet_subsys(&arptable_filter_net_ops);
71 if (ret < 0)
72 return ret;
74 arpfilter_ops = xt_hook_link(&packet_filter, arptable_filter_hook);
75 if (IS_ERR(arpfilter_ops)) {
76 ret = PTR_ERR(arpfilter_ops);
77 goto cleanup_table;
79 return ret;
81 cleanup_table:
82 unregister_pernet_subsys(&arptable_filter_net_ops);
83 return ret;
86 static void __exit arptable_filter_fini(void)
88 xt_hook_unlink(&packet_filter, arpfilter_ops);
89 unregister_pernet_subsys(&arptable_filter_net_ops);
92 module_init(arptable_filter_init);
93 module_exit(arptable_filter_fini);