OSDN Git Service

netfilter: nf_tables: Add native tproxy support
authorMáté Eckl <ecklm94@gmail.com>
Mon, 30 Jul 2018 09:07:32 +0000 (11:07 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 30 Jul 2018 12:07:12 +0000 (14:07 +0200)
commit4ed8eb6570a49931c705512060acd50058d61616
treeb9fde5be65756cf54c8d7efccf5fc1d503ebe252
parentb96af92d6eaf9fadd77aa798c508a8a9d2e60020
netfilter: nf_tables: Add native tproxy support

A great portion of the code is taken from xt_TPROXY.c

There are some changes compared to the iptables implementation:
 - tproxy statement is not terminal here
 - Either address or port has to be specified, but at least one of them
   is necessary. If one of them is not specified, the evaluation will be
   performed with the original attribute of the packet (ie. target port
   is not specified => the packet's dport will be used).

To make this work in inet tables, the tproxy structure has a family
member (typically called priv->family) which is not necessarily equal to
ctx->family.

priv->family can have three values legally:
 - NFPROTO_IPV4 if the table family is ip OR if table family is inet,
   but an ipv4 address is specified as a target address. The rule only
   evaluates ipv4 packets in this case.
 - NFPROTO_IPV6 if the table family is ip6 OR if table family is inet,
   but an ipv6 address is specified as a target address. The rule only
   evaluates ipv6 packets in this case.
 - NFPROTO_UNSPEC if the table family is inet AND if only the port is
   specified. The rule will evaluate both ipv4 and ipv6 packets.

Signed-off-by: Máté Eckl <ecklm94@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/uapi/linux/netfilter/nf_tables.h
net/netfilter/Kconfig
net/netfilter/Makefile
net/netfilter/nft_tproxy.c [new file with mode: 0644]