NETFILTER: remove unnecessary goto statement for error recovery
[tomato.git] / release / src-rt / linux / linux-2.6 / net / ipv4 / netfilter / ipt_BCOUNT.c
blobd2ac17d433f1f2126c274ad750df946c73809f10
1 /*
3 BCOUNT target
4 Copyright (C) 2006 Jonathan Zarate
6 Licensed under GNU GPL v2 or later.
8 */
9 #include <linux/module.h>
10 #include <linux/skbuff.h>
11 #include <linux/version.h>
12 #include <linux/if_ether.h>
14 #include <net/netfilter/nf_conntrack.h>
15 #include <linux/netfilter_ipv4/ip_tables.h>
16 #include <linux/netfilter_ipv4/ipt_BCOUNT.h>
18 // #define DEBUG_BCOUNT
20 static unsigned int
21 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
22 target(struct sk_buff **pskb,
23 const struct net_device *in,
24 const struct net_device *out,
25 unsigned int hooknum,
26 const struct xt_target *target,
27 const void *targinfo)
28 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
29 target(struct sk_buff *skb,
30 const struct net_device *in,
31 const struct net_device *out,
32 unsigned int hooknum,
33 const struct xt_target *target,
34 const void *targinfo)
35 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) */
36 target(struct sk_buff *skb,
37 const struct xt_target_param *par)
38 #endif
40 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
41 struct sk_buff *skb = *pskb;
42 #endif
43 struct nf_conn *ct;
44 enum ip_conntrack_info ctinfo;
46 ct = nf_ct_get(skb, &ctinfo);
47 if (ct) {
48 ct->bcount += (skb)->len;
49 if (ct->bcount >= 0x0FFFFFFF) ct->bcount = 0x0FFFFFFF;
50 #ifdef DEBUG_BCOUNT
51 if (net_ratelimit())
52 printf(KERN_DEBUG "BCOUNT %lx %lx\n", (skb)->len, ct->bcount);
53 #endif
55 return IPT_CONTINUE;
58 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
59 static int
60 checkentry(const char *tablename,
61 const void *e,
62 const struct xt_target *target,
63 void *targinfo,
64 unsigned int hook_mask)
65 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
66 static bool
67 checkentry(const char *tablename,
68 const void *e,
69 const struct xt_target *target,
70 void *targinfo,
71 unsigned int hook_mask)
72 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) */
73 static bool
74 checkentry(const struct xt_tgchk_param *par)
75 #endif
77 return 1;
80 static struct ipt_target BCOUNT_target = {
81 .name = "BCOUNT",
82 .family = AF_INET,
83 .target = target,
84 .targetsize = sizeof(struct ipt_BCOUNT_target),
85 .checkentry = checkentry,
86 .me = THIS_MODULE,
89 static int __init init(void)
91 return xt_register_target(&BCOUNT_target);
94 static void __exit fini(void)
96 xt_unregister_target(&BCOUNT_target);
99 module_init(init);
100 module_exit(fini);
103 MODULE_AUTHOR("Jonathan Zarate");
104 MODULE_DESCRIPTION("BCOUNT target");
105 MODULE_LICENSE("GPL");