Thread (11 messages) 11 messages, 4 authors, 2015-12-24

Re: [PATCH net-next 1/4] soreuseport: define reuseport groups

From: David Miller <davem@davemloft.net>
Date: 2015-12-22 22:04:00

From: Craig Gallek <redacted>
Date: Tue, 22 Dec 2015 16:58:11 -0500
On Tue, Dec 22, 2015 at 4:40 PM, David Miller [off-list ref] wrote:
quoted
From: Craig Gallek <redacted>
Date: Tue, 22 Dec 2015 15:05:07 -0500
quoted
+     for (i = 0; i < reuse->num_socks; i++) {
+             if (reuse->socks[i] == sk) {
+                     reuse->socks[i] = reuse->socks[reuse->num_socks - 1];
+                     reuse->num_socks--;
+                     if (reuse->num_socks == 0)
+                             kfree_rcu(reuse, rcu);
+                     break;
+             }
+     }
Don't you need to memmove() the entire rest of the array down one slot
when you hit the matching 'sk' in there?  I can't see how it can work
to only move one entry down.
It moves the last element in the list into the slot that was just
emptied.  You could argue that this may cause unexpected changes in
the index -> socket mapping observed by the user, but I'm not sure
making many socket indexes change (by sliding everything down one)
when one is removed is a desirable behavior either.  I don't have a
strong opinion either way though...
Thanks for explaining, I misered the code.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help