From: Patrick McHardy <kaber@trash.net>
To: KOVACS Krisztian <hidden@sch.bme.hu>
Cc: netfilter-devel@vger.kernel.org,
Balazs Scheidler <bazsi@balabit.hu>,
Toth Laszlo Attila <panther@balabit.hu>
Subject: Re: [PATCH 00/13] Transparent Proxying Patches, Take 3
Date: Mon, 01 Oct 2007 00:01:56 +0200 [thread overview]
Message-ID: <47001CD4.1040604@trash.net> (raw)
In-Reply-To: <20070930205141.10969.27205.stgit@nessa.odu>
KOVACS Krisztian wrote:
> Hi Patrick,
>
> These patches are our (Balazs, Attila and me) third try at providing Linux
> 2.2-like transparent proxying support for Linux 2.6. During the 5th Netfilter
> Workshop in Karlsruhe, Germany we tried to come up with an even more
> lightweight approach not requiring the modification of the IPv4 routing code at
> all.
>
> The most important changes relative to the previous versions[1,2] are:
> * the tproxy table is gone, TPROXY targets need to be added to the
> mangle table instead
> * the tproxy match is gone, a new "socket" match is introduced
> * instead of using a separate routing trick to divert packets to the
> local IP stack inside the TProxy target, we are now using stock routing
> decisions, and need a bit in the packet MARK field, and perform diversion by
> using an advanced routing rule (this hopefully makes it possible to
> implement IPv6 support in the future
> * instead of IP_FREEBIND we are using a setsockopt named IP_TRANSPARENT
> which requires CAP_NET_ADMIN privilege
> * in previous patches the output routing decision was commented out, it
> is now correctly decided whether a packet belongs to a tproxied
> connection or not.
>
> Usage is a bit more complicated compared to the previous approach, but it's
> certainly not rocket science:
>
> # iptables rules necessary:
> # create a chain named DIVERT
> iptables -t mangle -N DIVERT
> # everything that matches "-m socket" should go to the local stack
> iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
> # connections to be redirected should use the TPROXY target, which sets
> # up redirection, and marks the packet according to its 'tproxy-mark'
> # argument
> iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY \
> --tproxy-mark 0x1/0x1 --on-port 50080
> # DIVERT chain: mark packets and accept
> iptables -t mangle -A DIVERT -j MARK --set-mark 1
> iptables -t mangle -A DIVERT -j ACCEPT
>
> # set up advanced routing rules to deliver our marked packets locally
> ip rule add fwmark 1 lookup 100
> ip route add local 0.0.0.0/0 dev lo table 100
>
> The proxy code needs to be modified as well, but these are really lightweight:
> before binding, the IP_TRANSPARENT sockopt needs to be enabled on the socket.
> This implies IP_FREEBIND, so after enabling this socket option non-local binds
> will work and if you got your iptables/iproute setup right non-local traffic
> will be delivered to/from the socket. A netcat patch demonstrating this is
> available[4] as an example.
>
> Some word about the patches:
>
> * output path (patches 1-5): these modifications make it possible to
> output IPv4 datagrams with non-local IP addresses by:
> - introducing a new flowi flag (FLOWI_FLAG_ANYSRC) which disables the source
> address check in ip_route_output_slow() [3]
> - adding the IP_TRANSPARENT socket option (setting this requires CAP_NET_ADMIN)
> - setting FLOWI_FLAG_ANYSRC if IP_TRANSPARENT is enabled for the originating
> socket
> - set FLOWI_FLAG_ANYSRC where appropriate for sending reply packets
> generated by the kernel; this requires extending the ip_reply_arg
> structure with a flags field and adding an IP_REPLY_ARG_NOSRCCHECK flag
>
> * input patch (patches 6-13): these changes implement redirection support for
> TCP plus the iptables socket match and TPROXY target -- these provide the
> actual user interface:
> - split IPv4 defragmentation into a separate module, as this is needed by
> both our target and match
> - add a 'socket' match which does a socket lookup based on the destination
> tuple in the packet and matches is a socket has been found
> - add a 'TPROXY' target which looks up a socket based on a modified IP/port
> tuple and stores the socket reference in the skb
> - modifying the TCP/UDP input paths to use the stored socket reference if
> present
>
> All kinds of comments welcome. Patrick, I'd like to ask you to review these
> patches and if no issues are found by you or by anyone on the list, please
> consider merging them.
>
Thanks for posting these patches. I'll gladly review them, but
the patches touching things outside of netfilter need to go
through netdev and Dave for merging.
next prev parent reply other threads:[~2007-09-30 22:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-30 20:51 [PATCH 00/13] Transparent Proxying Patches, Take 3 KOVACS Krisztian
2007-09-30 20:51 ` [PATCH 01/13] Loosen source address check on IPv4 output KOVACS Krisztian
2007-09-30 22:12 ` Patrick McHardy
2007-09-30 20:52 ` [PATCH 02/13] Implement IP_TRANSPARENT socket option KOVACS Krisztian
2007-09-30 22:12 ` Patrick McHardy
2007-09-30 20:52 ` [PATCH 03/13] Allow binding to non-local addresses if IP_TRANSPARENT is set KOVACS Krisztian
2007-09-30 22:12 ` Patrick McHardy
2007-09-30 20:52 ` [PATCH 04/13] Conditionally enable transparent flow flag when connecting KOVACS Krisztian
2007-09-30 20:52 ` [PATCH 05/13] Handle TCP SYN+ACK/ACK/RST transparency KOVACS Krisztian
2007-09-30 21:45 ` Jan Engelhardt
2007-09-30 21:46 ` Jan Engelhardt
2007-09-30 21:59 ` KOVACS Krisztian
2007-09-30 22:02 ` Jan Engelhardt
2007-09-30 21:58 ` KOVACS Krisztian
2007-09-30 22:23 ` Patrick McHardy
2007-10-01 19:27 ` KOVACS Krisztian
2007-09-30 20:52 ` [PATCH 06/13] Port redirection support for TCP KOVACS Krisztian
2007-09-30 22:26 ` Patrick McHardy
2007-09-30 22:49 ` KOVACS Krisztian
2007-10-01 14:09 ` Patrick McHardy
2007-10-01 14:24 ` KOVACS Krisztian
2007-09-30 20:52 ` [PATCH 07/13] Export UDP socket lookup function KOVACS Krisztian
2007-09-30 20:53 ` [PATCH 08/13] Split Netfilter IPv4 defragmentation into a separate module KOVACS Krisztian
2007-09-30 22:35 ` Patrick McHardy
2007-09-30 20:53 ` [PATCH 09/13] iptables tproxy core KOVACS Krisztian
2007-09-30 22:37 ` Patrick McHardy
2007-09-30 20:53 ` [PATCH 10/13] iptables socket match KOVACS Krisztian
2007-09-30 21:43 ` Jan Engelhardt
2007-09-30 22:15 ` [PATCH 10/13] xt_socket Jan Engelhardt
2007-09-30 20:53 ` [PATCH 11/13] iptables TPROXY target KOVACS Krisztian
2007-09-30 21:40 ` [PATCH 11/13] xtables " Jan Engelhardt
2007-09-30 22:07 ` KOVACS Krisztian
2007-09-30 22:20 ` [PATCH 11/13] xt_TPROXY Jan Engelhardt
2007-09-30 23:04 ` KOVACS Krisztian
2007-09-30 22:43 ` [PATCH 11/13] iptables TPROXY target Patrick McHardy
2007-09-30 22:50 ` Jan Engelhardt
2007-09-30 22:51 ` KOVACS Krisztian
2007-09-30 22:56 ` Patrick McHardy
2007-09-30 23:06 ` KOVACS Krisztian
2007-09-30 22:57 ` Jan Engelhardt
2007-10-01 14:11 ` Patrick McHardy
2007-09-30 20:53 ` [PATCH 12/13] Don't lookup the socket if there's a socket attached to the skb KOVACS Krisztian
2007-09-30 20:53 ` [PATCH 13/13] " KOVACS Krisztian
2007-09-30 22:01 ` Patrick McHardy [this message]
2007-09-30 22:13 ` [PATCH 00/13] Transparent Proxying Patches, Take 3 KOVACS Krisztian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47001CD4.1040604@trash.net \
--to=kaber@trash.net \
--cc=bazsi@balabit.hu \
--cc=hidden@sch.bme.hu \
--cc=netfilter-devel@vger.kernel.org \
--cc=panther@balabit.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).