blob: 474d621cbc2ea8f992eed715a033b2e77e5835d3 [file] [log] [blame]
KOVACS Krisztian9ad2d742008-10-08 11:35:12 +02001/*
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
KOVACS Krisztian9ad2d742008-10-08 11:35:12 +020013#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
KOVACS Krisztian9ad2d742008-10-08 11:35:12 +020021
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)
Florian Westphald503b302011-02-17 11:32:38 +010031 sock_put(sk);
KOVACS Krisztian9ad2d742008-10-08 11:35:12 +020032}
33
34/* consumes sk */
Florian Westphald503b302011-02-17 11:32:38 +010035void
KOVACS Krisztian9ad2d742008-10-08 11:35:12 +020036nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
37{
Florian Westphald503b302011-02-17 11:32:38 +010038 /* assigning tw sockets complicates things; most
39 * skb->sk->X checks would have to test sk->sk_state first */
40 if (sk->sk_state == TCP_TIME_WAIT) {
41 inet_twsk_put(inet_twsk(sk));
42 return;
43 }
Eric Dumazetd485d502010-09-21 21:17:29 +000044
Florian Westphald503b302011-02-17 11:32:38 +010045 skb_orphan(skb);
46 skb->sk = sk;
47 skb->destructor = nf_tproxy_destructor;
KOVACS Krisztian9ad2d742008-10-08 11:35:12 +020048}
49EXPORT_SYMBOL_GPL(nf_tproxy_assign_sock);
50
51static int __init nf_tproxy_init(void)
52{
53 pr_info("NF_TPROXY: Transparent proxy support initialized, version 4.1.0\n");
54 pr_info("NF_TPROXY: Copyright (c) 2006-2007 BalaBit IT Ltd.\n");
55 return 0;
56}
57
58module_init(nf_tproxy_init);
59
60MODULE_LICENSE("GPL");
61MODULE_AUTHOR("Krisztian Kovacs");
62MODULE_DESCRIPTION("Transparent proxy support core routines");