Skip to content

Commit

Permalink
kernel-boot: Skip rename if the device name is provided by user
Browse files Browse the repository at this point in the history
Skip renaming device if the name_assign_type is USER. For example a
user created sub-device with provided name "smi0" has this type and
should not be renamed:
 # rdma dev add smi0 type SMI parent ibp8s0f0

Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
  • Loading branch information
MarkZhang81 authored and Yishai Hadas committed Jul 9, 2024
1 parent 540bb50 commit 47e2e8b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kernel-boot/rdma_rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct data {
uint64_t node_guid;
char *name;
int idx;
int name_assign_type;
};

static bool debug_mode;
Expand Down Expand Up @@ -555,6 +556,11 @@ static int get_nldata_cb(struct nl_msg *msg, void *data)

d->idx = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
d->node_guid = nla_get_u64(tb[RDMA_NLDEV_ATTR_NODE_GUID]);

if (tb[RDMA_NLDEV_ATTR_NAME_ASSIGN_TYPE])
d->name_assign_type =
nla_get_u8(tb[RDMA_NLDEV_ATTR_NAME_ASSIGN_TYPE]);

return NL_STOP;
}

Expand Down Expand Up @@ -639,6 +645,13 @@ int main(int argc, char **argv)
goto out;
}

if (d.name_assign_type == RDMA_NAME_ASSIGN_TYPE_USER) {
pr_dbg("%s: Leave user-assigned names, do nothing\n", d.curr);
/* Do nothing */
ret = 0;
goto out;
}

if (d.idx == -1 || !d.prefix) {
pr_err("%s: Failed to get current device name and index\n",
d.curr);
Expand Down

0 comments on commit 47e2e8b

Please sign in to comment.