From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Parav Pandit <parav@nvidia.com>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org
Cc: jiri@resnulli.us, Jiri Pirko <jiri@nvidia.com>
Subject: Re: [PATCH net-next 1/2] devlink/port: Check attributes early and constify
Date: Tue, 12 Aug 2025 13:56:57 +0100 [thread overview]
Message-ID: <5bf50cb2-31c6-4391-a09e-a73fd84fe051@linux.dev> (raw)
In-Reply-To: <20250812035106.134529-2-parav@nvidia.com>
On 12/08/2025 04:51, Parav Pandit wrote:
> Constify the devlink port attributes to indicate they are read only
> and does not depend on anything else. Therefore, validate it early
> before setting in the devlink port.
>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Parav Pandit <parav@nvidia.com>
> ---
> include/net/devlink.h | 2 +-
> net/devlink/port.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/devlink.h b/include/net/devlink.h
> index 93640a29427c..c6f3afa92c8f 100644
> --- a/include/net/devlink.h
> +++ b/include/net/devlink.h
> @@ -1739,7 +1739,7 @@ void devlink_port_type_ib_set(struct devlink_port *devlink_port,
> struct ib_device *ibdev);
> void devlink_port_type_clear(struct devlink_port *devlink_port);
> void devlink_port_attrs_set(struct devlink_port *devlink_port,
> - struct devlink_port_attrs *devlink_port_attrs);
> + const struct devlink_port_attrs *dl_port_attrs);
> void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 controller,
> u16 pf, bool external);
> void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller,
> diff --git a/net/devlink/port.c b/net/devlink/port.c
> index 939081a0e615..1033b9ad2af4 100644
> --- a/net/devlink/port.c
> +++ b/net/devlink/port.c
> @@ -1357,17 +1357,17 @@ static int __devlink_port_attrs_set(struct devlink_port *devlink_port,
> * @attrs: devlink port attrs
> */
> void devlink_port_attrs_set(struct devlink_port *devlink_port,
> - struct devlink_port_attrs *attrs)
> + const struct devlink_port_attrs *attrs)
> {
> int ret;
>
> ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port);
> + WARN_ON(attrs->splittable && attrs->split);
>
> devlink_port->attrs = *attrs;
> ret = __devlink_port_attrs_set(devlink_port, attrs->flavour);
> if (ret)
> return;
> - WARN_ON(attrs->splittable && attrs->split);
After this change there is no need for local variable and the "if" block
> }
> EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
>
next prev parent reply other threads:[~2025-08-12 12:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 3:51 [PATCH net-next 0/2] devlink port attr cleanup Parav Pandit
2025-08-12 3:51 ` [PATCH net-next 1/2] devlink/port: Check attributes early and constify Parav Pandit
2025-08-12 12:56 ` Vadim Fedorenko [this message]
2025-08-12 14:46 ` Jakub Kicinski
2025-08-12 16:20 ` Parav Pandit
2025-08-12 3:51 ` [PATCH net-next 2/2] devlink/port: Simplify return checks Parav Pandit
2025-08-12 12:59 ` Vadim Fedorenko
2025-08-12 13:45 ` Parav Pandit
2025-08-12 14:47 ` Jakub Kicinski
2025-08-12 16:21 ` Parav Pandit
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=5bf50cb2-31c6-4391-a09e-a73fd84fe051@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).