Skip to contentSkip to conversation

netfilter: nfnetlink_queue: use xor hash function to distribute instances

PATCH New [email protected] 1 participant 2 messages Mar 14, 2013

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/2 netfilter: nfnetlink_queue: use xor hash function to distribute instances

From: Pablo Neira Ayuso <[email protected]>

Thanks to Eric Dumazet for suggesting this during the NFWS.

---
 net/netfilter/nfnetlink_queue_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nfnetlink_queue_core.c +1 -1
index 3158d87..4512658 100644
@@ -73,7 +73,7 @@ static struct hlist_head instance_table[INSTANCE_BUCKETS] __read_mostly;
 
 static inline u_int8_t instance_hashfn(u_int16_t queue_num)
 {
-	return ((queue_num >> 8) | queue_num) % INSTANCE_BUCKETS;
+	return ((queue_num >> 8) ^ queue_num) % INSTANCE_BUCKETS;
 }
 
 static struct nfqnl_instance *
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH 2/2 netfilter: nfnetlink_queue: fix incorrect initialization of copy range field

From: Pablo Neira Ayuso <[email protected]>

2^16 = 0xffff, not 0xfffff (note the extra 'f').

---
 net/netfilter/nfnetlink_queue_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nfnetlink_queue_core.c +1 -1
index 4512658..e81dad6 100644
@@ -113,7 +113,7 @@ instance_create(u_int16_t queue_num, int portid)
 	inst->queue_num = queue_num;
 	inst->peer_portid = portid;
 	inst->queue_maxlen = NFQNL_QMAX_DEFAULT;
-	inst->copy_range = 0xfffff;
+	inst->copy_range = 0xffff;
 	inst->copy_mode = NFQNL_COPY_NONE;
 	spin_lock_init(&inst->lock);
 	INIT_LIST_HEAD(&inst->queue_list);
Signature · 1 line
1.7.10.4