netlink: introduce typedef for filter function

Make the code using filter function a bit nicer by consolidating the
filter function arguments using typedef.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Jiri Pirko 2023-12-16 13:29:58 +01:00 committed by Paolo Abeni
parent a731132424
commit 403863e985
4 changed files with 8 additions and 9 deletions

View File

@ -59,9 +59,8 @@ static int cn_already_initialized;
* both, or if both are zero then the group is looked up and sent there.
*/
int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group,
gfp_t gfp_mask,
int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data),
void *filter_data)
gfp_t gfp_mask, netlink_filter_fn filter,
void *filter_data)
{
struct cn_callback_entry *__cbq;
unsigned int size;

View File

@ -100,8 +100,7 @@ void cn_del_callback(const struct cb_id *id);
*/
int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid,
u32 group, gfp_t gfp_mask,
int (*filter)(struct sock *dsk, struct sk_buff *skb,
void *data),
netlink_filter_fn filter,
void *filter_data);
/**

View File

@ -228,10 +228,12 @@ bool netlink_strict_get_check(struct sk_buff *skb);
int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
__u32 group, gfp_t allocation);
typedef int (*netlink_filter_fn)(struct sock *dsk, struct sk_buff *skb, void *data);
int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
__u32 portid, __u32 group, gfp_t allocation,
int (*filter)(struct sock *dsk,
struct sk_buff *skb, void *data),
netlink_filter_fn filter,
void *filter_data);
int netlink_set_err(struct sock *ssk, __u32 portid, __u32 group, int code);
int netlink_register_notifier(struct notifier_block *nb);

View File

@ -1519,8 +1519,7 @@ out:
int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
u32 portid,
u32 group, gfp_t allocation,
int (*filter)(struct sock *dsk,
struct sk_buff *skb, void *data),
netlink_filter_fn filter,
void *filter_data)
{
struct net *net = sock_net(ssk);