netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Jiri Pirko <jiri@resnulli.us>, <netdev@vger.kernel.org>
Cc: <kuba@kernel.org>, <pabeni@redhat.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <jacob.e.keller@intel.com>,
	<jhs@mojatatu.com>, <johannes@sipsolutions.net>,
	<andriy.shevchenko@linux.intel.com>, <amritha.nambiar@intel.com>,
	<sdf@google.com>, <horms@kernel.org>
Subject: Re: [patch net-next v4 8/9] devlink: add a command to set notification filter and use it for multicasts
Date: Mon, 27 Nov 2023 13:30:04 +0100	[thread overview]
Message-ID: <98ece061-f21d-bc21-815a-19f34584f268@intel.com> (raw)
In-Reply-To: <20231123181546.521488-9-jiri@resnulli.us>

On 11/23/23 19:15, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Currently the user listening on a socket for devlink notifications
> gets always all messages for all existing instances, even if he is
> interested only in one of those. That may cause unnecessary overhead
> on setups with thousands of instances present.
> 
> User is currently able to narrow down the devlink objects replies
> to dump commands by specifying select attributes.
> 
> Allow similar approach for notifications. Introduce a new devlink
> NOTIFY_FILTER_SET which the user passes the select attributes. Store
> these per-socket and use them for filtering messages
> during multicast send.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
> v3->v4:
> - rebased on top of genl_sk_priv_*() introduction
> ---
>   Documentation/netlink/specs/devlink.yaml | 10 ++++
>   include/uapi/linux/devlink.h             |  2 +
>   net/devlink/devl_internal.h              | 34 ++++++++++-
>   net/devlink/netlink.c                    | 73 ++++++++++++++++++++++++
>   net/devlink/netlink_gen.c                | 15 ++++-
>   net/devlink/netlink_gen.h                |  4 +-
>   tools/net/ynl/generated/devlink-user.c   | 31 ++++++++++
>   tools/net/ynl/generated/devlink-user.h   | 47 +++++++++++++++
>   8 files changed, 212 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml
> index 43067e1f63aa..6bad1d3454b7 100644
> --- a/Documentation/netlink/specs/devlink.yaml
> +++ b/Documentation/netlink/specs/devlink.yaml
> @@ -2055,3 +2055,13 @@ operations:
>               - bus-name
>               - dev-name
>               - selftests
> +
> +    -
> +      name: notify-filter-set
> +      doc: Set notification messages socket filter.
> +      attribute-set: devlink
> +      do:
> +        request:
> +          attributes:
> +            - bus-name
> +            - dev-name
> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
> index b3c8383d342d..130cae0d3e20 100644
> --- a/include/uapi/linux/devlink.h
> +++ b/include/uapi/linux/devlink.h
> @@ -139,6 +139,8 @@ enum devlink_command {
>   	DEVLINK_CMD_SELFTESTS_GET,	/* can dump */
>   	DEVLINK_CMD_SELFTESTS_RUN,
>   
> +	DEVLINK_CMD_NOTIFY_FILTER_SET,
> +
>   	/* add new commands above here */
>   	__DEVLINK_CMD_MAX,
>   	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
> diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
> index 84dc9628d3f2..82e0fb3bbebf 100644
> --- a/net/devlink/devl_internal.h
> +++ b/net/devlink/devl_internal.h
> @@ -191,11 +191,41 @@ static inline bool devlink_nl_notify_need(struct devlink *devlink)
>   				  DEVLINK_MCGRP_CONFIG);
>   }
>   
> +struct devlink_obj_desc {
> +	struct rcu_head rcu;
> +	const char *bus_name;
> +	const char *dev_name;
> +	long data[];

could you please remove that data pointer?,
you are not using desc as flex pointer as of now

> +};
> +
> +static inline void devlink_nl_obj_desc_init(struct devlink_obj_desc *desc,

given next patch of the series with port index, you could rename this
function to devlink_nl_obj_desc_names_set(), and move 0-init outside.

> +					    struct devlink *devlink)
> +{
> +	memset(desc, 0, sizeof(*desc));
> +	desc->bus_name = devlink->dev->bus->name;
> +	desc->dev_name = dev_name(devlink->dev);
> +}
> +
> +int devlink_nl_notify_filter(struct sock *dsk, struct sk_buff *skb, void *data);
> +
> +static inline void devlink_nl_notify_send_desc(struct devlink *devlink,
> +					       struct sk_buff *msg,
> +					       struct devlink_obj_desc *desc)
> +{
> +	genlmsg_multicast_netns_filtered(&devlink_nl_family,
> +					 devlink_net(devlink),
> +					 msg, 0, DEVLINK_MCGRP_CONFIG,
> +					 GFP_KERNEL,
> +					 devlink_nl_notify_filter, desc);
> +}
> +
>   static inline void devlink_nl_notify_send(struct devlink *devlink,
>   					  struct sk_buff *msg)
>   {
> -	genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink),
> -				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
> +	struct devlink_obj_desc desc;

`= {};` would wipe out the need for memset().

> +
> +	devlink_nl_obj_desc_init(&desc, devlink);
> +	devlink_nl_notify_send_desc(devlink, msg, &desc);
>   }
>   
>   /* Notify */

[snip]

  reply	other threads:[~2023-11-27 12:30 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 18:15 [patch net-next v4 0/9] devlink: introduce notifications filtering Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 1/9] devlink: use devl_is_registered() helper instead xa_get_mark() Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 2/9] devlink: introduce __devl_is_registered() helper and use it instead of xa_get_mark() Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 3/9] devlink: send notifications only if there are listeners Jiri Pirko
2023-11-27 11:01   ` Paolo Abeni
2023-11-27 12:04     ` Jiri Pirko
2023-11-27 15:00       ` Paolo Abeni
2023-11-28  7:39         ` Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 4/9] devlink: introduce a helper for netlink multicast send Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 5/9] genetlink: introduce per-sock family private pointer storage Jiri Pirko
2023-11-27 11:13   ` Paolo Abeni
2023-11-27 12:00     ` Jiri Pirko
2023-11-27 22:46   ` Jakub Kicinski
2023-11-28  8:25     ` Jiri Pirko
2023-11-28 15:11       ` Jakub Kicinski
2023-11-28 16:05         ` Jiri Pirko
2023-11-28 16:36           ` Jakub Kicinski
2023-11-29 13:59             ` Jiri Pirko
2023-11-29 15:01               ` Jakub Kicinski
2023-11-29 15:25                 ` Jiri Pirko
2023-11-28 12:30   ` Przemek Kitszel
2023-11-28 15:05     ` Jiri Pirko
2023-11-28 16:18     ` Andy Shevchenko
2023-11-28 19:59       ` Jacob Keller
2023-11-28 20:06         ` Andy Shevchenko
2023-11-29 23:29           ` Jacob Keller
2023-11-23 18:15 ` [patch net-next v4 6/9] netlink: introduce typedef for filter function Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 7/9] genetlink: introduce helpers to do filtered multicast Jiri Pirko
2023-11-23 18:15 ` [patch net-next v4 8/9] devlink: add a command to set notification filter and use it for multicasts Jiri Pirko
2023-11-27 12:30   ` Przemek Kitszel [this message]
2023-11-27 12:51     ` Jiri Pirko
2023-11-27 12:56       ` Jiri Pirko
2023-11-27 15:40   ` Przemek Kitszel
2023-11-28  8:26     ` Jiri Pirko
2023-12-04 16:24     ` Jiri Pirko
2023-12-04 16:47       ` Andy Shevchenko
2023-12-04 19:17       ` Keller, Jacob E
2023-12-05  7:47         ` Jiri Pirko
2023-12-05 15:58           ` andriy.shevchenko
2023-11-23 18:15 ` [patch net-next v4 9/9] devlink: extend multicast filtering by port index Jiri Pirko

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=98ece061-f21d-bc21-815a-19f34584f268@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=amritha.nambiar@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.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).