]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/netfilter/nf_tproxy_core.c
scm: lower SCM_MAX_FD
[net-next-2.6.git] / net / netfilter / nf_tproxy_core.c
CommitLineData
9ad2d745
KK
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
9ad2d745
KK
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
9ad2d745
KK
21
22static void
23nf_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 */
35int
36nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
37{
d485d500
ED
38 bool transparent = (sk->sk_state == TCP_TIME_WAIT) ?
39 inet_twsk(sk)->tw_transparent :
40 inet_sk(sk)->transparent;
41
42 if (transparent) {
9a279bcb 43 skb_orphan(skb);
9ad2d745
KK
44 skb->sk = sk;
45 skb->destructor = nf_tproxy_destructor;
46 return 1;
47 } else
48 nf_tproxy_put_sock(sk);
49
50 return 0;
51}
52EXPORT_SYMBOL_GPL(nf_tproxy_assign_sock);
53
54static int __init nf_tproxy_init(void)
55{
56 pr_info("NF_TPROXY: Transparent proxy support initialized, version 4.1.0\n");
57 pr_info("NF_TPROXY: Copyright (c) 2006-2007 BalaBit IT Ltd.\n");
58 return 0;
59}
60
61module_init(nf_tproxy_init);
62
63MODULE_LICENSE("GPL");
64MODULE_AUTHOR("Krisztian Kovacs");
65MODULE_DESCRIPTION("Transparent proxy support core routines");