netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Holger Eitzenberger <holger@eitzenberger.org>
To: Jan Engelhardt <jengelh@inai.de>
Cc: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH RFC 1/3] NFQUEUE: introduce CPU fanout
Date: Tue, 19 Mar 2013 22:34:24 +0100	[thread overview]
Message-ID: <20130319213424.GE13505@imap.eitzenberger.org> (raw)
In-Reply-To: <alpine.LNX.2.01.1303191531210.9679@nerf07.vanv.qr>

Hi Jan,

> 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);
> +}

having read through the webpage - and using 'goto' for error handling
in own code quite often - I don't see why your code above should be
more readable.


  parent reply	other threads:[~2013-03-19 21:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-19 14:14 [PATCH RFC 0/3] NFQUEUE: introduce CPU fanout holger
2013-03-19 14:14 ` [PATCH RFC 1/3] " holger
2013-03-19 14:26   ` David Miller
2013-03-19 14:34     ` Jan Engelhardt
2013-03-19 14:37       ` David Miller
2013-03-19 21:38         ` Holger Eitzenberger
2013-03-19 21:34       ` Holger Eitzenberger [this message]
2013-03-19 21:57         ` Jan Engelhardt
2013-03-19 22:30           ` Holger Eitzenberger
2013-03-19 19:56   ` Florian Westphal
2013-03-19 20:17     ` Holger Eitzenberger
2013-03-19 14:14 ` [PATCH RFC 2/3] NFQUEUE: coalesce IPv4 and IPv6 hashing holger
2013-03-19 14:27   ` David Miller
2013-03-19 14:39     ` Holger Eitzenberger
2013-03-19 14:14 ` [PATCH RFC 3/3] NFQUEUE: add --queue-cpu-fanout parameter holger
2013-03-19 14:34   ` Eric Leblond
2013-03-19 16:07     ` Holger Eitzenberger
2013-03-23 19:52     ` Holger Eitzenberger
2013-03-23 21:53       ` Eric Leblond

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=20130319213424.GE13505@imap.eitzenberger.org \
    --to=holger@eitzenberger.org \
    --cc=jengelh@inai.de \
    --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).