public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb•de>
To: Eric Dumazet <eric.dumazet@gmail•com>
Cc: Pablo Neira Ayuso <pablo@netfilter•org>,
	Patrick McHardy <kaber@trash•net>,
	Jozsef Kadlecsik <kadlec@blackhole•kfki.hu>,
	"David S. Miller" <davem@davemloft•net>,
	Joshua Hunt <johunt@akamai•com>, Vishwanath Pai <vpai@akamai•com>,
	netfilter-devel@vger•kernel.org, coreteam@netfilter•org,
	netdev@vger•kernel.org, linux-kernel@vger•kernel.org
Subject: Re: [PATCH 3/3] netfilter: xt_hashlimit: uses div_u64 for division
Date: Fri, 30 Sep 2016 19:39:54 +0200	[thread overview]
Message-ID: <201609301939.55089.arnd@arndb.de> (raw)
In-Reply-To: <1475253522.28155.195.camel@edumazet-glaptop3.roam.corp.google.com>

On Friday 30 September 2016, Eric Dumazet wrote:
> On Fri, 2016-09-30 at 18:05 +0200, Arnd Bergmann wrote:
> >  net/netfilter/xt_hashlimit.c | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
> > index 44a095ecc7b7..3d5525df6eb3 100644
> > --- a/net/netfilter/xt_hashlimit.c
> > +++ b/net/netfilter/xt_hashlimit.c
> > @@ -464,20 +464,23 @@ static u32 xt_hashlimit_len_to_chunks(u32 len)
> >  static u64 user2credits(u64 user, int revision)
> >  {
> >  	if (revision == 1) {
> > +		u32 user32 = user; /* use 32-bit division */
> > +
> 
> This looks dangerous to me. Have you really tried all possible cases ?

Yes, I'm pretty certain about that: The 11d5f15723c9 patch that introduced this
kept the existing implementation for the revision==1 case, except for changing
the types.

> Caller (even if using revision == 1) does
> user2credits(cfg->avg * cfg->burst, revision);
> 
> Since this is not a fast path, I would prefer to keep the 64bit divide.
>
> Vishwanath version looks safer.

Ok, fair enough. I couldn't tell how much of a fast path this
was, and it's more a general issue that I see with other developers
blindly using div_u64() whenever getting this link error.

Since I already had the patch by the time I saw the other one
(which is also at v3 and got comments), I just sent it out along
with the other two patches I had for netfilter.

I also ended up introducing a typo in a last-minute change, so I'll let
Vishwanath and you work out the best implementation and withdraw my
version.

	Arnd

  parent reply	other threads:[~2016-09-30 17:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 16:05 [PATCH 1/3] netfilter: nf_tables: avoid uninitialized variable warning Arnd Bergmann
2016-09-30 16:05 ` [PATCH 2/3] netfilter: hide reference to nf_hooks_ingress Arnd Bergmann
2016-09-30 17:06   ` Aaron Conole
2016-09-30 16:05 ` [PATCH 3/3] netfilter: xt_hashlimit: uses div_u64 for division Arnd Bergmann
2016-09-30 16:38   ` Eric Dumazet
2016-09-30 17:21     ` Vishwanath Pai
2016-09-30 17:39     ` Arnd Bergmann [this message]
2016-09-30 17:47 ` [PATCH 1/3] netfilter: nf_tables: avoid uninitialized variable warning Pablo Neira Ayuso
2016-09-30 18:21   ` 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=201609301939.55089.arnd@arndb.de \
    --to=arnd@arndb$(echo .)de \
    --cc=coreteam@netfilter$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=johunt@akamai$(echo .)com \
    --cc=kaber@trash$(echo .)net \
    --cc=kadlec@blackhole$(echo .)kfki.hu \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=netfilter-devel@vger$(echo .)kernel.org \
    --cc=pablo@netfilter$(echo .)org \
    --cc=vpai@akamai$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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