* [PATCH net-next] devlink: prevent function configuration when port is active
@ 2026-08-10 10:32 Tariq Toukan
2026-08-10 13:52 ` Przemek Kitszel
0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-08-10 10:32 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Aya Levin, Gal Pressman, Jiri Pirko, Jiri Pirko, linux-kernel,
Oren Sidi, Simon Horman, Tariq Toukan
From: Oren Sidi <osidi@nvidia.com>
Reject port function parameter changes when the port is active.
Enforcing this insures configuration integrity and consistency.
Signed-off-by: Oren Sidi <osidi@nvidia.com>
Reviewed-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
net/devlink/port.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/net/devlink/port.c b/net/devlink/port.c
index 1528f2d148df..6a9857bf79da 100644
--- a/net/devlink/port.c
+++ b/net/devlink/port.c
@@ -708,7 +708,10 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port,
struct netlink_ext_ack *extack)
{
const struct devlink_port_ops *ops = devlink_port->ops;
+ enum devlink_port_fn_opstate opstate;
+ enum devlink_port_fn_state state;
struct nlattr *attr;
+ int err;
if (tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] &&
!ops->port_fn_hw_addr_set) {
@@ -721,6 +724,20 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port,
"Function does not support state setting");
return -EOPNOTSUPP;
}
+ if (devlink_port->attrs.flavour == DEVLINK_PORT_FLAVOUR_PCI_SF &&
+ ops->port_fn_state_get && !tb[DEVLINK_PORT_FN_ATTR_STATE]) {
+ err = ops->port_fn_state_get(devlink_port, &state,
+ &opstate, extack);
+ if (err)
+ return err;
+
+ if (state == DEVLINK_PORT_FN_STATE_ACTIVE) {
+ NL_SET_ERR_MSG(extack,
+ "port function parameters can't be configured when port is up");
+ return -EINVAL;
+ }
+ }
+
attr = tb[DEVLINK_PORT_FN_ATTR_CAPS];
if (attr) {
struct nla_bitfield32 caps;
base-commit: 001b5d347d8ba39b2dccaefcc57967b18caec8fe
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] devlink: prevent function configuration when port is active
2026-08-10 10:32 [PATCH net-next] devlink: prevent function configuration when port is active Tariq Toukan
@ 2026-08-10 13:52 ` Przemek Kitszel
0 siblings, 0 replies; 2+ messages in thread
From: Przemek Kitszel @ 2026-08-10 13:52 UTC (permalink / raw)
To: Tariq Toukan, Oren Sidi
Cc: Aya Levin, Gal Pressman, Jiri Pirko, Jiri Pirko, linux-kernel,
Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, netdev, Paolo Abeni
On 8/10/26 12:32, Tariq Toukan wrote:
> From: Oren Sidi <osidi@nvidia.com>
>
> Reject port function parameter changes when the port is active.
> Enforcing this insures configuration integrity and consistency.
>
> Signed-off-by: Oren Sidi <osidi@nvidia.com>
> Reviewed-by: Aya Levin <ayal@nvidia.com>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> net/devlink/port.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/net/devlink/port.c b/net/devlink/port.c
> index 1528f2d148df..6a9857bf79da 100644
> --- a/net/devlink/port.c
> +++ b/net/devlink/port.c
> @@ -708,7 +708,10 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port,
> struct netlink_ext_ack *extack)
> {
> const struct devlink_port_ops *ops = devlink_port->ops;
> + enum devlink_port_fn_opstate opstate;
> + enum devlink_port_fn_state state;
> struct nlattr *attr;
> + int err;
>
> if (tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] &&
> !ops->port_fn_hw_addr_set) {
> @@ -721,6 +724,20 @@ static int devlink_port_function_validate(struct devlink_port *devlink_port,
> "Function does not support state setting");
> return -EOPNOTSUPP;
> }
> + if (devlink_port->attrs.flavour == DEVLINK_PORT_FLAVOUR_PCI_SF &&
nit: this is the only place that marks the logic only for SUBFUNCTION,
would be good to amend commit message/subject line:
s/function/subfunction/ # for the subject
with or without the above:
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> + ops->port_fn_state_get && !tb[DEVLINK_PORT_FN_ATTR_STATE]) {
> + err = ops->port_fn_state_get(devlink_port, &state,
> + &opstate, extack);
> + if (err)
> + return err;
> +
> + if (state == DEVLINK_PORT_FN_STATE_ACTIVE) {
> + NL_SET_ERR_MSG(extack,
> + "port function parameters can't be configured when port is up");
> + return -EINVAL;
> + }
> + }
> +
> attr = tb[DEVLINK_PORT_FN_ATTR_CAPS];
> if (attr) {
> struct nla_bitfield32 caps;
>
> base-commit: 001b5d347d8ba39b2dccaefcc57967b18caec8fe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-10 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 10:32 [PATCH net-next] devlink: prevent function configuration when port is active Tariq Toukan
2026-08-10 13:52 ` Przemek Kitszel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox