All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] udp: Neaten and reduce size of compute_score functions
Date: Mon, 01 Dec 2014 19:09:20 -0800	[thread overview]
Message-ID: <1417489760.4894.8.camel@perches.com> (raw)
In-Reply-To: <1417489141.4442.24.camel@edumazet-glaptop2.roam.corp.google.com>

On Mon, 2014-12-01 at 18:59 -0800, Eric Dumazet wrote:
> On Mon, 2014-12-01 at 17:39 -0800, Joe Perches wrote:
> > The compute_score functions are a bit difficult to read.
> > 
> > Neaten them a bit to reduce object sizes and make them a
> > bit more intelligible.
> > 
> > Return early to avoid indentation and avoid unnecessary
> > initializations.
[]
> > +	if (!(net_eq(sock_net(sk), net) &&
> > +	      udp_sk(sk)->udp_port_hash == hnum &&
> > +	      !ipv6_only_sock(sk)))
> > +		return -1
> 
> Or even better :
> 
> 
> 	if (!net_eq(sock_net(sk), net) ||
> 	    udp_sk(sk)->udp_port_hash != hnum ||
> 	    ipv6_only_sock(sk))
> 		return -1;

Hi Eric.

Yeah, I thought about it but thought it
simpler to not change the logic.

Either way is fine with me.

David?

btw: the same thing can be done for the v6 block too:

+       if (!(net_eq(sock_net(sk), net) && !ipv6_only_sock(sk)))
+               return -1;
 
-               if (inet->inet_rcv_saddr != daddr)
+       inet = inet_sk(sk);
+
+       if (inet->inet_rcv_saddr != daddr)
+               return -1;
+       if (inet->inet_num != hnum)
+               return -1;

to:

	if (!net_eq(sock_net(sk, net) ||
	    ipv6_only_sock(sk))
		return -1;

	inet = inet_sk(sk);

	if (inet->inet_rcv_saddr != daddr ||
	    inet->inet_num != hnum)
		return -1;



  reply	other threads:[~2014-12-02  3:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02  1:39 [PATCH net-next] udp: Neaten and reduce size of compute_score functions Joe Perches
2014-12-02  2:59 ` Eric Dumazet
2014-12-02  3:09   ` Joe Perches [this message]
2014-12-02  4:29     ` [PATCH V2 " Joe Perches
2014-12-02  5:08       ` Eric Dumazet
2014-12-02  5:26         ` Joe Perches
2014-12-09  1:29       ` David Miller
2014-12-02  4:44     ` [PATCH " Eric Dumazet

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=1417489760.4894.8.camel@perches.com \
    --to=joe@perches.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.