NETFILTER: remove unnecessary goto statement for error recovery
[tomato.git] / release / src-rt / linux / linux-2.6 / net / ipv4 / netfilter / iptable_raw.c
blob9aca5badcb744613283c0382b54b3a4c24f07922
1 /*
2 * 'raw' table, which is the very first hooked in at PRE_ROUTING and LOCAL_OUT .
4 * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
5 */
6 #include <linux/module.h>
7 #include <linux/netfilter_ipv4/ip_tables.h>
8 #include <net/ip.h>
10 #define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT))
12 static struct
14 struct ipt_replace repl;
15 struct ipt_standard entries[2];
16 struct ipt_error term;
17 } initial_table __initdata = {
18 .repl = {
19 .name = "raw",
20 .valid_hooks = RAW_VALID_HOOKS,
21 .num_entries = 3,
22 .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error),
23 .hook_entry = {
24 [NF_IP_PRE_ROUTING] = 0,
25 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard)
27 .underflow = {
28 [NF_IP_PRE_ROUTING] = 0,
29 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard)
32 .entries = {
33 IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
34 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
36 .term = IPT_ERROR_INIT, /* ERROR */
39 static struct xt_table packet_raw = {
40 .name = "raw",
41 .valid_hooks = RAW_VALID_HOOKS,
42 .me = THIS_MODULE,
43 .af = AF_INET,
46 /* The work comes in here from netfilter.c. */
47 static unsigned int
48 ipt_hook(unsigned int hook,
49 struct sk_buff *skb,
50 const struct net_device *in,
51 const struct net_device *out,
52 int (*okfn)(struct sk_buff *))
54 return ipt_do_table(skb, hook, in, out, &packet_raw);
57 static unsigned int
58 ipt_local_hook(unsigned int hook,
59 struct sk_buff *skb,
60 const struct net_device *in,
61 const struct net_device *out,
62 int (*okfn)(struct sk_buff *))
64 /* root is playing with raw sockets. */
65 if (skb->len < sizeof(struct iphdr) ||
66 ip_hdrlen(skb) < sizeof(struct iphdr)) {
67 if (net_ratelimit())
68 printk("iptable_raw: ignoring short SOCK_RAW"
69 "packet.\n");
70 return NF_ACCEPT;
72 return ipt_do_table(skb, hook, in, out, &packet_raw);
75 /* 'raw' is the very first table. */
76 static struct nf_hook_ops ipt_ops[] = {
78 .hook = ipt_hook,
79 .pf = PF_INET,
80 .hooknum = NF_IP_PRE_ROUTING,
81 .priority = NF_IP_PRI_RAW,
82 .owner = THIS_MODULE,
85 .hook = ipt_local_hook,
86 .pf = PF_INET,
87 .hooknum = NF_IP_LOCAL_OUT,
88 .priority = NF_IP_PRI_RAW,
89 .owner = THIS_MODULE,
93 static int __init iptable_raw_init(void)
95 int ret;
97 /* Register table */
98 ret = ipt_register_table(&packet_raw, &initial_table.repl);
99 if (ret < 0)
100 return ret;
102 /* Register hooks */
103 ret = nf_register_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
104 if (ret < 0) {
105 ipt_unregister_table(&packet_raw);
108 return ret;
111 static void __exit iptable_raw_fini(void)
113 nf_unregister_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
114 ipt_unregister_table(&packet_raw);
117 module_init(iptable_raw_init);
118 module_exit(iptable_raw_fini);
119 MODULE_LICENSE("GPL");