Re: [PATCH net-next] devlink: prevent function configuration when port is active
Przemek Kitszel <[email protected]>
| Newsgroups | org.kernel.vger.netdev,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 8/10/26 12:32, Tariq Toukan wrote: > From: Oren Sidi <[email protected]> > > Reject port function parameter changes when the port is active. > Enforcing this insures configuration integrity and consistency. > > Signed-off-by: Oren Sidi <[email protected]> > Reviewed-by: Aya Levin <[email protected]> > Reviewed-by: Jiri Pirko <[email protected]> > Signed-off-by: Tariq Toukan <[email protected]> > --- > 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 <[email protected]> > + 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