Message ID | 20231204203907.413435-4-pctammela@mojatatu.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net/sched: conditional notification of events for cls and act | expand |
Mon, Dec 04, 2023 at 09:39:05PM CET, pctammela@mojatatu.com wrote: >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(...) > >Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 0cbbbded0331..6a8543b34e2c 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -10,6 +10,13 @@ #include <uapi/linux/rtnetlink.h> 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 void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, const struct nlmsghdr *nlh, gfp_t flags);
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(...) Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> --- include/linux/rtnetlink.h | 7 +++++++ 1 file changed, 7 insertions(+)