2013-04-06 13:24:29 +00:00
|
|
|
/*
|
|
|
|
* Rusty Russell (C)2000 -- This code is GPL.
|
|
|
|
* Patrick McHardy (c) 2006-2012
|
|
|
|
*/
|
|
|
|
|
2005-08-10 03:21:49 +00:00
|
|
|
#include <linux/kernel.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-08-10 03:21:49 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netfilter.h>
|
2017-12-20 15:12:55 +00:00
|
|
|
#include <linux/netfilter_ipv4.h>
|
|
|
|
#include <linux/netfilter_ipv6.h>
|
2015-04-02 12:31:41 +00:00
|
|
|
#include <linux/netfilter_bridge.h>
|
2005-08-10 03:23:11 +00:00
|
|
|
#include <linux/seq_file.h>
|
2006-02-27 21:03:24 +00:00
|
|
|
#include <linux/rcupdate.h>
|
2005-08-10 03:21:49 +00:00
|
|
|
#include <net/protocol.h>
|
2007-12-05 09:24:48 +00:00
|
|
|
#include <net/netfilter/nf_queue.h>
|
2010-05-11 23:19:48 +00:00
|
|
|
#include <net/dst.h>
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
#include "nf_internals.h"
|
|
|
|
|
2021-08-05 10:02:43 +00:00
|
|
|
static const struct nf_queue_handler __rcu *nf_queue_handler;
|
|
|
|
|
2007-02-12 19:15:49 +00:00
|
|
|
/*
|
2012-11-23 06:22:21 +00:00
|
|
|
* Hook for nfnetlink_queue to register its queue handler.
|
|
|
|
* We do this so that most of the NFQUEUE code can be modular.
|
|
|
|
*
|
|
|
|
* Once the queue is registered it must reinject all packets it
|
|
|
|
* receives, no matter what.
|
2005-08-10 03:21:49 +00:00
|
|
|
*/
|
|
|
|
|
2021-08-05 10:02:43 +00:00
|
|
|
void nf_register_queue_handler(const struct nf_queue_handler *qh)
|
2007-02-12 19:15:49 +00:00
|
|
|
{
|
2012-11-23 06:22:21 +00:00
|
|
|
/* should never happen, we only have one queueing backend in kernel */
|
2021-08-05 10:02:43 +00:00
|
|
|
WARN_ON(rcu_access_pointer(nf_queue_handler));
|
|
|
|
rcu_assign_pointer(nf_queue_handler, qh);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(nf_register_queue_handler);
|
|
|
|
|
|
|
|
/* The caller must flush their queue before this */
|
2021-08-05 10:02:43 +00:00
|
|
|
void nf_unregister_queue_handler(void)
|
2005-08-10 03:21:49 +00:00
|
|
|
{
|
2021-08-05 10:02:43 +00:00
|
|
|
RCU_INIT_POINTER(nf_queue_handler, NULL);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(nf_unregister_queue_handler);
|
|
|
|
|
2022-02-25 13:02:41 +00:00
|
|
|
static void nf_queue_sock_put(struct sock *sk)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_INET
|
|
|
|
sock_gen_put(sk);
|
|
|
|
#else
|
|
|
|
sock_put(sk);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-03-27 02:24:46 +00:00
|
|
|
static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
|
2007-12-05 09:27:19 +00:00
|
|
|
{
|
2015-04-03 20:31:01 +00:00
|
|
|
struct nf_hook_state *state = &entry->state;
|
|
|
|
|
2007-12-05 09:27:19 +00:00
|
|
|
/* Release those devices we held, or Alexey will kill me. */
|
2021-08-05 11:55:27 +00:00
|
|
|
dev_put(state->in);
|
|
|
|
dev_put(state->out);
|
2015-04-06 02:19:00 +00:00
|
|
|
if (state->sk)
|
2022-02-25 13:02:41 +00:00
|
|
|
nf_queue_sock_put(state->sk);
|
2018-12-18 16:15:15 +00:00
|
|
|
|
2020-03-27 02:24:47 +00:00
|
|
|
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
2021-08-05 11:55:27 +00:00
|
|
|
dev_put(entry->physin);
|
|
|
|
dev_put(entry->physout);
|
2020-03-27 02:24:47 +00:00
|
|
|
#endif
|
2018-12-18 16:15:15 +00:00
|
|
|
}
|
2020-03-27 02:24:46 +00:00
|
|
|
|
|
|
|
void nf_queue_entry_free(struct nf_queue_entry *entry)
|
|
|
|
{
|
|
|
|
nf_queue_entry_release_refs(entry);
|
|
|
|
kfree(entry);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(nf_queue_entry_free);
|
2018-12-18 16:15:15 +00:00
|
|
|
|
2020-03-27 02:24:47 +00:00
|
|
|
static void __nf_queue_entry_init_physdevs(struct nf_queue_entry *entry)
|
2018-12-18 16:15:15 +00:00
|
|
|
{
|
2014-10-01 09:19:17 +00:00
|
|
|
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
2020-03-27 02:24:47 +00:00
|
|
|
const struct sk_buff *skb = entry->skb;
|
|
|
|
struct nf_bridge_info *nf_bridge;
|
2018-12-18 16:15:15 +00:00
|
|
|
|
2020-03-27 02:24:47 +00:00
|
|
|
nf_bridge = nf_bridge_info_get(skb);
|
2018-12-18 16:15:15 +00:00
|
|
|
if (nf_bridge) {
|
2020-03-27 02:24:47 +00:00
|
|
|
entry->physin = nf_bridge_get_physindev(skb);
|
|
|
|
entry->physout = nf_bridge_get_physoutdev(skb);
|
|
|
|
} else {
|
|
|
|
entry->physin = NULL;
|
|
|
|
entry->physout = NULL;
|
2007-12-05 09:27:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-19 04:58:23 +00:00
|
|
|
/* Bump dev refs so they don't vanish while packet is out */
|
2022-02-28 05:22:22 +00:00
|
|
|
bool nf_queue_entry_get_refs(struct nf_queue_entry *entry)
|
2013-04-19 04:58:23 +00:00
|
|
|
{
|
2015-04-03 20:31:01 +00:00
|
|
|
struct nf_hook_state *state = &entry->state;
|
|
|
|
|
2022-02-28 05:22:22 +00:00
|
|
|
if (state->sk && !refcount_inc_not_zero(&state->sk->sk_refcnt))
|
|
|
|
return false;
|
|
|
|
|
2021-08-05 11:55:27 +00:00
|
|
|
dev_hold(state->in);
|
|
|
|
dev_hold(state->out);
|
2013-04-19 04:58:23 +00:00
|
|
|
|
2020-03-27 02:24:47 +00:00
|
|
|
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
|
2021-08-05 11:55:27 +00:00
|
|
|
dev_hold(entry->physin);
|
|
|
|
dev_hold(entry->physout);
|
2020-03-27 02:24:47 +00:00
|
|
|
#endif
|
2022-02-28 05:22:22 +00:00
|
|
|
return true;
|
2013-04-19 04:58:23 +00:00
|
|
|
}
|
2013-04-19 04:58:25 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nf_queue_entry_get_refs);
|
2013-04-19 04:58:23 +00:00
|
|
|
|
2017-11-30 23:21:03 +00:00
|
|
|
void nf_queue_nf_hook_drop(struct net *net)
|
2015-06-19 19:03:39 +00:00
|
|
|
{
|
|
|
|
const struct nf_queue_handler *qh;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2021-08-05 10:02:43 +00:00
|
|
|
qh = rcu_dereference(nf_queue_handler);
|
2015-07-20 10:55:02 +00:00
|
|
|
if (qh)
|
2017-11-30 23:21:03 +00:00
|
|
|
qh->nf_hook_drop(net);
|
2015-06-19 19:03:39 +00:00
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
2017-07-25 22:02:33 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nf_queue_nf_hook_drop);
|
2015-06-19 19:03:39 +00:00
|
|
|
|
2017-12-20 15:12:55 +00:00
|
|
|
static void nf_ip_saveroute(const struct sk_buff *skb,
|
|
|
|
struct nf_queue_entry *entry)
|
|
|
|
{
|
|
|
|
struct ip_rt_info *rt_info = nf_queue_entry_reroute(entry);
|
|
|
|
|
|
|
|
if (entry->state.hook == NF_INET_LOCAL_OUT) {
|
|
|
|
const struct iphdr *iph = ip_hdr(skb);
|
|
|
|
|
|
|
|
rt_info->tos = iph->tos;
|
|
|
|
rt_info->daddr = iph->daddr;
|
|
|
|
rt_info->saddr = iph->saddr;
|
|
|
|
rt_info->mark = skb->mark;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nf_ip6_saveroute(const struct sk_buff *skb,
|
|
|
|
struct nf_queue_entry *entry)
|
|
|
|
{
|
|
|
|
struct ip6_rt_info *rt_info = nf_queue_entry_reroute(entry);
|
|
|
|
|
|
|
|
if (entry->state.hook == NF_INET_LOCAL_OUT) {
|
|
|
|
const struct ipv6hdr *iph = ipv6_hdr(skb);
|
|
|
|
|
|
|
|
rt_info->daddr = iph->daddr;
|
|
|
|
rt_info->saddr = iph->saddr;
|
|
|
|
rt_info->mark = skb->mark;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-17 17:05:32 +00:00
|
|
|
static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
|
2017-08-23 22:08:32 +00:00
|
|
|
unsigned int index, unsigned int queuenum)
|
2005-08-10 03:21:49 +00:00
|
|
|
{
|
2007-12-05 09:27:19 +00:00
|
|
|
struct nf_queue_entry *entry = NULL;
|
2007-12-05 09:23:57 +00:00
|
|
|
const struct nf_queue_handler *qh;
|
2017-11-27 21:58:37 +00:00
|
|
|
unsigned int route_key_size;
|
2020-03-27 02:24:49 +00:00
|
|
|
int status;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2011-03-31 01:57:33 +00:00
|
|
|
/* QUEUE == DROP if no one is waiting, to be safe. */
|
2021-08-05 10:02:43 +00:00
|
|
|
qh = rcu_dereference(nf_queue_handler);
|
2020-03-27 02:24:49 +00:00
|
|
|
if (!qh)
|
|
|
|
return -ESRCH;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2017-11-27 21:58:37 +00:00
|
|
|
switch (state->pf) {
|
|
|
|
case AF_INET:
|
|
|
|
route_key_size = sizeof(struct ip_rt_info);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
route_key_size = sizeof(struct ip6_rt_info);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
route_key_size = 0;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-06 21:18:09 +00:00
|
|
|
|
2022-02-28 23:46:19 +00:00
|
|
|
if (skb_sk_is_prefetched(skb)) {
|
|
|
|
struct sock *sk = skb->sk;
|
|
|
|
|
|
|
|
if (!sk_is_refcounted(sk)) {
|
|
|
|
if (!refcount_inc_not_zero(&sk->sk_refcnt))
|
|
|
|
return -ENOTCONN;
|
|
|
|
|
|
|
|
/* drop refcount on skb_orphan */
|
|
|
|
skb->destructor = sock_edemux;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-27 21:58:37 +00:00
|
|
|
entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC);
|
2020-03-27 02:24:49 +00:00
|
|
|
if (!entry)
|
|
|
|
return -ENOMEM;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2019-12-02 18:54:30 +00:00
|
|
|
if (skb_dst(skb) && !skb_dst_force(skb)) {
|
2020-03-27 02:24:49 +00:00
|
|
|
kfree(entry);
|
|
|
|
return -ENETDOWN;
|
2019-06-26 18:40:45 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 09:26:33 +00:00
|
|
|
*entry = (struct nf_queue_entry) {
|
|
|
|
.skb = skb,
|
2015-04-03 20:31:01 +00:00
|
|
|
.state = *state,
|
2017-08-23 22:08:32 +00:00
|
|
|
.hook_index = index,
|
2017-11-27 21:58:37 +00:00
|
|
|
.size = sizeof(*entry) + route_key_size,
|
2007-12-05 09:26:33 +00:00
|
|
|
};
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2020-03-27 02:24:47 +00:00
|
|
|
__nf_queue_entry_init_physdevs(entry);
|
|
|
|
|
2022-02-28 05:22:22 +00:00
|
|
|
if (!nf_queue_entry_get_refs(entry)) {
|
|
|
|
kfree(entry);
|
|
|
|
return -ENOTCONN;
|
|
|
|
}
|
2017-12-20 15:12:55 +00:00
|
|
|
|
|
|
|
switch (entry->state.pf) {
|
|
|
|
case AF_INET:
|
|
|
|
nf_ip_saveroute(skb, entry);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
nf_ip6_saveroute(skb, entry);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-12-05 09:26:33 +00:00
|
|
|
status = qh->outfn(entry, queuenum);
|
2005-08-10 03:21:49 +00:00
|
|
|
if (status < 0) {
|
2020-03-27 02:24:49 +00:00
|
|
|
nf_queue_entry_free(entry);
|
|
|
|
return status;
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
|
2011-01-18 14:27:28 +00:00
|
|
|
return 0;
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
|
2016-10-17 17:05:32 +00:00
|
|
|
/* Packets leaving via this function must come back through nf_reinject(). */
|
|
|
|
int nf_queue(struct sk_buff *skb, struct nf_hook_state *state,
|
2019-07-02 18:41:14 +00:00
|
|
|
unsigned int index, unsigned int verdict)
|
2016-10-17 17:05:32 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2019-07-02 18:41:14 +00:00
|
|
|
ret = __nf_queue(skb, state, index, verdict >> NF_VERDICT_QBITS);
|
2016-10-17 17:05:32 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
if (ret == -ESRCH &&
|
2017-08-23 22:08:32 +00:00
|
|
|
(verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
|
2016-10-17 17:05:32 +00:00
|
|
|
return 1;
|
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-04-11 14:36:41 +00:00
|
|
|
EXPORT_SYMBOL_GPL(nf_queue);
|
2016-10-17 17:05:32 +00:00
|
|
|
|
2016-11-03 09:56:39 +00:00
|
|
|
static unsigned int nf_iterate(struct sk_buff *skb,
|
|
|
|
struct nf_hook_state *state,
|
2017-08-23 22:08:32 +00:00
|
|
|
const struct nf_hook_entries *hooks,
|
|
|
|
unsigned int *index)
|
2016-11-03 09:56:39 +00:00
|
|
|
{
|
2017-08-23 22:08:32 +00:00
|
|
|
const struct nf_hook_entry *hook;
|
|
|
|
unsigned int verdict, i = *index;
|
2016-11-03 09:56:39 +00:00
|
|
|
|
2017-08-23 22:08:32 +00:00
|
|
|
while (i < hooks->num_hook_entries) {
|
|
|
|
hook = &hooks->hooks[i];
|
2016-11-03 09:56:39 +00:00
|
|
|
repeat:
|
2017-08-23 22:08:32 +00:00
|
|
|
verdict = nf_hook_entry_hookfn(hook, skb, state);
|
2016-11-03 09:56:39 +00:00
|
|
|
if (verdict != NF_ACCEPT) {
|
2019-05-13 18:17:40 +00:00
|
|
|
*index = i;
|
2016-11-03 09:56:39 +00:00
|
|
|
if (verdict != NF_REPEAT)
|
|
|
|
return verdict;
|
|
|
|
goto repeat;
|
|
|
|
}
|
2017-08-23 22:08:32 +00:00
|
|
|
i++;
|
|
|
|
}
|
2016-11-03 09:56:39 +00:00
|
|
|
|
2017-08-23 22:08:32 +00:00
|
|
|
*index = i;
|
2016-11-03 09:56:39 +00:00
|
|
|
return NF_ACCEPT;
|
|
|
|
}
|
|
|
|
|
2017-12-02 23:58:47 +00:00
|
|
|
static struct nf_hook_entries *nf_hook_entries_head(const struct net *net, u8 pf, u8 hooknum)
|
|
|
|
{
|
|
|
|
switch (pf) {
|
2017-12-07 15:28:26 +00:00
|
|
|
#ifdef CONFIG_NETFILTER_FAMILY_BRIDGE
|
2017-12-02 23:58:47 +00:00
|
|
|
case NFPROTO_BRIDGE:
|
|
|
|
return rcu_dereference(net->nf.hooks_bridge[hooknum]);
|
2017-12-07 15:28:26 +00:00
|
|
|
#endif
|
2017-12-02 23:58:47 +00:00
|
|
|
case NFPROTO_IPV4:
|
|
|
|
return rcu_dereference(net->nf.hooks_ipv4[hooknum]);
|
|
|
|
case NFPROTO_IPV6:
|
|
|
|
return rcu_dereference(net->nf.hooks_ipv6[hooknum]);
|
|
|
|
default:
|
|
|
|
WARN_ON_ONCE(1);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-08-23 22:08:32 +00:00
|
|
|
/* Caller must hold rcu read-side lock */
|
2007-12-05 09:26:33 +00:00
|
|
|
void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
|
2005-08-10 03:21:49 +00:00
|
|
|
{
|
2017-08-23 22:08:32 +00:00
|
|
|
const struct nf_hook_entry *hook_entry;
|
|
|
|
const struct nf_hook_entries *hooks;
|
2007-12-05 09:26:33 +00:00
|
|
|
struct sk_buff *skb = entry->skb;
|
2017-08-23 22:08:32 +00:00
|
|
|
const struct net *net;
|
|
|
|
unsigned int i;
|
2011-01-18 14:27:28 +00:00
|
|
|
int err;
|
2017-08-23 22:08:32 +00:00
|
|
|
u8 pf;
|
|
|
|
|
|
|
|
net = entry->state.net;
|
|
|
|
pf = entry->state.pf;
|
|
|
|
|
2017-12-02 23:58:47 +00:00
|
|
|
hooks = nf_hook_entries_head(net, pf, entry->state.hook);
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2017-08-23 22:08:32 +00:00
|
|
|
i = entry->hook_index;
|
2017-12-02 23:58:47 +00:00
|
|
|
if (WARN_ON_ONCE(!hooks || i >= hooks->num_hook_entries)) {
|
2017-08-23 22:08:32 +00:00
|
|
|
kfree_skb(skb);
|
2020-03-27 02:24:48 +00:00
|
|
|
nf_queue_entry_free(entry);
|
2017-08-23 22:08:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hook_entry = &hooks->hooks[i];
|
|
|
|
|
2005-08-10 03:21:49 +00:00
|
|
|
/* Continue traversal iff userspace said ok... */
|
2015-10-09 11:10:37 +00:00
|
|
|
if (verdict == NF_REPEAT)
|
2016-11-15 22:48:44 +00:00
|
|
|
verdict = nf_hook_entry_hookfn(hook_entry, skb, &entry->state);
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2006-02-27 21:03:24 +00:00
|
|
|
if (verdict == NF_ACCEPT) {
|
2017-11-27 21:50:26 +00:00
|
|
|
if (nf_reroute(skb, entry) < 0)
|
2006-02-27 21:03:24 +00:00
|
|
|
verdict = NF_DROP;
|
|
|
|
}
|
|
|
|
|
2005-08-10 03:21:49 +00:00
|
|
|
if (verdict == NF_ACCEPT) {
|
2016-10-17 17:05:32 +00:00
|
|
|
next_hook:
|
2017-08-23 22:08:32 +00:00
|
|
|
++i;
|
|
|
|
verdict = nf_iterate(skb, &entry->state, hooks, &i);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (verdict & NF_VERDICT_MASK) {
|
|
|
|
case NF_ACCEPT:
|
2006-07-25 05:52:47 +00:00
|
|
|
case NF_STOP:
|
2007-12-05 09:27:02 +00:00
|
|
|
local_bh_disable();
|
2015-09-16 01:04:18 +00:00
|
|
|
entry->state.okfn(entry->state.net, entry->state.sk, skb);
|
2007-12-05 09:27:02 +00:00
|
|
|
local_bh_enable();
|
2005-08-10 03:21:49 +00:00
|
|
|
break;
|
|
|
|
case NF_QUEUE:
|
2019-07-02 18:41:14 +00:00
|
|
|
err = nf_queue(skb, &entry->state, i, verdict);
|
2017-08-23 22:08:32 +00:00
|
|
|
if (err == 1)
|
|
|
|
goto next_hook;
|
2005-08-10 03:21:49 +00:00
|
|
|
break;
|
2010-02-19 14:28:38 +00:00
|
|
|
case NF_STOLEN:
|
2011-08-05 00:36:28 +00:00
|
|
|
break;
|
2006-07-25 05:52:47 +00:00
|
|
|
default:
|
|
|
|
kfree_skb(skb);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
2015-10-13 12:33:28 +00:00
|
|
|
|
2020-03-27 02:24:48 +00:00
|
|
|
nf_queue_entry_free(entry);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(nf_reinject);
|