Cache xtime every call to update_wall_time
[usb.git] / net / ipv4 / netfilter / arptable_filter.c
blob75c0230625331e91ac2ed5d28841072a24a8db33
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_arp/arp_tables.h>
11 MODULE_LICENSE("GPL");
12 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
13 MODULE_DESCRIPTION("arptables filter table");
15 #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
16 (1 << NF_ARP_FORWARD))
18 static struct
20 struct arpt_replace repl;
21 struct arpt_standard entries[3];
22 struct arpt_error term;
23 } initial_table __initdata = {
24 .repl = {
25 .name = "filter",
26 .valid_hooks = FILTER_VALID_HOOKS,
27 .num_entries = 4,
28 .size = sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error),
29 .hook_entry = {
30 [NF_ARP_IN] = 0,
31 [NF_ARP_OUT] = sizeof(struct arpt_standard),
32 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard),
34 .underflow = {
35 [NF_ARP_IN] = 0,
36 [NF_ARP_OUT] = sizeof(struct arpt_standard),
37 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard),
40 .entries = {
41 ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_IN */
42 ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_OUT */
43 ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_FORWARD */
45 .term = ARPT_ERROR_INIT,
48 static struct arpt_table packet_filter = {
49 .name = "filter",
50 .valid_hooks = FILTER_VALID_HOOKS,
51 .lock = RW_LOCK_UNLOCKED,
52 .private = NULL,
53 .me = THIS_MODULE,
54 .af = NF_ARP,
57 /* The work comes in here from netfilter.c */
58 static unsigned int arpt_hook(unsigned int hook,
59 struct sk_buff **pskb,
60 const struct net_device *in,
61 const struct net_device *out,
62 int (*okfn)(struct sk_buff *))
64 return arpt_do_table(pskb, hook, in, out, &packet_filter);
67 static struct nf_hook_ops arpt_ops[] = {
69 .hook = arpt_hook,
70 .owner = THIS_MODULE,
71 .pf = NF_ARP,
72 .hooknum = NF_ARP_IN,
75 .hook = arpt_hook,
76 .owner = THIS_MODULE,
77 .pf = NF_ARP,
78 .hooknum = NF_ARP_OUT,
81 .hook = arpt_hook,
82 .owner = THIS_MODULE,
83 .pf = NF_ARP,
84 .hooknum = NF_ARP_FORWARD,
88 static int __init arptable_filter_init(void)
90 int ret;
92 /* Register table */
93 ret = arpt_register_table(&packet_filter, &initial_table.repl);
94 if (ret < 0)
95 return ret;
97 ret = nf_register_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
98 if (ret < 0)
99 goto cleanup_table;
100 return ret;
102 cleanup_table:
103 arpt_unregister_table(&packet_filter);
104 return ret;
107 static void __exit arptable_filter_fini(void)
109 nf_unregister_hooks(arpt_ops, ARRAY_SIZE(arpt_ops));
110 arpt_unregister_table(&packet_filter);
113 module_init(arptable_filter_init);
114 module_exit(arptable_filter_fini);