summaryrefslogtreecommitdiff
path: root/net/devlink/devl_internal.h
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2023-12-16 13:29:55 +0100
committerPaolo Abeni <pabeni@redhat.com>2023-12-19 15:31:40 +0100
commitcddbff470e3318834af518168d3a917b6e975062 (patch)
tree2932277f4dfc374f098cf39b24f0b52b89efffbe /net/devlink/devl_internal.h
parent11280ddeae238e3ea27d153794472cfca5e8d121 (diff)
devlink: send notifications only if there are listeners
Introduce devlink_nl_notify_need() helper and using it to check at the beginning of notification functions to avoid overhead of composing notification messages in case nobody listens. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/devlink/devl_internal.h')
-rw-r--r--net/devlink/devl_internal.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index 59ae4761d10a..510990de094e 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -185,6 +185,12 @@ int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
struct devlink *devlink, int attrtype);
int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info);
+static inline bool devlink_nl_notify_need(struct devlink *devlink)
+{
+ return genl_has_listeners(&devlink_nl_family, devlink_net(devlink),
+ DEVLINK_MCGRP_CONFIG);
+}
+
/* Notify */
void devlink_notify_register(struct devlink *devlink);
void devlink_notify_unregister(struct devlink *devlink);