Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

devlink: bring port new reply back

In the offending fixes commit I mistakenly removed the reply message of
the port new command. I was under impression it is a new port
notification, partly due to the "notify" in the name of the helper
function. Bring the code sending reply with new port message back, this
time putting it directly to devlink_nl_cmd_port_new_doit()

Fixes: c496daeb8630 ("devlink: remove duplicate port notification")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230531142025.2605001-1-jiri@resnulli.us
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jiri Pirko and committed by
Jakub Kicinski
5ff9424e a03a91bd

+38 -6
+6 -3
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
··· 282 282 283 283 static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, 284 284 const struct devlink_port_new_attrs *new_attr, 285 - struct netlink_ext_ack *extack) 285 + struct netlink_ext_ack *extack, 286 + struct devlink_port **dl_port) 286 287 { 287 288 struct mlx5_eswitch *esw = dev->priv.eswitch; 288 289 struct mlx5_sf *sf; ··· 297 296 new_attr->controller, new_attr->sfnum); 298 297 if (err) 299 298 goto esw_err; 299 + *dl_port = &sf->dl_port; 300 300 trace_mlx5_sf_add(dev, sf->port_index, sf->controller, sf->hw_fn_id, new_attr->sfnum); 301 301 return 0; 302 302 ··· 338 336 339 337 int mlx5_devlink_sf_port_new(struct devlink *devlink, 340 338 const struct devlink_port_new_attrs *new_attr, 341 - struct netlink_ext_ack *extack) 339 + struct netlink_ext_ack *extack, 340 + struct devlink_port **dl_port) 342 341 { 343 342 struct mlx5_core_dev *dev = devlink_priv(devlink); 344 343 struct mlx5_sf_table *table; ··· 355 352 "Port add is only supported in eswitch switchdev mode or SF ports are disabled."); 356 353 return -EOPNOTSUPP; 357 354 } 358 - err = mlx5_sf_add(dev, table, new_attr, extack); 355 + err = mlx5_sf_add(dev, table, new_attr, extack, dl_port); 359 356 mlx5_sf_table_put(table); 360 357 return err; 361 358 }
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h
··· 20 20 21 21 int mlx5_devlink_sf_port_new(struct devlink *devlink, 22 22 const struct devlink_port_new_attrs *add_attr, 23 - struct netlink_ext_ack *extack); 23 + struct netlink_ext_ack *extack, 24 + struct devlink_port **dl_port); 24 25 int mlx5_devlink_sf_port_del(struct devlink *devlink, 25 26 struct devlink_port *dl_port, 26 27 struct netlink_ext_ack *extack);
+3 -1
include/net/devlink.h
··· 1434 1434 * @devlink: Devlink instance 1435 1435 * @attrs: attributes of the new port 1436 1436 * @extack: extack for reporting error messages 1437 + * @devlink_port: pointer to store new devlink port pointer 1437 1438 * 1438 1439 * Devlink core will call this device driver function upon user request 1439 1440 * to create a new port function of a specified flavor and optional ··· 1447 1446 */ 1448 1447 int (*port_new)(struct devlink *devlink, 1449 1448 const struct devlink_port_new_attrs *attrs, 1450 - struct netlink_ext_ack *extack); 1449 + struct netlink_ext_ack *extack, 1450 + struct devlink_port **devlink_port); 1451 1451 1452 1452 /** 1453 1453 * Rate control callbacks.
+27 -1
net/devlink/leftover.c
··· 1347 1347 struct netlink_ext_ack *extack = info->extack; 1348 1348 struct devlink_port_new_attrs new_attrs = {}; 1349 1349 struct devlink *devlink = info->user_ptr[0]; 1350 + struct devlink_port *devlink_port; 1351 + struct sk_buff *msg; 1352 + int err; 1350 1353 1351 1354 if (!devlink->ops->port_new) 1352 1355 return -EOPNOTSUPP; ··· 1380 1377 new_attrs.sfnum_valid = true; 1381 1378 } 1382 1379 1383 - return devlink->ops->port_new(devlink, &new_attrs, extack); 1380 + err = devlink->ops->port_new(devlink, &new_attrs, 1381 + extack, &devlink_port); 1382 + if (err) 1383 + return err; 1384 + 1385 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1386 + if (!msg) { 1387 + err = -ENOMEM; 1388 + goto err_out_port_del; 1389 + } 1390 + err = devlink_nl_port_fill(msg, devlink_port, DEVLINK_CMD_NEW, 1391 + info->snd_portid, info->snd_seq, 0, NULL); 1392 + if (WARN_ON_ONCE(err)) 1393 + goto err_out_msg_free; 1394 + err = genlmsg_reply(msg, info); 1395 + if (err) 1396 + goto err_out_port_del; 1397 + return 0; 1398 + 1399 + err_out_msg_free: 1400 + nlmsg_free(msg); 1401 + err_out_port_del: 1402 + devlink_port->ops->port_del(devlink, devlink_port, NULL); 1403 + return err; 1384 1404 } 1385 1405 1386 1406 static int devlink_nl_cmd_port_del_doit(struct sk_buff *skb,