2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-10-08 09:35:12 +00:00
|
|
|
/*
|
|
|
|
* Transparent proxy support for Linux/iptables
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2008 BalaBit IT Ltd.
|
|
|
|
* Author: Krisztian Kovacs
|
|
|
|
*/
|
2010-03-19 20:08:16 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
2008-10-08 09:35:12 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netfilter/x_tables.h>
|
|
|
|
#include <linux/netfilter_ipv4/ip_tables.h>
|
|
|
|
#include <net/tcp.h>
|
|
|
|
#include <net/udp.h>
|
|
|
|
#include <net/icmp.h>
|
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/inet_sock.h>
|
|
|
|
#include <net/netfilter/ipv4/nf_defrag_ipv4.h>
|
2010-10-24 23:38:32 +00:00
|
|
|
|
2011-12-12 02:58:24 +00:00
|
|
|
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
|
2010-10-24 23:38:32 +00:00
|
|
|
#include <linux/netfilter_ipv6/ip6_tables.h>
|
2013-07-29 13:41:53 +00:00
|
|
|
#include <net/inet6_hashtables.h>
|
2010-10-21 14:19:42 +00:00
|
|
|
#include <net/netfilter/ipv6/nf_defrag_ipv6.h>
|
2010-10-24 23:38:32 +00:00
|
|
|
#endif
|
2008-10-08 09:35:12 +00:00
|
|
|
|
2016-10-27 18:49:48 +00:00
|
|
|
#include <net/netfilter/nf_socket.h>
|
2009-06-09 13:16:34 +00:00
|
|
|
#include <linux/netfilter/xt_socket.h>
|
|
|
|
|
2013-07-29 13:41:53 +00:00
|
|
|
/* "socket" match based redirection (no specific rule)
|
|
|
|
* ===================================================
|
|
|
|
*
|
|
|
|
* There are connections with dynamic endpoints (e.g. FTP data
|
|
|
|
* connection) that the user is unable to add explicit rules
|
|
|
|
* for. These are taken care of by a generic "socket" rule. It is
|
|
|
|
* assumed that the proxy application is trusted to open such
|
|
|
|
* connections without explicit iptables rule (except of course the
|
|
|
|
* generic 'socket' rule). In this case the following sockets are
|
|
|
|
* matched in preference order:
|
|
|
|
*
|
|
|
|
* - match: if there's a fully established connection matching the
|
|
|
|
* _packet_ tuple
|
|
|
|
*
|
|
|
|
* - match: if there's a non-zero bound listener (possibly with a
|
|
|
|
* non-local address) We don't accept zero-bound listeners, since
|
|
|
|
* then local services could intercept traffic going through the
|
|
|
|
* box.
|
|
|
|
*/
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
static bool
|
|
|
|
socket_match(const struct sk_buff *skb, struct xt_action_param *par,
|
|
|
|
const struct xt_socket_mtinfo1 *info)
|
|
|
|
{
|
2015-06-16 00:40:43 +00:00
|
|
|
struct sk_buff *pskb = (struct sk_buff *)skb;
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
struct sock *sk = skb->sk;
|
|
|
|
|
2018-09-27 22:36:28 +00:00
|
|
|
if (sk && !net_eq(xt_net(par), sock_net(sk)))
|
2018-06-27 13:34:25 +00:00
|
|
|
sk = NULL;
|
|
|
|
|
2013-05-22 11:01:06 +00:00
|
|
|
if (!sk)
|
2016-11-03 09:56:21 +00:00
|
|
|
sk = nf_sk_lookup_slow_v4(xt_net(par), skb, xt_in(par));
|
2018-06-27 13:34:25 +00:00
|
|
|
|
2013-05-22 11:01:06 +00:00
|
|
|
if (sk) {
|
2009-06-09 13:16:34 +00:00
|
|
|
bool wildcard;
|
|
|
|
bool transparent = true;
|
|
|
|
|
2013-06-20 12:52:22 +00:00
|
|
|
/* Ignore sockets listening on INADDR_ANY,
|
|
|
|
* unless XT_SOCKET_NOWILDCARD is set
|
|
|
|
*/
|
|
|
|
wildcard = (!(info->flags & XT_SOCKET_NOWILDCARD) &&
|
2015-03-17 04:06:17 +00:00
|
|
|
sk_fullsock(sk) &&
|
2009-10-15 06:30:45 +00:00
|
|
|
inet_sk(sk)->inet_rcv_saddr == 0);
|
2009-06-09 13:16:34 +00:00
|
|
|
|
|
|
|
/* Ignore non-transparent sockets,
|
2015-03-17 04:06:17 +00:00
|
|
|
* if XT_SOCKET_TRANSPARENT is used
|
|
|
|
*/
|
2013-07-12 02:22:19 +00:00
|
|
|
if (info->flags & XT_SOCKET_TRANSPARENT)
|
2018-06-01 12:54:07 +00:00
|
|
|
transparent = inet_sk_transparent(sk);
|
2008-10-08 09:35:12 +00:00
|
|
|
|
2015-06-16 00:40:43 +00:00
|
|
|
if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard &&
|
2017-09-22 01:01:36 +00:00
|
|
|
transparent && sk_fullsock(sk))
|
2015-06-16 00:40:43 +00:00
|
|
|
pskb->mark = sk->sk_mark;
|
|
|
|
|
2013-05-22 11:01:06 +00:00
|
|
|
if (sk != skb->sk)
|
2013-10-11 16:03:25 +00:00
|
|
|
sock_gen_put(sk);
|
2009-06-09 13:16:34 +00:00
|
|
|
|
|
|
|
if (wildcard || !transparent)
|
2008-10-08 09:35:12 +00:00
|
|
|
sk = NULL;
|
|
|
|
}
|
|
|
|
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
return sk != NULL;
|
2008-10-08 09:35:12 +00:00
|
|
|
}
|
|
|
|
|
2009-06-09 13:16:34 +00:00
|
|
|
static bool
|
2010-10-21 14:19:42 +00:00
|
|
|
socket_mt4_v0(const struct sk_buff *skb, struct xt_action_param *par)
|
2009-06-09 13:16:34 +00:00
|
|
|
{
|
2013-07-12 02:22:19 +00:00
|
|
|
static struct xt_socket_mtinfo1 xt_info_v0 = {
|
|
|
|
.flags = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
return socket_match(skb, par, &xt_info_v0);
|
2009-06-09 13:16:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2015-06-16 00:40:43 +00:00
|
|
|
socket_mt4_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par)
|
2009-06-09 13:16:34 +00:00
|
|
|
{
|
|
|
|
return socket_match(skb, par, par->matchinfo);
|
|
|
|
}
|
|
|
|
|
2016-10-27 18:49:48 +00:00
|
|
|
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
static bool
|
2015-06-16 00:40:43 +00:00
|
|
|
socket_mt6_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par)
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
{
|
|
|
|
const struct xt_socket_mtinfo1 *info = (struct xt_socket_mtinfo1 *) par->matchinfo;
|
2015-06-16 00:40:43 +00:00
|
|
|
struct sk_buff *pskb = (struct sk_buff *)skb;
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
struct sock *sk = skb->sk;
|
|
|
|
|
2018-09-27 22:36:28 +00:00
|
|
|
if (sk && !net_eq(xt_net(par), sock_net(sk)))
|
2018-06-27 13:34:25 +00:00
|
|
|
sk = NULL;
|
|
|
|
|
2013-05-22 11:01:06 +00:00
|
|
|
if (!sk)
|
2016-11-03 09:56:21 +00:00
|
|
|
sk = nf_sk_lookup_slow_v6(xt_net(par), skb, xt_in(par));
|
2018-06-27 13:34:25 +00:00
|
|
|
|
2013-05-22 11:01:06 +00:00
|
|
|
if (sk) {
|
2010-10-21 14:19:42 +00:00
|
|
|
bool wildcard;
|
|
|
|
bool transparent = true;
|
|
|
|
|
2013-06-20 12:52:22 +00:00
|
|
|
/* Ignore sockets listening on INADDR_ANY
|
|
|
|
* unless XT_SOCKET_NOWILDCARD is set
|
|
|
|
*/
|
|
|
|
wildcard = (!(info->flags & XT_SOCKET_NOWILDCARD) &&
|
2015-03-17 04:06:17 +00:00
|
|
|
sk_fullsock(sk) &&
|
ipv6: make lookups simpler and faster
TCP listener refactoring, part 4 :
To speed up inet lookups, we moved IPv4 addresses from inet to struct
sock_common
Now is time to do the same for IPv6, because it permits us to have fast
lookups for all kind of sockets, including upcoming SYN_RECV.
Getting IPv6 addresses in TCP lookups currently requires two extra cache
lines, plus a dereference (and memory stall).
inet6_sk(sk) does the dereference of inet_sk(__sk)->pinet6
This patch is way bigger than its IPv4 counter part, because for IPv4,
we could add aliases (inet_daddr, inet_rcv_saddr), while on IPv6,
it's not doable easily.
inet6_sk(sk)->daddr becomes sk->sk_v6_daddr
inet6_sk(sk)->rcv_saddr becomes sk->sk_v6_rcv_saddr
And timewait socket also have tw->tw_v6_daddr & tw->tw_v6_rcv_saddr
at the same offset.
We get rid of INET6_TW_MATCH() as INET6_MATCH() is now the generic
macro.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-10-03 22:42:29 +00:00
|
|
|
ipv6_addr_any(&sk->sk_v6_rcv_saddr));
|
2010-10-21 14:19:42 +00:00
|
|
|
|
|
|
|
/* Ignore non-transparent sockets,
|
2015-03-17 04:06:17 +00:00
|
|
|
* if XT_SOCKET_TRANSPARENT is used
|
|
|
|
*/
|
2013-07-12 02:22:19 +00:00
|
|
|
if (info->flags & XT_SOCKET_TRANSPARENT)
|
2018-06-01 12:54:07 +00:00
|
|
|
transparent = inet_sk_transparent(sk);
|
2010-10-21 14:19:42 +00:00
|
|
|
|
2015-06-16 00:40:43 +00:00
|
|
|
if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard &&
|
2017-09-22 01:01:36 +00:00
|
|
|
transparent && sk_fullsock(sk))
|
2015-06-16 00:40:43 +00:00
|
|
|
pskb->mark = sk->sk_mark;
|
|
|
|
|
2013-05-22 11:01:06 +00:00
|
|
|
if (sk != skb->sk)
|
2013-10-11 16:03:25 +00:00
|
|
|
sock_gen_put(sk);
|
2010-10-21 14:19:42 +00:00
|
|
|
|
|
|
|
if (wildcard || !transparent)
|
|
|
|
sk = NULL;
|
|
|
|
}
|
|
|
|
|
netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match
Currently in xt_socket, we take advantage of early demuxed sockets
since commit 00028aa37098 ("netfilter: xt_socket: use IP early demux")
in order to avoid a second socket lookup in the fast path, but we
only make partial use of this:
We still unnecessarily parse headers, extract proto, {s,d}addr and
{s,d}ports from the skb data, accessing possible conntrack information,
etc even though we were not even calling into the socket lookup via
xt_socket_get_sock_{v4,v6}() due to skb->sk hit, meaning those cycles
can be spared.
After this patch, we only proceed the slower, manual lookup path
when we have a skb->sk miss, thus time to match verdict for early
demuxed sockets will improve further, which might be i.e. interesting
for use cases such as mentioned in 681f130f39e1 ("netfilter: xt_socket:
add XT_SOCKET_NOWILDCARD flag").
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-04-02 12:28:30 +00:00
|
|
|
return sk != NULL;
|
2010-10-21 14:19:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-11-15 20:36:45 +00:00
|
|
|
static int socket_mt_enable_defrag(struct net *net, int family)
|
|
|
|
{
|
|
|
|
switch (family) {
|
|
|
|
case NFPROTO_IPV4:
|
|
|
|
return nf_defrag_ipv4_enable(net);
|
2017-04-18 17:39:58 +00:00
|
|
|
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
|
2016-11-15 20:36:45 +00:00
|
|
|
case NFPROTO_IPV6:
|
|
|
|
return nf_defrag_ipv6_enable(net);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
WARN_ONCE(1, "Unknown family %d\n", family);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-20 12:52:22 +00:00
|
|
|
static int socket_mt_v1_check(const struct xt_mtchk_param *par)
|
|
|
|
{
|
|
|
|
const struct xt_socket_mtinfo1 *info = (struct xt_socket_mtinfo1 *) par->matchinfo;
|
2016-11-15 20:36:45 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = socket_mt_enable_defrag(par->net, par->family);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2013-06-20 12:52:22 +00:00
|
|
|
|
|
|
|
if (info->flags & ~XT_SOCKET_FLAGS_V1) {
|
2018-02-09 14:52:07 +00:00
|
|
|
pr_info_ratelimited("unknown flags 0x%x\n",
|
|
|
|
info->flags & ~XT_SOCKET_FLAGS_V1);
|
2013-06-20 12:52:22 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int socket_mt_v2_check(const struct xt_mtchk_param *par)
|
|
|
|
{
|
|
|
|
const struct xt_socket_mtinfo2 *info = (struct xt_socket_mtinfo2 *) par->matchinfo;
|
2016-11-15 20:36:45 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = socket_mt_enable_defrag(par->net, par->family);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2013-06-20 12:52:22 +00:00
|
|
|
|
|
|
|
if (info->flags & ~XT_SOCKET_FLAGS_V2) {
|
2018-02-09 14:52:07 +00:00
|
|
|
pr_info_ratelimited("unknown flags 0x%x\n",
|
|
|
|
info->flags & ~XT_SOCKET_FLAGS_V2);
|
2013-06-20 12:52:22 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-16 00:40:43 +00:00
|
|
|
static int socket_mt_v3_check(const struct xt_mtchk_param *par)
|
|
|
|
{
|
|
|
|
const struct xt_socket_mtinfo3 *info =
|
|
|
|
(struct xt_socket_mtinfo3 *)par->matchinfo;
|
2016-11-15 20:36:45 +00:00
|
|
|
int err;
|
2015-06-16 00:40:43 +00:00
|
|
|
|
2016-11-15 20:36:45 +00:00
|
|
|
err = socket_mt_enable_defrag(par->net, par->family);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2015-06-16 00:40:43 +00:00
|
|
|
if (info->flags & ~XT_SOCKET_FLAGS_V3) {
|
2018-02-09 14:52:07 +00:00
|
|
|
pr_info_ratelimited("unknown flags 0x%x\n",
|
|
|
|
info->flags & ~XT_SOCKET_FLAGS_V3);
|
2015-06-16 00:40:43 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-09 13:16:34 +00:00
|
|
|
static struct xt_match socket_mt_reg[] __read_mostly = {
|
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 0,
|
|
|
|
.family = NFPROTO_IPV4,
|
2010-10-21 14:19:42 +00:00
|
|
|
.match = socket_mt4_v0,
|
2009-10-29 14:35:10 +00:00
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
2009-06-09 13:16:34 +00:00
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 1,
|
|
|
|
.family = NFPROTO_IPV4,
|
2015-06-16 00:40:43 +00:00
|
|
|
.match = socket_mt4_v1_v2_v3,
|
2013-06-20 12:52:22 +00:00
|
|
|
.checkentry = socket_mt_v1_check,
|
2009-06-09 13:16:34 +00:00
|
|
|
.matchsize = sizeof(struct xt_socket_mtinfo1),
|
2009-10-29 14:35:10 +00:00
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
2009-06-09 13:16:34 +00:00
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
2016-10-27 18:49:48 +00:00
|
|
|
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
|
2010-10-21 14:19:42 +00:00
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 1,
|
|
|
|
.family = NFPROTO_IPV6,
|
2015-06-16 00:40:43 +00:00
|
|
|
.match = socket_mt6_v1_v2_v3,
|
2013-06-20 12:52:22 +00:00
|
|
|
.checkentry = socket_mt_v1_check,
|
|
|
|
.matchsize = sizeof(struct xt_socket_mtinfo1),
|
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 2,
|
|
|
|
.family = NFPROTO_IPV4,
|
2015-06-16 00:40:43 +00:00
|
|
|
.match = socket_mt4_v1_v2_v3,
|
2013-06-20 12:52:22 +00:00
|
|
|
.checkentry = socket_mt_v2_check,
|
|
|
|
.matchsize = sizeof(struct xt_socket_mtinfo1),
|
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
2016-10-27 18:49:48 +00:00
|
|
|
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
|
2013-06-20 12:52:22 +00:00
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 2,
|
|
|
|
.family = NFPROTO_IPV6,
|
2015-06-16 00:40:43 +00:00
|
|
|
.match = socket_mt6_v1_v2_v3,
|
2013-06-20 12:52:22 +00:00
|
|
|
.checkentry = socket_mt_v2_check,
|
2010-10-21 14:19:42 +00:00
|
|
|
.matchsize = sizeof(struct xt_socket_mtinfo1),
|
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
2015-06-16 00:40:43 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 3,
|
|
|
|
.family = NFPROTO_IPV4,
|
|
|
|
.match = socket_mt4_v1_v2_v3,
|
|
|
|
.checkentry = socket_mt_v3_check,
|
|
|
|
.matchsize = sizeof(struct xt_socket_mtinfo1),
|
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
2016-10-27 18:49:48 +00:00
|
|
|
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
|
2015-06-16 00:40:43 +00:00
|
|
|
{
|
|
|
|
.name = "socket",
|
|
|
|
.revision = 3,
|
|
|
|
.family = NFPROTO_IPV6,
|
|
|
|
.match = socket_mt6_v1_v2_v3,
|
|
|
|
.checkentry = socket_mt_v3_check,
|
|
|
|
.matchsize = sizeof(struct xt_socket_mtinfo1),
|
|
|
|
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
|
|
|
(1 << NF_INET_LOCAL_IN),
|
|
|
|
.me = THIS_MODULE,
|
|
|
|
},
|
2010-10-21 14:19:42 +00:00
|
|
|
#endif
|
2008-10-08 09:35:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init socket_mt_init(void)
|
|
|
|
{
|
2009-06-09 13:16:34 +00:00
|
|
|
return xt_register_matches(socket_mt_reg, ARRAY_SIZE(socket_mt_reg));
|
2008-10-08 09:35:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit socket_mt_exit(void)
|
|
|
|
{
|
2009-06-09 13:16:34 +00:00
|
|
|
xt_unregister_matches(socket_mt_reg, ARRAY_SIZE(socket_mt_reg));
|
2008-10-08 09:35:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(socket_mt_init);
|
|
|
|
module_exit(socket_mt_exit);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Krisztian Kovacs, Balazs Scheidler");
|
|
|
|
MODULE_DESCRIPTION("x_tables socket match module");
|
|
|
|
MODULE_ALIAS("ipt_socket");
|
2010-10-21 14:19:42 +00:00
|
|
|
MODULE_ALIAS("ip6t_socket");
|