This is a note to let you know that I've just added the patch titled sfc: Fix loop condition for efx_filter_search() when !for_insert to the 3.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: sfc-fix-loop-condition-for-efx_filter_search-when-for_insert.patch and it can be found in the queue-3.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 454d85d509053208d0a38e75626e362f55944930 Mon Sep 17 00:00:00 2001 From: Ben Hutchings <bhutchings@xxxxxxxxxxxxxx> Date: Fri, 24 Jun 2011 20:26:44 +0100 Subject: sfc: Fix loop condition for efx_filter_search() when !for_insert From: Ben Hutchings <bhutchings@xxxxxxxxxxxxxx> [ Upstream commit 4017dbdc14af1903dc9fcba4d08b89c02325069d ] efx_filter_remove_filter() fails to remove inserted filters in some cases. For example: 1. Two filters A and B have specifications that result in an initial hash collision. 2. A is inserted first, followed by B. 3. An attempt to remove B first succeeds, but if A is removed first a subsequent attempt to remove B fails. When searching for an existing filter (!for_insert), efx_filter_search() must always continue to the maximum search depth for the given type rather than stopping at the first unused entry. Signed-off-by: Ben Hutchings <bhutchings@xxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/net/sfc/filter.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) --- a/drivers/net/sfc/filter.c +++ b/drivers/net/sfc/filter.c @@ -335,28 +335,35 @@ static int efx_filter_search(struct efx_ bool for_insert, int *depth_required) { unsigned hash, incr, filter_idx, depth, depth_max; - struct efx_filter_spec *cmp; hash = efx_filter_hash(key); incr = efx_filter_increment(key); - depth_max = (spec->priority <= EFX_FILTER_PRI_HINT ? - FILTER_CTL_SRCH_HINT_MAX : FILTER_CTL_SRCH_MAX); - for (depth = 1, filter_idx = hash & (table->size - 1); - depth <= depth_max && test_bit(filter_idx, table->used_bitmap); - ++depth) { - cmp = &table->spec[filter_idx]; - if (efx_filter_equal(spec, cmp)) - goto found; + filter_idx = hash & (table->size - 1); + depth = 1; + depth_max = (for_insert ? + (spec->priority <= EFX_FILTER_PRI_HINT ? + FILTER_CTL_SRCH_HINT_MAX : FILTER_CTL_SRCH_MAX) : + table->search_depth[spec->type]); + + for (;;) { + /* Return success if entry is used and matches this spec + * or entry is unused and we are trying to insert. + */ + if (test_bit(filter_idx, table->used_bitmap) ? + efx_filter_equal(spec, &table->spec[filter_idx]) : + for_insert) { + *depth_required = depth; + return filter_idx; + } + + /* Return failure if we reached the maximum search depth */ + if (depth == depth_max) + return for_insert ? -EBUSY : -ENOENT; + filter_idx = (filter_idx + incr) & (table->size - 1); + ++depth; } - if (!for_insert) - return -ENOENT; - if (depth > depth_max) - return -EBUSY; -found: - *depth_required = depth; - return filter_idx; } /* Construct/deconstruct external filter IDs */ Patches currently in stable-queue which might be from bhutchings@xxxxxxxxxxxxxx are queue-3.0/sfc-fix-siena-mac-statistics-on-big-endian-platforms.patch queue-3.0/sfc-do-not-attempt-to-flush-queues-if-dma-is-disabled.patch queue-3.0/sfc-fix-two-causes-of-flush-failure.patch queue-3.0/sfc-properly-sync-rx-dma-buffer-when-it-is-not-the-last-in-the-page.patch queue-3.0/sfc-only-use-tx-push-if-a-single-descriptor-is-to-be-written.patch queue-3.0/sfc-fix-efx_rx_buf_offset-in-the-presence-of-swiotlb.patch queue-3.0/sfc-lock-tx-queues-when-calling-netif_device_detach.patch queue-3.0/sfc-convert-firmware-subtypes-to-native-byte-order-in-efx_mcdi_get_board_cfg.patch queue-3.0/sfc-fix-timekeeping-in-efx_mcdi_poll.patch queue-3.0/sfc-disable-soft-interrupt-handling-during-efx_device_detach_sync.patch queue-3.0/sfc-fix-loop-condition-for-efx_filter_search-when-for_insert.patch queue-3.0/sfc-detach-net-device-when-stopping-queues-for-reconfiguration.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html