All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 ethtool] rxclass: fix a bug in rmgr when searching for empty slot
@ 2023-09-01  6:52 Yinjun Zhang
  2023-09-11 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Yinjun Zhang @ 2023-09-01  6:52 UTC (permalink / raw)
  To: mkubecek
  Cc: oss-drivers, netdev, Yinjun Zhang, Alexander Duyck,
	Niklas Söderlund

When reverse searching the list in rmgr for a free location the last
slot (first slot searched) in the list needs special care as it might
not span the full word length. This is done by building a bit-mask
covering the not-active parts of the last word and using that to judge
if there is a free location in the last word or not. Once that is known
searching in the last slot, or to skip it, can be done by the same
algorithm as for the other slots in the list.

There is a bug in creating the bit-mask for the non-active parts of the
last slot where the 0-indexed nature of bit addressing is not taken into
account when shifting. This leads to a one-off bug, fix it.

Fixes: 8d63f72ccdcb ("Add RX packet classification interface")
Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com>
Cc: Alexander Duyck <alexanderduyck@meta.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
Change since v1:
Use `loc` instead of `rmgr->size - 1` as suggested by Alexander.
---
 rxclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rxclass.c b/rxclass.c
index 66cf00ba7728..f17e3a5124c0 100644
--- a/rxclass.c
+++ b/rxclass.c
@@ -446,7 +446,7 @@ static int rmgr_find_empty_slot(struct rmgr_ctrl *rmgr,
 	 * If loc rolls over it should be greater than or equal to rmgr->size
 	 * and as such we know we have reached the end of the list.
 	 */
-	if (!~(rmgr->slot[slot_num] | (~1UL << rmgr->size % BITS_PER_LONG))) {
+	if (!~(rmgr->slot[slot_num] | (~1UL << loc % BITS_PER_LONG))) {
 		loc -= 1 + (loc % BITS_PER_LONG);
 		slot_num--;
 	}
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 ethtool] rxclass: fix a bug in rmgr when searching for empty slot
  2023-09-01  6:52 [PATCH v2 ethtool] rxclass: fix a bug in rmgr when searching for empty slot Yinjun Zhang
@ 2023-09-11 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-09-11 20:20 UTC (permalink / raw)
  To: Yinjun Zhang
  Cc: mkubecek, oss-drivers, netdev, alexanderduyck, niklas.soderlund

Hello:

This patch was applied to ethtool/ethtool.git (master)
by Michal Kubecek <mkubecek@suse.cz>:

On Fri,  1 Sep 2023 14:52:03 +0800 you wrote:
> When reverse searching the list in rmgr for a free location the last
> slot (first slot searched) in the list needs special care as it might
> not span the full word length. This is done by building a bit-mask
> covering the not-active parts of the last word and using that to judge
> if there is a free location in the last word or not. Once that is known
> searching in the last slot, or to skip it, can be done by the same
> algorithm as for the other slots in the list.
> 
> [...]

Here is the summary with links:
  - [v2,ethtool] rxclass: fix a bug in rmgr when searching for empty slot
    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=7fd525f67cf5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-11 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01  6:52 [PATCH v2 ethtool] rxclass: fix a bug in rmgr when searching for empty slot Yinjun Zhang
2023-09-11 20:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.