]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: xt_socket: add XT_SOCKET_RESTORESKMARK flag
authorHarout Hedeshian <harouth@codeaurora.org>
Tue, 16 Jun 2015 00:40:43 +0000 (18:40 -0600)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 18 Jun 2015 11:05:09 +0000 (13:05 +0200)
commit8282cd7689b5c19b490d2ace0958643b688a61be
tree7d8824df92301e6ffc19d9f3275afb0f32df7310
parentb47230a878d001c3bbb759465bde2924f7c608ac
netfilter: xt_socket: add XT_SOCKET_RESTORESKMARK flag

xt_socket is useful for matching sockets with IP_TRANSPARENT and
taking some action on the matching packets. However, it lacks the
ability to match only a small subset of transparent sockets.

Suppose there are 2 applications, each with its own set of transparent
sockets. The first application wants all matching packets dropped,
while the second application wants them forwarded somewhere else.

Add the ability to retore the skb->mark from the sk_mark. The mark
is only restored if a matching socket is found and the transparent /
nowildcard conditions are satisfied.

Now the 2 hypothetical applications can differentiate their sockets
based on a mark value set with SO_MARK.

iptables -t mangle -I PREROUTING -m socket --transparent \
                                           --restore-skmark -j action
iptables -t mangle -A action -m mark --mark 10 -j action2
iptables -t mangle -A action -m mark --mark 11 -j action3

Signed-off-by: Harout Hedeshian <harouth@codeaurora.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/uapi/linux/netfilter/xt_socket.h
net/netfilter/xt_socket.c