Commit 8e787646 authored by Aviv Heller's avatar Aviv Heller Committed by Doug Ledford

IB/core: Fix removal of default GID cache entry

When deleting a default GID from the cache, its gid_type field is set
to 0.

This could set the gid_type to RoCE v1 for a RoCE v2 default GID,
essentially making it inaccessible to future modifications, since it
is no longer found by find_gid().

This fix preserves the gid_type value for default gids during cache
operations.

Fixes: b39ffa1d ('IB/core: Add gid_type to gid attribute')
Signed-off-by: default avatarAviv Heller <avivh@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 198b12f7
...@@ -178,6 +178,7 @@ static int write_gid(struct ib_device *ib_dev, u8 port, ...@@ -178,6 +178,7 @@ static int write_gid(struct ib_device *ib_dev, u8 port,
{ {
int ret = 0; int ret = 0;
struct net_device *old_net_dev; struct net_device *old_net_dev;
enum ib_gid_type old_gid_type;
/* in rdma_cap_roce_gid_table, this funciton should be protected by a /* in rdma_cap_roce_gid_table, this funciton should be protected by a
* sleep-able lock. * sleep-able lock.
...@@ -199,6 +200,7 @@ static int write_gid(struct ib_device *ib_dev, u8 port, ...@@ -199,6 +200,7 @@ static int write_gid(struct ib_device *ib_dev, u8 port,
} }
old_net_dev = table->data_vec[ix].attr.ndev; old_net_dev = table->data_vec[ix].attr.ndev;
old_gid_type = table->data_vec[ix].attr.gid_type;
if (old_net_dev && old_net_dev != attr->ndev) if (old_net_dev && old_net_dev != attr->ndev)
dev_put(old_net_dev); dev_put(old_net_dev);
/* if modify_gid failed, just delete the old gid */ /* if modify_gid failed, just delete the old gid */
...@@ -207,10 +209,14 @@ static int write_gid(struct ib_device *ib_dev, u8 port, ...@@ -207,10 +209,14 @@ static int write_gid(struct ib_device *ib_dev, u8 port,
attr = &zattr; attr = &zattr;
table->data_vec[ix].context = NULL; table->data_vec[ix].context = NULL;
} }
if (default_gid)
table->data_vec[ix].props |= GID_TABLE_ENTRY_DEFAULT;
memcpy(&table->data_vec[ix].gid, gid, sizeof(*gid)); memcpy(&table->data_vec[ix].gid, gid, sizeof(*gid));
memcpy(&table->data_vec[ix].attr, attr, sizeof(*attr)); memcpy(&table->data_vec[ix].attr, attr, sizeof(*attr));
if (default_gid) {
table->data_vec[ix].props |= GID_TABLE_ENTRY_DEFAULT;
if (action == GID_TABLE_WRITE_ACTION_DEL)
table->data_vec[ix].attr.gid_type = old_gid_type;
}
if (table->data_vec[ix].attr.ndev && if (table->data_vec[ix].attr.ndev &&
table->data_vec[ix].attr.ndev != old_net_dev) table->data_vec[ix].attr.ndev != old_net_dev)
dev_hold(table->data_vec[ix].attr.ndev); dev_hold(table->data_vec[ix].attr.ndev);
......
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