]> git.baikalelectronics.ru Git - kernel.git/commit
net: avoid strange behavior with skb_defer_max == 1
authorJakub Kicinski <kuba@kernel.org>
Wed, 18 May 2022 18:55:22 +0000 (11:55 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 21 May 2022 00:05:36 +0000 (17:05 -0700)
commit5e593dc32536318383c5edf3c467496a3b5d3ab0
tree16ea16ba1844e45c17fce73d9cb911ec2d7de338
parentbbb8009a331fc8e4c267e29f6221c2f9fe467c15
net: avoid strange behavior with skb_defer_max == 1

When user sets skb_defer_max to 1 the kick threshold is 0
(half of 1). If we increment queue length before the check
the kick will never happen, and the skb may get stranded.
This is likely harmless but can be avoided by moving the
increment after the check. This way skb_defer_max == 1
will always kick. Still a silly config to have, but
somehow that feels more correct.

While at it drop a comment which seems to be outdated
or confusing, and wrap the defer_count write with
a WRITE_ONCE() since it's read on the fast path
that avoids taking the lock.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20220518185522.2038683-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/skbuff.c