Skip to content

Commit 403863e

Browse files
Jiri PirkoPaolo Abeni
authored andcommitted
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 <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent a731132 commit 403863e

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

drivers/connector/connector.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ static int cn_already_initialized;
5959
* both, or if both are zero then the group is looked up and sent there.
6060
*/
6161
int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group,
62-
gfp_t gfp_mask,
63-
int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data),
64-
void *filter_data)
62+
gfp_t gfp_mask, netlink_filter_fn filter,
63+
void *filter_data)
6564
{
6665
struct cn_callback_entry *__cbq;
6766
unsigned int size;

include/linux/connector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ void cn_del_callback(const struct cb_id *id);
100100
*/
101101
int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid,
102102
u32 group, gfp_t gfp_mask,
103-
int (*filter)(struct sock *dsk, struct sk_buff *skb,
104-
void *data),
103+
netlink_filter_fn filter,
105104
void *filter_data);
106105

107106
/**

include/linux/netlink.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ bool netlink_strict_get_check(struct sk_buff *skb);
228228
int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
229229
int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
230230
__u32 group, gfp_t allocation);
231+
232+
typedef int (*netlink_filter_fn)(struct sock *dsk, struct sk_buff *skb, void *data);
233+
231234
int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
232235
__u32 portid, __u32 group, gfp_t allocation,
233-
int (*filter)(struct sock *dsk,
234-
struct sk_buff *skb, void *data),
236+
netlink_filter_fn filter,
235237
void *filter_data);
236238
int netlink_set_err(struct sock *ssk, __u32 portid, __u32 group, int code);
237239
int netlink_register_notifier(struct notifier_block *nb);

net/netlink/af_netlink.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,7 @@ static void do_one_broadcast(struct sock *sk,
15191519
int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
15201520
u32 portid,
15211521
u32 group, gfp_t allocation,
1522-
int (*filter)(struct sock *dsk,
1523-
struct sk_buff *skb, void *data),
1522+
netlink_filter_fn filter,
15241523
void *filter_data)
15251524
{
15261525
struct net *net = sock_net(ssk);

0 commit comments

Comments
 (0)