Skip to content

Commit

Permalink
netfilter: tproxy: remove nf_tproxy_core, keep tw sk assigned to skb
Browse files Browse the repository at this point in the history
The module was "permanent", due to the special tproxy skb->destructor.
Nowadays we have tcp early demux and its sock_edemux destructor in
networking core which can be used instead.

Thanks to early demux changes the input path now also handles
"skb->sk is tw socket" correctly, so this no longer needs the special
handling introduced with commit d503b30
(netfilter: tproxy: do not assign timewait sockets to skb->sk).

Thus:
- move assign_sock function to where its needed
- don't prevent timewait sockets from being assigned to the skb
- remove nf_tproxy_core.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Jul 31, 2013
1 parent 957bec3 commit fd158d7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 89 deletions.
5 changes: 2 additions & 3 deletions Documentation/networking/tproxy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ Transparent proxy support
=========================

This feature adds Linux 2.2-like transparent proxy support to current kernels.
To use it, enable NETFILTER_TPROXY, the socket match and the TPROXY target in
your kernel config. You will need policy routing too, so be sure to enable that
as well.
To use it, enable the socket match and the TPROXY target in your kernel config.
You will need policy routing too, so be sure to enable that as well.


1. Making non-local sockets work
Expand Down
4 changes: 0 additions & 4 deletions include/net/netfilter/nf_tproxy_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,4 @@ nf_tproxy_get_sock_v6(struct net *net, const u8 protocol,
}
#endif

/* assign a socket to the skb -- consumes sk */
void
nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk);

#endif
22 changes: 5 additions & 17 deletions net/netfilter/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -410,20 +410,6 @@ config NF_NAT_TFTP

endif # NF_CONNTRACK

# transparent proxy support
config NETFILTER_TPROXY
tristate "Transparent proxying support"
depends on IP_NF_MANGLE
depends on NETFILTER_ADVANCED
help
This option enables transparent proxying support, that is,
support for handling non-locally bound IPv4 TCP and UDP sockets.
For it to work you will have to configure certain iptables rules
and use policy routing. For more information on how to set it up
see Documentation/networking/tproxy.txt.

To compile it as a module, choose M here. If unsure, say N.

config NETFILTER_XTABLES
tristate "Netfilter Xtables support (required for ip_tables)"
default m if NETFILTER_ADVANCED=n
Expand Down Expand Up @@ -720,17 +706,20 @@ config NETFILTER_XT_TARGET_TEE
this clone be rerouted to another nexthop.

config NETFILTER_XT_TARGET_TPROXY
tristate '"TPROXY" target support'
depends on NETFILTER_TPROXY
tristate '"TPROXY" target transparent proxying support'
depends on NETFILTER_XTABLES
depends on NETFILTER_ADVANCED
depends on IP_NF_MANGLE
select NF_DEFRAG_IPV4
select NF_DEFRAG_IPV6 if IP6_NF_IPTABLES
help
This option adds a `TPROXY' target, which is somewhat similar to
REDIRECT. It can only be used in the mangle table and is useful
to redirect traffic to a transparent proxy. It does _not_ depend
on Netfilter connection tracking and NAT, unlike REDIRECT.
For it to work you will have to configure certain iptables rules
and use policy routing. For more information on how to set it up
see Documentation/networking/tproxy.txt.

To compile it as a module, choose M here. If unsure, say N.

Expand Down Expand Up @@ -1180,7 +1169,6 @@ config NETFILTER_XT_MATCH_SCTP

config NETFILTER_XT_MATCH_SOCKET
tristate '"socket" match support'
depends on NETFILTER_TPROXY
depends on NETFILTER_XTABLES
depends on NETFILTER_ADVANCED
depends on !NF_CONNTRACK || NF_CONNTRACK
Expand Down
3 changes: 0 additions & 3 deletions net/netfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o
obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o

# transparent proxy support
obj-$(CONFIG_NETFILTER_TPROXY) += nf_tproxy_core.o

# generic X tables
obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o

Expand Down
62 changes: 0 additions & 62 deletions net/netfilter/nf_tproxy_core.c

This file was deleted.

9 changes: 9 additions & 0 deletions net/netfilter/xt_TPROXY.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ tproxy_handle_time_wait4(struct sk_buff *skb, __be32 laddr, __be16 lport,
return sk;
}

/* assign a socket to the skb -- consumes sk */
static void
nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
{
skb_orphan(skb);
skb->sk = sk;
skb->destructor = sock_edemux;
}

static unsigned int
tproxy_tg4(struct sk_buff *skb, __be32 laddr, __be16 lport,
u_int32_t mark_mask, u_int32_t mark_value)
Expand Down

0 comments on commit fd158d7

Please sign in to comment.