Commit 58e1eb81 authored by Jack Morgenstein's avatar Jack Morgenstein Committed by Luis Henriques

IB/mlx4: Forbid using sysfs to change RoCE pkeys

commit 2b135db3 upstream.

The pkey mapping for RoCE must remain the default mapping:
VFs:
  virtual index 0 = mapped to real index 0 (0xFFFF)
  All others indices: mapped to a real pkey index containing an
                      invalid pkey.
PF:
  virtual index i = real index i.

Don't allow users to change these mappings using files found in
sysfs.

Fixes: c1e7e466 ('IB/mlx4: Add iov directory in sysfs under the ib device')
Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 72d64a06
...@@ -660,6 +660,8 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave) ...@@ -660,6 +660,8 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
struct mlx4_port *p; struct mlx4_port *p;
int i; int i;
int ret; int ret;
int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port_num) ==
IB_LINK_LAYER_ETHERNET;
p = kzalloc(sizeof *p, GFP_KERNEL); p = kzalloc(sizeof *p, GFP_KERNEL);
if (!p) if (!p)
...@@ -677,7 +679,8 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave) ...@@ -677,7 +679,8 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
p->pkey_group.name = "pkey_idx"; p->pkey_group.name = "pkey_idx";
p->pkey_group.attrs = p->pkey_group.attrs =
alloc_group_attrs(show_port_pkey, store_port_pkey, alloc_group_attrs(show_port_pkey,
is_eth ? NULL : store_port_pkey,
dev->dev->caps.pkey_table_len[port_num]); dev->dev->caps.pkey_table_len[port_num]);
if (!p->pkey_group.attrs) { if (!p->pkey_group.attrs) {
ret = -ENOMEM; ret = -ENOMEM;
......
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