]> git.karo-electronics.de Git - mv-sheeva.git/blob - net/netfilter/nf_tproxy_core.c
tproxy: add lookup type checks for UDP in nf_tproxy_get_sock_v4()
[mv-sheeva.git] / net / netfilter / nf_tproxy_core.c
1 /*
2  * Transparent proxy support for Linux/iptables
3  *
4  * Copyright (c) 2006-2007 BalaBit IT Ltd.
5  * Author: Balazs Scheidler, Krisztian Kovacs
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  */
12
13 #include <linux/module.h>
14
15 #include <linux/net.h>
16 #include <linux/if.h>
17 #include <linux/netdevice.h>
18 #include <net/udp.h>
19 #include <net/netfilter/nf_tproxy_core.h>
20
21
22 static void
23 nf_tproxy_destructor(struct sk_buff *skb)
24 {
25         struct sock *sk = skb->sk;
26
27         skb->sk = NULL;
28         skb->destructor = NULL;
29
30         if (sk)
31                 nf_tproxy_put_sock(sk);
32 }
33
34 /* consumes sk */
35 int
36 nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
37 {
38         if (inet_sk(sk)->transparent) {
39                 skb_orphan(skb);
40                 skb->sk = sk;
41                 skb->destructor = nf_tproxy_destructor;
42                 return 1;
43         } else
44                 nf_tproxy_put_sock(sk);
45
46         return 0;
47 }
48 EXPORT_SYMBOL_GPL(nf_tproxy_assign_sock);
49
50 static int __init nf_tproxy_init(void)
51 {
52         pr_info("NF_TPROXY: Transparent proxy support initialized, version 4.1.0\n");
53         pr_info("NF_TPROXY: Copyright (c) 2006-2007 BalaBit IT Ltd.\n");
54         return 0;
55 }
56
57 module_init(nf_tproxy_init);
58
59 MODULE_LICENSE("GPL");
60 MODULE_AUTHOR("Krisztian Kovacs");
61 MODULE_DESCRIPTION("Transparent proxy support core routines");