lkml.org 
[lkml]   [2016]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3] udp reuseport: fix packet of same flow hashed to different socket
From
Date
On Sun, 2016-06-12 at 20:43 +0800, Su Xuemin wrote:
> From: "Su, Xuemin" <suxm@chinanetcenter.com>
...

> Signed-off-by: Su, Xuemin <suxm@chinanetcenter.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---

First, I want to thank you for this very high quality submission,
especially if this is your first linux kernel patch.

I have one additional comment to make :



> if (score > badness) {
> reuseport = sk->sk_reuseport;
> @@ -556,14 +510,20 @@ struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
> daddr, hnum, dif,
> hslot2, slot2, skb);
> if (!result) {
> + unsigned int old = hash2;
> hash2 = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum);
> +
> + /* avoid search the same slot again. */
> + if (unlikely(old == hash2))
> + return result;
> +

Technically speaking, what matters is the slot, not the hash value
(32bit)

So I would save in old, slot2

> slot2 = hash2 & udptable->mask;

And here perform the check
if (unlikely(slot2 != old_slot))
return result;

> hslot2 = &udptable->hash2[slot2];
> if (hslot->count < hslot2->count)
> goto begin;


(Same remark applies in IPv6)

Thanks !


\
 
 \ /
  Last update: 2016-06-12 18:21    [W:0.122 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site