Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-12

Re: [PATCH v3] udp reuseport: fix packet of same flow hashed to different socket

From: Eric Dumazet <hidden>
Date: 2016-06-12 15:32:58
Also in: lkml

On Sun, 2016-06-12 at 20:43 +0800, Su Xuemin wrote:
From: "Su, Xuemin" <redacted>
...
Signed-off-by: Su, Xuemin <redacted>
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 :


quoted hunk ↗ jump to hunk
 		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 !
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help