From: Holger Eitzenberger <holger@eitzenberger.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH v2 2/3] NFQUEUE: coalesce IPv4 and IPv6 hashing
Date: Sat, 23 Mar 2013 21:04:04 +0100 [thread overview]
Message-ID: <20130323200608.174914056@eitzenberger.org> (raw)
In-Reply-To: 20130323200402.209591997@eitzenberger.org
[-- Attachment #1: net-next/NFQUEUE-coalesce.diff --]
[-- Type: text/plain, Size: 2055 bytes --]
Because rev1 and rev3 of the target share the same hashing
generalize it by introduing nfqueue_hash().
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Index: net-next/net/netfilter/xt_NFQUEUE.c
===================================================================
--- net-next.orig/net/netfilter/xt_NFQUEUE.c 2013-03-23 19:01:11.000000000 +0100
+++ net-next/net/netfilter/xt_NFQUEUE.c 2013-03-23 20:54:54.000000000 +0100
@@ -76,22 +76,31 @@
}
#endif
-static unsigned int
-nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par)
+static u32
+nfqueue_hash(const struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_NFQ_info_v1 *info = par->targinfo;
u32 queue = info->queuenum;
- if (info->queues_total > 1) {
- if (par->family == NFPROTO_IPV4)
- queue = (((u64) hash_v4(skb) * info->queues_total) >>
- 32) + queue;
+ if (par->family == NFPROTO_IPV4)
+ queue += ((u64) hash_v4(skb) * info->queues_total) >> 32;
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
- else if (par->family == NFPROTO_IPV6)
- queue = (((u64) hash_v6(skb) * info->queues_total) >>
- 32) + queue;
+ else if (par->family == NFPROTO_IPV6)
+ queue += ((u64) hash_v6(skb) * info->queues_total) >> 32;
#endif
- }
+
+ return queue;
+}
+
+static unsigned int
+nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par)
+{
+ const struct xt_NFQ_info_v1 *info = par->targinfo;
+ u32 queue = info->queuenum;
+
+ if (info->queues_total > 1)
+ queue = nfqueue_hash(skb, par);
+
return NF_QUEUE_NR(queue);
}
@@ -144,17 +153,10 @@
int cpu = smp_processor_id();
queue = info->queuenum + cpu % info->queues_total;
- } else {
- if (par->family == NFPROTO_IPV4)
- queue = (((u64) hash_v4(skb) * info->queues_total) >>
- 32) + queue;
-#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
- else if (par->family == NFPROTO_IPV6)
- queue = (((u64) hash_v6(skb) * info->queues_total) >>
- 32) + queue;
-#endif
- }
+ } else
+ queue = nfqueue_hash(skb, par);
}
+
return NF_QUEUE_NR(queue);
}
next prev parent reply other threads:[~2013-03-23 20:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 20:04 [PATCH v2 0/3] NFQUEUE: introduce CPU fanout Holger Eitzenberger
2013-03-23 20:04 ` [PATCH v2 1/3] " Holger Eitzenberger
2013-04-01 23:26 ` Pablo Neira Ayuso
2013-03-23 20:04 ` Holger Eitzenberger [this message]
2013-04-01 23:26 ` [PATCH v2 2/3] NFQUEUE: coalesce IPv4 and IPv6 hashing Pablo Neira Ayuso
2013-03-23 20:04 ` [PATCH v2 3/3] NFQUEUE: add --queue-cpu-fanout parameter Holger Eitzenberger
2013-04-01 23:29 ` Pablo Neira Ayuso
2013-04-02 10:35 ` Holger Eitzenberger
2013-04-02 11:26 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130323200608.174914056@eitzenberger.org \
--to=holger@eitzenberger.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).