Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 236633
b: refs/heads/master
c: 94b27cc
h: refs/heads/master
i:
  236631: 18a700a
v: v3
  • Loading branch information
Florian Westphal authored and Patrick McHardy committed Jan 18, 2011
1 parent cd96295 commit e47cedb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f615df76ed862b7d3927ec5f55b805ca19be29d9
refs/heads/master: 94b27cc36123069966616670c3653cd6873babe9
1 change: 1 addition & 0 deletions trunk/include/linux/netfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define NF_VERDICT_MASK 0x000000ff

/* extra verdict flags have mask 0x0000ff00 */
#define NF_VERDICT_FLAG_QUEUE_BYPASS 0x00008000

/* queue number (NF_QUEUE) or errno (NF_DROP) */
#define NF_VERDICT_QMASK 0xffff0000
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/netfilter/xt_NFQUEUE.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ struct xt_NFQ_info_v1 {
__u16 queues_total;
};

struct xt_NFQ_info_v2 {
__u16 queuenum;
__u16 queues_total;
__u16 bypass;
};

#endif /* _XT_NFQ_TARGET_H */
3 changes: 3 additions & 0 deletions trunk/net/netfilter/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
if (ret < 0) {
if (ret == -ECANCELED)
goto next_hook;
if (ret == -ESRCH &&
(verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
goto next_hook;
kfree_skb(skb);
}
ret = 0;
Expand Down
7 changes: 6 additions & 1 deletion trunk/net/netfilter/nf_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ static int __nf_queue(struct sk_buff *skb,
rcu_read_lock();

qh = rcu_dereference(queue_handler[pf]);
if (!qh)
if (!qh) {
status = -ESRCH;
goto err_unlock;
}

afinfo = nf_get_afinfo(pf);
if (!afinfo)
Expand Down Expand Up @@ -303,6 +305,9 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
if (err < 0) {
if (err == -ECANCELED)
goto next_hook;
if (err == -ESRCH &&
(verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
goto next_hook;
kfree_skb(skb);
}
break;
Expand Down
28 changes: 25 additions & 3 deletions trunk/net/netfilter/xt_NFQUEUE.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,20 @@ nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par)
return NF_QUEUE_NR(queue);
}

static int nfqueue_tg_v1_check(const struct xt_tgchk_param *par)
static unsigned int
nfqueue_tg_v2(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_NFQ_info_v1 *info = par->targinfo;
const struct xt_NFQ_info_v2 *info = par->targinfo;
unsigned int ret = nfqueue_tg_v1(skb, par);

if (info->bypass)
ret |= NF_VERDICT_FLAG_QUEUE_BYPASS;
return ret;
}

static int nfqueue_tg_check(const struct xt_tgchk_param *par)
{
const struct xt_NFQ_info_v2 *info = par->targinfo;
u32 maxid;

if (unlikely(!rnd_inited)) {
Expand All @@ -102,6 +113,8 @@ static int nfqueue_tg_v1_check(const struct xt_tgchk_param *par)
info->queues_total, maxid);
return -ERANGE;
}
if (par->target->revision == 2 && info->bypass > 1)
return -EINVAL;
return 0;
}

Expand All @@ -117,11 +130,20 @@ static struct xt_target nfqueue_tg_reg[] __read_mostly = {
.name = "NFQUEUE",
.revision = 1,
.family = NFPROTO_UNSPEC,
.checkentry = nfqueue_tg_v1_check,
.checkentry = nfqueue_tg_check,
.target = nfqueue_tg_v1,
.targetsize = sizeof(struct xt_NFQ_info_v1),
.me = THIS_MODULE,
},
{
.name = "NFQUEUE",
.revision = 2,
.family = NFPROTO_UNSPEC,
.checkentry = nfqueue_tg_check,
.target = nfqueue_tg_v2,
.targetsize = sizeof(struct xt_NFQ_info_v2),
.me = THIS_MODULE,
},
};

static int __init nfqueue_tg_init(void)
Expand Down

0 comments on commit e47cedb

Please sign in to comment.