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>
|
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"
|
|
|
|
|
2007-02-12 19:15:49 +00:00
|
|
|
/*
|
2005-08-10 03:21:49 +00:00
|
|
|
* A queue handler may be registered for each protocol. Each is protected by
|
|
|
|
* long term mutex. The handler must provide an an outfn() to accept packets
|
|
|
|
* for queueing and must reinject all packets it receives, no matter what.
|
|
|
|
*/
|
2010-03-09 19:59:15 +00:00
|
|
|
static const struct nf_queue_handler __rcu *queue_handler[NFPROTO_NUMPROTO] __read_mostly;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
static DEFINE_MUTEX(queue_handler_mutex);
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2005-08-10 03:23:36 +00:00
|
|
|
/* return EBUSY when somebody else is registered, return EEXIST if the
|
|
|
|
* same handler is registered, return 0 in case of success. */
|
2008-10-08 09:35:00 +00:00
|
|
|
int nf_register_queue_handler(u_int8_t pf, const struct nf_queue_handler *qh)
|
2007-02-12 19:15:49 +00:00
|
|
|
{
|
2005-08-10 03:21:49 +00:00
|
|
|
int ret;
|
2010-11-15 17:17:21 +00:00
|
|
|
const struct nf_queue_handler *old;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2008-10-08 09:35:00 +00:00
|
|
|
if (pf >= ARRAY_SIZE(queue_handler))
|
2005-08-10 03:21:49 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
mutex_lock(&queue_handler_mutex);
|
2010-11-15 17:17:21 +00:00
|
|
|
old = rcu_dereference_protected(queue_handler[pf],
|
|
|
|
lockdep_is_held(&queue_handler_mutex));
|
|
|
|
if (old == qh)
|
2005-08-10 03:23:36 +00:00
|
|
|
ret = -EEXIST;
|
2010-11-15 17:17:21 +00:00
|
|
|
else if (old)
|
2005-08-10 03:21:49 +00:00
|
|
|
ret = -EBUSY;
|
|
|
|
else {
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_assign_pointer(queue_handler[pf], qh);
|
2005-08-10 03:21:49 +00:00
|
|
|
ret = 0;
|
|
|
|
}
|
2007-07-08 05:40:26 +00:00
|
|
|
mutex_unlock(&queue_handler_mutex);
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(nf_register_queue_handler);
|
|
|
|
|
|
|
|
/* The caller must flush their queue before this */
|
2008-10-08 09:35:00 +00:00
|
|
|
int nf_unregister_queue_handler(u_int8_t pf, const struct nf_queue_handler *qh)
|
2005-08-10 03:21:49 +00:00
|
|
|
{
|
2010-11-15 17:17:21 +00:00
|
|
|
const struct nf_queue_handler *old;
|
|
|
|
|
2008-10-08 09:35:00 +00:00
|
|
|
if (pf >= ARRAY_SIZE(queue_handler))
|
2005-08-10 03:21:49 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
mutex_lock(&queue_handler_mutex);
|
2010-11-15 17:17:21 +00:00
|
|
|
old = rcu_dereference_protected(queue_handler[pf],
|
|
|
|
lockdep_is_held(&queue_handler_mutex));
|
|
|
|
if (old && old != qh) {
|
2007-07-08 05:40:26 +00:00
|
|
|
mutex_unlock(&queue_handler_mutex);
|
2007-07-08 05:40:08 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_assign_pointer(queue_handler[pf], NULL);
|
|
|
|
mutex_unlock(&queue_handler_mutex);
|
|
|
|
|
|
|
|
synchronize_rcu();
|
2007-02-12 19:15:49 +00:00
|
|
|
|
2005-08-10 03:21:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(nf_unregister_queue_handler);
|
|
|
|
|
2007-12-05 09:23:57 +00:00
|
|
|
void nf_unregister_queue_handlers(const struct nf_queue_handler *qh)
|
2005-08-10 03:21:49 +00:00
|
|
|
{
|
2008-10-08 09:35:00 +00:00
|
|
|
u_int8_t pf;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
mutex_lock(&queue_handler_mutex);
|
2008-10-08 09:35:00 +00:00
|
|
|
for (pf = 0; pf < ARRAY_SIZE(queue_handler); pf++) {
|
2010-11-15 17:17:21 +00:00
|
|
|
if (rcu_dereference_protected(
|
|
|
|
queue_handler[pf],
|
|
|
|
lockdep_is_held(&queue_handler_mutex)
|
|
|
|
) == qh)
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_assign_pointer(queue_handler[pf], NULL);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
2007-07-08 05:40:26 +00:00
|
|
|
mutex_unlock(&queue_handler_mutex);
|
|
|
|
|
|
|
|
synchronize_rcu();
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(nf_unregister_queue_handlers);
|
|
|
|
|
2007-12-05 09:27:19 +00:00
|
|
|
static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
|
|
|
|
{
|
|
|
|
/* Release those devices we held, or Alexey will kill me. */
|
|
|
|
if (entry->indev)
|
|
|
|
dev_put(entry->indev);
|
|
|
|
if (entry->outdev)
|
|
|
|
dev_put(entry->outdev);
|
|
|
|
#ifdef CONFIG_BRIDGE_NETFILTER
|
|
|
|
if (entry->skb->nf_bridge) {
|
|
|
|
struct nf_bridge_info *nf_bridge = entry->skb->nf_bridge;
|
|
|
|
|
|
|
|
if (nf_bridge->physindev)
|
|
|
|
dev_put(nf_bridge->physindev);
|
|
|
|
if (nf_bridge->physoutdev)
|
|
|
|
dev_put(nf_bridge->physoutdev);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* Drop reference to owner of hook which queued us. */
|
|
|
|
module_put(entry->elem->owner);
|
|
|
|
}
|
|
|
|
|
2007-02-12 19:15:49 +00:00
|
|
|
/*
|
|
|
|
* Any packet that leaves via this function must come back
|
2005-08-10 03:21:49 +00:00
|
|
|
* through nf_reinject().
|
|
|
|
*/
|
2006-08-05 07:58:52 +00:00
|
|
|
static int __nf_queue(struct sk_buff *skb,
|
|
|
|
struct list_head *elem,
|
2008-10-08 09:35:00 +00:00
|
|
|
u_int8_t pf, unsigned int hook,
|
2006-08-05 07:58:52 +00:00
|
|
|
struct net_device *indev,
|
|
|
|
struct net_device *outdev,
|
|
|
|
int (*okfn)(struct sk_buff *),
|
|
|
|
unsigned int queuenum)
|
2005-08-10 03:21:49 +00:00
|
|
|
{
|
2011-01-18 14:27:28 +00:00
|
|
|
int status = -ENOENT;
|
2007-12-05 09:27:19 +00:00
|
|
|
struct nf_queue_entry *entry = NULL;
|
2005-08-10 03:21:49 +00:00
|
|
|
#ifdef CONFIG_BRIDGE_NETFILTER
|
2007-12-05 09:27:19 +00:00
|
|
|
struct net_device *physindev;
|
|
|
|
struct net_device *physoutdev;
|
2005-08-10 03:21:49 +00:00
|
|
|
#endif
|
2007-12-18 06:42:27 +00:00
|
|
|
const struct nf_afinfo *afinfo;
|
2007-12-05 09:23:57 +00:00
|
|
|
const struct nf_queue_handler *qh;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
/* QUEUE == DROP if noone is waiting, to be safe. */
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
|
|
|
|
qh = rcu_dereference(queue_handler[pf]);
|
2007-12-05 09:27:19 +00:00
|
|
|
if (!qh)
|
|
|
|
goto err_unlock;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2006-04-06 21:18:09 +00:00
|
|
|
afinfo = nf_get_afinfo(pf);
|
2007-12-05 09:27:19 +00:00
|
|
|
if (!afinfo)
|
|
|
|
goto err_unlock;
|
2006-04-06 21:18:09 +00:00
|
|
|
|
2007-12-05 09:26:33 +00:00
|
|
|
entry = kmalloc(sizeof(*entry) + afinfo->route_key_size, GFP_ATOMIC);
|
2011-01-18 14:27:28 +00:00
|
|
|
if (!entry) {
|
|
|
|
status = -ENOMEM;
|
2007-12-05 09:27:19 +00:00
|
|
|
goto err_unlock;
|
2011-01-18 14:27:28 +00:00
|
|
|
}
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2007-12-05 09:26:33 +00:00
|
|
|
*entry = (struct nf_queue_entry) {
|
|
|
|
.skb = skb,
|
|
|
|
.elem = list_entry(elem, struct nf_hook_ops, list),
|
|
|
|
.pf = pf,
|
|
|
|
.hook = hook,
|
|
|
|
.indev = indev,
|
|
|
|
.outdev = outdev,
|
|
|
|
.okfn = okfn,
|
|
|
|
};
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
/* If it's going away, ignore hook. */
|
2007-12-05 09:26:33 +00:00
|
|
|
if (!try_module_get(entry->elem->owner)) {
|
2011-01-18 14:28:38 +00:00
|
|
|
status = -ECANCELED;
|
|
|
|
goto err_unlock;
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
/* Bump dev refs so they don't vanish while packet is out */
|
2007-12-05 09:23:17 +00:00
|
|
|
if (indev)
|
|
|
|
dev_hold(indev);
|
|
|
|
if (outdev)
|
|
|
|
dev_hold(outdev);
|
2005-08-10 03:21:49 +00:00
|
|
|
#ifdef CONFIG_BRIDGE_NETFILTER
|
2006-08-05 07:58:52 +00:00
|
|
|
if (skb->nf_bridge) {
|
|
|
|
physindev = skb->nf_bridge->physindev;
|
2007-12-05 09:23:17 +00:00
|
|
|
if (physindev)
|
|
|
|
dev_hold(physindev);
|
2006-08-05 07:58:52 +00:00
|
|
|
physoutdev = skb->nf_bridge->physoutdev;
|
2007-12-05 09:23:17 +00:00
|
|
|
if (physoutdev)
|
|
|
|
dev_hold(physoutdev);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-05-11 23:19:48 +00:00
|
|
|
skb_dst_force(skb);
|
2007-12-05 09:26:33 +00:00
|
|
|
afinfo->saveroute(skb, entry);
|
|
|
|
status = qh->outfn(entry, queuenum);
|
2005-08-10 03:21:49 +00:00
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_read_unlock();
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
if (status < 0) {
|
2007-12-05 09:27:19 +00:00
|
|
|
nf_queue_entry_release_refs(entry);
|
|
|
|
goto err;
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
|
2011-01-18 14:27:28 +00:00
|
|
|
return 0;
|
2007-12-05 09:27:19 +00:00
|
|
|
|
|
|
|
err_unlock:
|
|
|
|
rcu_read_unlock();
|
|
|
|
err:
|
|
|
|
kfree(entry);
|
2011-01-18 14:27:28 +00:00
|
|
|
return status;
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
|
2006-08-05 07:58:52 +00:00
|
|
|
int nf_queue(struct sk_buff *skb,
|
|
|
|
struct list_head *elem,
|
2008-10-08 09:35:00 +00:00
|
|
|
u_int8_t pf, unsigned int hook,
|
2006-08-05 07:58:52 +00:00
|
|
|
struct net_device *indev,
|
|
|
|
struct net_device *outdev,
|
|
|
|
int (*okfn)(struct sk_buff *),
|
|
|
|
unsigned int queuenum)
|
|
|
|
{
|
|
|
|
struct sk_buff *segs;
|
2011-01-18 14:27:28 +00:00
|
|
|
int err;
|
|
|
|
unsigned int queued;
|
2006-08-05 07:58:52 +00:00
|
|
|
|
|
|
|
if (!skb_is_gso(skb))
|
|
|
|
return __nf_queue(skb, elem, pf, hook, indev, outdev, okfn,
|
|
|
|
queuenum);
|
|
|
|
|
|
|
|
switch (pf) {
|
2009-04-14 12:26:49 +00:00
|
|
|
case NFPROTO_IPV4:
|
2006-08-05 07:58:52 +00:00
|
|
|
skb->protocol = htons(ETH_P_IP);
|
|
|
|
break;
|
2009-04-14 12:26:49 +00:00
|
|
|
case NFPROTO_IPV6:
|
2006-08-05 07:58:52 +00:00
|
|
|
skb->protocol = htons(ETH_P_IPV6);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
segs = skb_gso_segment(skb, 0);
|
2011-01-18 14:27:28 +00:00
|
|
|
/* Does not use PTR_ERR to limit the number of error codes that can be
|
|
|
|
* returned by nf_queue. For instance, callers rely on -ECANCELED to mean
|
|
|
|
* 'ignore this hook'.
|
|
|
|
*/
|
2008-04-29 08:03:09 +00:00
|
|
|
if (IS_ERR(segs))
|
2011-01-18 14:27:28 +00:00
|
|
|
return -EINVAL;
|
2006-08-05 07:58:52 +00:00
|
|
|
|
2011-01-18 14:27:28 +00:00
|
|
|
queued = 0;
|
|
|
|
err = 0;
|
2006-08-05 07:58:52 +00:00
|
|
|
do {
|
|
|
|
struct sk_buff *nskb = segs->next;
|
|
|
|
|
|
|
|
segs->next = NULL;
|
2011-01-18 14:27:28 +00:00
|
|
|
if (err == 0)
|
|
|
|
err = __nf_queue(segs, elem, pf, hook, indev,
|
|
|
|
outdev, okfn, queuenum);
|
|
|
|
if (err == 0)
|
|
|
|
queued++;
|
|
|
|
else
|
2006-08-05 07:58:52 +00:00
|
|
|
kfree_skb(segs);
|
|
|
|
segs = nskb;
|
|
|
|
} while (segs);
|
2011-01-18 14:27:28 +00:00
|
|
|
|
2011-01-18 14:28:38 +00:00
|
|
|
/* also free orig skb if only some segments were queued */
|
2011-01-18 14:27:28 +00:00
|
|
|
if (unlikely(err && queued))
|
|
|
|
err = 0;
|
2011-01-18 14:28:38 +00:00
|
|
|
if (err == 0)
|
|
|
|
kfree_skb(skb);
|
2011-01-18 14:27:28 +00:00
|
|
|
return err;
|
2006-08-05 07:58:52 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2007-12-05 09:26:33 +00:00
|
|
|
struct sk_buff *skb = entry->skb;
|
|
|
|
struct list_head *elem = &entry->elem->list;
|
2007-12-18 06:42:27 +00:00
|
|
|
const struct nf_afinfo *afinfo;
|
2011-01-18 14:27:28 +00:00
|
|
|
int err;
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
|
2007-12-05 09:27:19 +00:00
|
|
|
nf_queue_entry_release_refs(entry);
|
2005-08-10 03:21:49 +00:00
|
|
|
|
|
|
|
/* Continue traversal iff userspace said ok... */
|
|
|
|
if (verdict == NF_REPEAT) {
|
|
|
|
elem = elem->prev;
|
|
|
|
verdict = NF_ACCEPT;
|
|
|
|
}
|
|
|
|
|
2006-02-27 21:03:24 +00:00
|
|
|
if (verdict == NF_ACCEPT) {
|
2007-12-05 09:26:33 +00:00
|
|
|
afinfo = nf_get_afinfo(entry->pf);
|
|
|
|
if (!afinfo || afinfo->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) {
|
|
|
|
next_hook:
|
2007-12-05 09:26:33 +00:00
|
|
|
verdict = nf_iterate(&nf_hooks[entry->pf][entry->hook],
|
|
|
|
skb, entry->hook,
|
|
|
|
entry->indev, entry->outdev, &elem,
|
|
|
|
entry->okfn, INT_MIN);
|
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();
|
2007-12-05 09:26:33 +00:00
|
|
|
entry->okfn(skb);
|
2007-12-05 09:27:02 +00:00
|
|
|
local_bh_enable();
|
2005-08-10 03:21:49 +00:00
|
|
|
break;
|
|
|
|
case NF_QUEUE:
|
2011-01-18 14:27:28 +00:00
|
|
|
err = __nf_queue(skb, elem, entry->pf, entry->hook,
|
|
|
|
entry->indev, entry->outdev, entry->okfn,
|
|
|
|
verdict >> NF_VERDICT_BITS);
|
2011-01-18 14:28:38 +00:00
|
|
|
if (err < 0) {
|
|
|
|
if (err == -ECANCELED)
|
|
|
|
goto next_hook;
|
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
2005-08-10 03:21:49 +00:00
|
|
|
break;
|
2010-02-19 14:28:38 +00:00
|
|
|
case NF_STOLEN:
|
2006-07-25 05:52:47 +00:00
|
|
|
default:
|
|
|
|
kfree_skb(skb);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
2007-12-05 09:26:33 +00:00
|
|
|
kfree(entry);
|
2005-08-10 03:21:49 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(nf_reinject);
|
|
|
|
|
2005-08-10 03:23:11 +00:00
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
static void *seq_start(struct seq_file *seq, loff_t *pos)
|
|
|
|
{
|
2008-10-08 09:35:00 +00:00
|
|
|
if (*pos >= ARRAY_SIZE(queue_handler))
|
2005-08-10 03:23:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *seq_next(struct seq_file *s, void *v, loff_t *pos)
|
|
|
|
{
|
|
|
|
(*pos)++;
|
|
|
|
|
2008-10-08 09:35:00 +00:00
|
|
|
if (*pos >= ARRAY_SIZE(queue_handler))
|
2005-08-10 03:23:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void seq_stop(struct seq_file *s, void *v)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int seq_show(struct seq_file *s, void *v)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
loff_t *pos = v;
|
2007-12-05 09:23:57 +00:00
|
|
|
const struct nf_queue_handler *qh;
|
2005-08-10 03:23:11 +00:00
|
|
|
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
qh = rcu_dereference(queue_handler[*pos]);
|
2005-08-10 03:23:11 +00:00
|
|
|
if (!qh)
|
|
|
|
ret = seq_printf(s, "%2lld NONE\n", *pos);
|
|
|
|
else
|
|
|
|
ret = seq_printf(s, "%2lld %s\n", *pos, qh->name);
|
2007-07-08 05:40:26 +00:00
|
|
|
rcu_read_unlock();
|
2005-08-10 03:23:11 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-11 06:07:31 +00:00
|
|
|
static const struct seq_operations nfqueue_seq_ops = {
|
2005-08-10 03:23:11 +00:00
|
|
|
.start = seq_start,
|
|
|
|
.next = seq_next,
|
|
|
|
.stop = seq_stop,
|
|
|
|
.show = seq_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int nfqueue_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return seq_open(file, &nfqueue_seq_ops);
|
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:36 +00:00
|
|
|
static const struct file_operations nfqueue_file_ops = {
|
2005-08-10 03:23:11 +00:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = nfqueue_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = seq_release,
|
|
|
|
};
|
|
|
|
#endif /* PROC_FS */
|
|
|
|
|
|
|
|
|
2005-08-10 03:21:49 +00:00
|
|
|
int __init netfilter_queue_init(void)
|
|
|
|
{
|
2005-08-10 03:23:11 +00:00
|
|
|
#ifdef CONFIG_PROC_FS
|
2008-03-27 23:55:53 +00:00
|
|
|
if (!proc_create("nf_queue", S_IRUGO,
|
|
|
|
proc_net_netfilter, &nfqueue_file_ops))
|
2005-08-10 03:23:11 +00:00
|
|
|
return -1;
|
|
|
|
#endif
|
2005-08-10 03:21:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|