Commit ddb6b284 authored by Pedro Tammela's avatar Pedro Tammela Committed by Jakub Kicinski

rtnl: add helper to send if skb is not null

This is a convenience helper for routines handling conditional rtnl
events, that is code that might send a notification depending on
rtnl_has_listeners/rtnl_notify_needed.

Instead of:
   if (skb)
      rtnetlink_send(...)

Use:
      rtnetlink_maybe_send(...)
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Link: https://lore.kernel.org/r/20231208192847.714940-4-pctammela@mojatatu.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8439109b
...@@ -10,6 +10,13 @@ ...@@ -10,6 +10,13 @@
#include <uapi/linux/rtnetlink.h> #include <uapi/linux/rtnetlink.h>
extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
static inline int rtnetlink_maybe_send(struct sk_buff *skb, struct net *net,
u32 pid, u32 group, int echo)
{
return !skb ? 0 : rtnetlink_send(skb, net, pid, group, echo);
}
extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid); extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
u32 group, const struct nlmsghdr *nlh, gfp_t flags); u32 group, const struct nlmsghdr *nlh, gfp_t flags);
......
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