Skip to content

Transparent Proxying Patches, Take 5

KOVACS Krisztian netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14Loosen source address check on IPv4 outputinclude/net/flow.h net/ipv4/route.c+14 -70 replies
2/14Implement IP_TRANSPARENT socket optioninclude/linux/in.h include/net/inet_sock.h include/net/inet_timewait_sock.h +3 more+18 -30 replies
3/14Allow binding to non-local addresses if IP_TRANSPARENT is setnet/ipv4/af_inet.c+1 -10 replies
4/14Conditionally enable transparent flow flag when connectinginclude/net/route.h+4 -00 replies
5/14Handle TCP SYN+ACK/ACK/RST transparencyinclude/net/inet_sock.h include/net/ip.h net/ipv4/inet_connection_sock.c +3 more+29 -50 replies
6/14Port redirection support for TCPinclude/net/inet_sock.h include/net/tcp.h net/ipv4/inet_connection_sock.c +2 more+6 -20 replies
7/14Export UDP socket lookup functioninclude/net/udp.h net/ipv4/udp.c+12 -00 replies
8/14Split Netfilter IPv4 defragmentation into a separate moduleinclude/net/netfilter/ipv4/nf_defrag_ipv4.h net/ipv4/netfilter/Kconfig net/ipv4/netfilter/Makefile +2 more+110 -530 replies
9/14iptables tproxy coreinclude/net/netfilter/nf_tproxy_core.h net/netfilter/Kconfig net/netfilter/Makefile +1 more+144 -00 replies
10/14iptables socket matchnet/netfilter/Kconfig net/netfilter/Makefile net/netfilter/xt_socket.c+114 -00 replies
11/14iptables TPROXY targetinclude/linux/netfilter/xt_TPROXY.h net/netfilter/Kconfig net/netfilter/Makefile +1 more+142 -00 replies
12/14Don't lookup the socket if there's a socket attached to the skbnet/ipv4/tcp_ipv4.c+8 -00 replies
13/14Don't lookup the socket if there's a socket attached to the skbnet/ipv4/udp.c+8 -00 replies
14/14Add documentationDocumentation/networking/tproxy.txt+62 -00 replies

Reviews trailers per patch

3 of 14 patches have a Reviewed-by or Acked-by.

PatchPatrick McHardy
1/14A-b
2/14A-b
3/14A-b
4/14
5/14
6/14
7/14
8/14
9/14
10/14
11/14
12/14
13/14
14/14

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/14] Transparent Proxying Patches, Take 5

Hi Dave,

This is the fifth round of transparent proxying patches following recent discussion on netfilter-devel [1,2].

The aim of the patchset is to make non-locally bound sockets work both for receiving and sending. The target is IPv4 TCP/UDP at the moment.

Speaking of the patches, there are two big parts:

* Output path (patches 1-6): these modifications make it possible to send IPv4 datagrams with non-local source IP address by:

- Introducing a new flowi flag (FLOWI_FLAG_ANYSRC) which disables source address checking in ip_route_output_slow(). This is also necessary for some of the tricks LVS does. [3]

- Adding the IP_TRANSPARENT socket option (setting this requires CAP_NET_ADMIN to prevent source address spoofing).

- Gluing these together across the TCP/UDP code.

* Input path (patches 7-13): these changes add redirection support for TCP along with an iptables target implementing NAT-less traffic interception, and an iptables match to make ahead-of-time socket lookups on PREROUTING. These combined with a set of iptables rules and policy routing make non-locally bound sockets work.

- Netfilter IPv4 defragmentation is split into a separate module. It's not particularly pretty but I see no other way of making sure the 'socket' match gets no fragmented IPv4 packets.

- The 'socket' iptables match does a socket lookup on the destination address and matches if a socket was found.

- The 'TPROXY' iptables target provides a way to intercept traffic without NAT -- it does an ahead-of-time socket lookup on the configured address and caches the socket reference in the skb.

- IPv4 TCP and UDP input path is modified to use this stored socket reference if it's present.

The last patch adds a short intro on how to use it. A trivial patch for netcat demonstrating the necessary modifications for proxies is available separately at [4].

References:
[1] http://marc.info/?l=netfilter-devel&m=119118672703285&w=2
[2] http://marc.info/?l=netfilter-devel&m=119135774918622&w=2
[3] http://marc.info/?l=linux-netdev&m=118065358510836&w=2
[4] http://people.netfilter.org/hidden/tproxy/netcat-ip_transparent-support.patch

Signature · 1 line
KOVACS Krisztian