aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/cache.c
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2018-04-23 09:58:17 -0400
committerDoug Ledford <dledford@redhat.com>2018-04-23 17:26:04 -0400
commita66ed149b0da5b97fa7486ee2bcd00f3f9df5442 (patch)
treebb0cc0dc546ff035f1dbe51e6a6033694ab01011 /drivers/infiniband/core/cache.c
parentd50e14abe2d0024aa527b89c7990147df5d531a5 (diff)
IB/core: Don't allow default GID addition at non reseved slots
Default GIDs are marked reserved at the start of the GID table at index 0 and 1 by gid_table_reserve_default(). Currently when default GID is requested, it can still allocates an empty slot which was not marked as RESERVED for default GID, which is incorrect. At least in current code flow of roce_gid_mgmt.c, in theory we can still request to allocate more than one/two default GIDs depending on how upper devices are setup. Therefore, it is better for cache layer to only allow our reserved slots to be used by default GID allocation requests. Fixes: 598ff6bae689 ("IB/core: Refactor GID modify code for RoCE") Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/core/cache.c')
-rw-r--r--drivers/infiniband/core/cache.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index e337b08de2ff..92ec845f9c40 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -291,14 +291,18 @@ static int find_gid(struct ib_gid_table *table, const union ib_gid *gid,
291 * so lookup free slot only if requested. 291 * so lookup free slot only if requested.
292 */ 292 */
293 if (pempty && empty < 0) { 293 if (pempty && empty < 0) {
294 if (data->props & GID_TABLE_ENTRY_INVALID) { 294 if (data->props & GID_TABLE_ENTRY_INVALID &&
295 /* Found an invalid (free) entry; allocate it */ 295 (default_gid ==
296 if (data->props & GID_TABLE_ENTRY_DEFAULT) { 296 !!(data->props & GID_TABLE_ENTRY_DEFAULT))) {
297 if (default_gid) 297 /*
298 empty = curr_index; 298 * Found an invalid (free) entry; allocate it.
299 } else { 299 * If default GID is requested, then our
300 empty = curr_index; 300 * found slot must be one of the DEFAULT
301 } 301 * reserved slots or we fail.
302 * This ensures that only DEFAULT reserved
303 * slots are used for default property GIDs.
304 */
305 empty = curr_index;
302 } 306 }
303 } 307 }
304 308