[PATCH] VM: add page_state info to per-node meminfo
[linux-ginger.git] / net / bridge / netfilter / ebtable_broute.c
blob1767c94cd3ded62edad7968037a4aa69d8dc0064
1 /*
2 * ebtable_broute
4 * Authors:
5 * Bart De Schuymer <bdschuym@pandora.be>
7 * April, 2002
9 * This table lets you choose between routing and bridging for frames
10 * entering on a bridge enslaved nic. This table is traversed before any
11 * other ebtables table. See net/bridge/br_input.c.
14 #include <linux/netfilter_bridge/ebtables.h>
15 #include <linux/module.h>
16 #include <linux/if_bridge.h>
18 /* EBT_ACCEPT means the frame will be bridged
19 * EBT_DROP means the frame will be routed
21 static struct ebt_entries initial_chain = {
22 .name = "BROUTING",
23 .policy = EBT_ACCEPT,
26 static struct ebt_replace initial_table =
28 .name = "broute",
29 .valid_hooks = 1 << NF_BR_BROUTING,
30 .entries_size = sizeof(struct ebt_entries),
31 .hook_entry = {
32 [NF_BR_BROUTING] = &initial_chain,
34 .entries = (char *)&initial_chain,
37 static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
39 if (valid_hooks & ~(1 << NF_BR_BROUTING))
40 return -EINVAL;
41 return 0;
44 static struct ebt_table broute_table =
46 .name = "broute",
47 .table = &initial_table,
48 .valid_hooks = 1 << NF_BR_BROUTING,
49 .lock = RW_LOCK_UNLOCKED,
50 .check = check,
51 .me = THIS_MODULE,
54 static int ebt_broute(struct sk_buff **pskb)
56 int ret;
58 ret = ebt_do_table(NF_BR_BROUTING, pskb, (*pskb)->dev, NULL,
59 &broute_table);
60 if (ret == NF_DROP)
61 return 1; /* route it */
62 return 0; /* bridge it */
65 static int __init init(void)
67 int ret;
69 ret = ebt_register_table(&broute_table);
70 if (ret < 0)
71 return ret;
72 /* see br_input.c */
73 br_should_route_hook = ebt_broute;
74 return ret;
77 static void __exit fini(void)
79 br_should_route_hook = NULL;
80 synchronize_net();
81 ebt_unregister_table(&broute_table);
84 module_init(init);
85 module_exit(fini);
86 MODULE_LICENSE("GPL");