From: Tariq Toukan <tariqt@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, <netdev@vger.kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Aya Levin <ayal@nvidia.com>, Gal Pressman <gal@nvidia.com>,
Jiri Pirko <jiri@nvidia.com>, Jiri Pirko <jiri@resnulli.us>,
<linux-kernel@vger.kernel.org>, Oren Sidi <osidi@nvidia.com>,
Simon Horman <horms@kernel.org>, Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net-next] devlink: prevent function configuration when port is active
Date: Mon, 10 Aug 2026 13:32:45 +0300 [thread overview]
Message-ID: <20260810103245.3162004-1-tariqt@nvidia.com> (raw)
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
next reply other threads:[~2026-08-10 10:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 10:32 Tariq Toukan [this message]
2026-08-10 13:52 ` [PATCH net-next] devlink: prevent function configuration when port is active Przemek Kitszel
2026-08-12 1:38 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260810103245.3162004-1-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=ayal@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jiri@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=osidi@nvidia.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.