Commit 8439109b authored by Victor Nogueira's avatar Victor Nogueira Committed by Jakub Kicinski

rtnl: add helper to check if a notification is needed

Building on the rtnl_has_listeners helper, add the rtnl_notify_needed
helper to check if we can bail out early in the notification routines.
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarVictor Nogueira <victor@mojatatu.com>
Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Link: https://lore.kernel.org/r/20231208192847.714940-3-pctammela@mojatatu.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c5e2a973
......@@ -137,4 +137,19 @@ static inline int rtnl_has_listeners(const struct net *net, u32 group)
return netlink_has_listeners(rtnl, group);
}
/**
* rtnl_notify_needed - check if notification is needed
* @net: Pointer to the net namespace
* @nlflags: netlink ingress message flags
* @group: rtnl group
*
* Based on the ingress message flags and rtnl group, returns true
* if a notification is needed, false otherwise.
*/
static inline bool
rtnl_notify_needed(const struct net *net, u16 nlflags, u32 group)
{
return (nlflags & NLM_F_ECHO) || rtnl_has_listeners(net, group);
}
#endif /* __LINUX_RTNETLINK_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment