Re: [PATCH RFC 1/3] NFQUEUE: introduce CPU fanout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 2013-03-19 15:26, David Miller wrote:
>
>> +			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
>
>Maybe add a helper function so you don't have to indent so deeply.  Something
>like:

And combined with smart arranging of clauses, won't need an extra 
helper function.
http://www.braceless.org/Various/The%20Else%20Statement%20Considered%20Harmful

Something like

+static unsigned int
+nfqueue_tg_v3(struct sk_buff *skb, const struct xt_action_param *par)
+{
+	const struct xt_NFQ_info_v3 *info = par->targinfo;
+	u32 queue = info->queuenum;
+
+	if (info->queues_total == 1)
+		return NF_QUEUE_NR(queue);
+	if (info->flags & NFQ_FLAG_CPU_FANOUT) {
+		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
+	return NF_QUEUE_NR(queue);
+}
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux