Commit 993284df authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

sfc: Don't try to set filters with search depths we know won't work

The filter engine will time-out and ignore filters beyond
200-something hops.  We also need to avoid infinite loops in
efx_filter_search() when the table is full.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4e7f7951
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
#define FILTER_CTL_SRCH_FUDGE_WILD 3 #define FILTER_CTL_SRCH_FUDGE_WILD 3
#define FILTER_CTL_SRCH_FUDGE_FULL 1 #define FILTER_CTL_SRCH_FUDGE_FULL 1
/* Hard maximum hop limit. Hardware will time-out beyond 200-something.
* We also need to avoid infinite loops in efx_filter_search() when the
* table is full.
*/
#define FILTER_CTL_SRCH_MAX 200
struct efx_filter_table { struct efx_filter_table {
u32 offset; /* address of table relative to BAR */ u32 offset; /* address of table relative to BAR */
unsigned size; /* number of entries */ unsigned size; /* number of entries */
...@@ -183,6 +189,7 @@ static int efx_filter_search(struct efx_filter_table *table, ...@@ -183,6 +189,7 @@ static int efx_filter_search(struct efx_filter_table *table,
incr = efx_filter_increment(key); incr = efx_filter_increment(key);
for (depth = 1, filter_idx = hash & (table->size - 1); for (depth = 1, filter_idx = hash & (table->size - 1);
depth <= FILTER_CTL_SRCH_MAX &&
test_bit(filter_idx, table->used_bitmap); test_bit(filter_idx, table->used_bitmap);
++depth) { ++depth) {
cmp = &table->spec[filter_idx]; cmp = &table->spec[filter_idx];
...@@ -192,6 +199,8 @@ static int efx_filter_search(struct efx_filter_table *table, ...@@ -192,6 +199,8 @@ static int efx_filter_search(struct efx_filter_table *table,
} }
if (!for_insert) if (!for_insert)
return -ENOENT; return -ENOENT;
if (depth > FILTER_CTL_SRCH_MAX)
return -EBUSY;
found: found:
*depth_required = depth; *depth_required = depth;
return filter_idx; return filter_idx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment