aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinjun Zhang <yinjun.zhang@corigine.com>2023-09-01 14:52:03 +0800
committerMichal Kubecek <mkubecek@suse.cz>2023-09-11 21:58:35 +0200
commit7fd525f67cf5176340421f598bfaef65ecd0b8c8 (patch)
treed3c7177fa195312461569243f5606297f10702f8
parenta1f71f85d02e5725642abd5e827ad0471ef9c46b (diff)
downloadethtool-7fd525f67cf5176340421f598bfaef65ecd0b8c8.tar.gz
rxclass: fix a bug in rmgr when searching for empty slot
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>
-rw-r--r--rxclass.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/rxclass.c b/rxclass.c
index 66cf00b..f17e3a5 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--;
}