diff options
author | Jiri Pirko <jiri@nvidia.com> | 2023-05-23 14:38:01 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-05-24 11:34:26 +0200 |
commit | 9277649c66fe7cb0e2f8adb09621556bcfb052c7 (patch) | |
tree | 60b58207fb829af1dc46d492864ffea60464aab5 /net/devlink/leftover.c | |
parent | devlink: remove no longer true locking comment from port_new/del() (diff) | |
download | linux-9277649c66fe7cb0e2f8adb09621556bcfb052c7.tar.xz linux-9277649c66fe7cb0e2f8adb09621556bcfb052c7.zip |
devlink: pass devlink_port pointer to ops->port_del() instead of index
Historically there was a reason why port_dev() along with for example
port_split() did get port_index instead of the devlink_port pointer.
With the locking changes that were done which ensured devlink instance
mutex is hold for every command, the port ops could get devlink_port
pointer directly. Change the forgotten port_dev() op to be as others
and pass devlink_port pointer instead of port_index.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/devlink/leftover.c')
-rw-r--r-- | net/devlink/leftover.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index cb60e42b2761..0410137a4a31 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -1396,20 +1396,14 @@ static int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, static int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, struct genl_info *info) { + struct devlink_port *devlink_port = info->user_ptr[1]; struct netlink_ext_ack *extack = info->extack; struct devlink *devlink = info->user_ptr[0]; - unsigned int port_index; if (!devlink->ops->port_del) return -EOPNOTSUPP; - if (GENL_REQ_ATTR_CHECK(info, DEVLINK_ATTR_PORT_INDEX)) { - NL_SET_ERR_MSG(extack, "Port index is not specified"); - return -EINVAL; - } - port_index = nla_get_u32(info->attrs[DEVLINK_ATTR_PORT_INDEX]); - - return devlink->ops->port_del(devlink, port_index, extack); + return devlink->ops->port_del(devlink, devlink_port, extack); } static int @@ -6341,6 +6335,7 @@ const struct genl_small_ops devlink_nl_ops[56] = { .cmd = DEVLINK_CMD_PORT_DEL, .doit = devlink_nl_cmd_port_del_doit, .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_PORT, }, { .cmd = DEVLINK_CMD_LINECARD_GET, |