From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net,
edumazet@google.com, jacob.e.keller@intel.com, jhs@mojatatu.com,
johannes@sipsolutions.net, andriy.shevchenko@linux.intel.com,
amritha.nambiar@intel.com, sdf@google.com, horms@kernel.org
Subject: [patch net-next v3 6/9] netlink: introduce typedef for filter function
Date: Mon, 20 Nov 2023 09:46:54 +0100 [thread overview]
Message-ID: <20231120084657.458076-7-jiri@resnulli.us> (raw)
In-Reply-To: <20231120084657.458076-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
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>
---
v2->v3:
- left the original .c and .h arg names and types
inconsistencies for cn_netlink_send_mult() and
netlink_broadcast_filtered()
v1->v2:
- new patch
---
drivers/connector/connector.c | 5 ++---
include/linux/connector.h | 3 +--
include/linux/netlink.h | 6 ++++--
net/netlink/af_netlink.c | 3 +--
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 7f7b94f616a6..4028e8eeba82 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -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;
diff --git a/include/linux/connector.h b/include/linux/connector.h
index cec2d99ae902..70bc1160f3d8 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -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);
/**
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 75d7de34c908..d30f599a4c6b 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -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);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index eb086b06d60d..c81dc7c60e02 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1520,8 +1520,7 @@ static void do_one_broadcast(struct sock *sk,
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);
--
2.41.0
next prev parent reply other threads:[~2023-11-20 8:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 8:46 [patch net-next v3 0/9] devlink: introduce notifications filtering Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 1/9] devlink: use devl_is_registered() helper instead xa_get_mark() Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 2/9] devlink: introduce __devl_is_registered() helper and use it instead of xa_get_mark() Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 3/9] devlink: send notifications only if there are listeners Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 4/9] devlink: introduce a helper for netlink multicast send Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 5/9] genetlink: implement release callback and free sk_user_data there Jiri Pirko
2023-11-21 2:50 ` Jakub Kicinski
2023-11-21 7:36 ` Jiri Pirko
2023-11-21 13:12 ` Jiri Pirko
2023-11-21 17:55 ` Jakub Kicinski
2023-11-22 9:29 ` Jiri Pirko
2023-11-22 17:08 ` Jakub Kicinski
2023-11-22 18:20 ` Jiri Pirko
2023-11-22 19:50 ` Jakub Kicinski
2023-11-23 6:37 ` Jiri Pirko
2023-11-23 10:32 ` Jiri Pirko
2023-11-23 16:24 ` Jakub Kicinski
2023-11-23 16:53 ` Jiri Pirko
2023-11-20 8:46 ` Jiri Pirko [this message]
2023-11-20 8:46 ` [patch net-next v3 7/9] genetlink: introduce helpers to do filtered multicast Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 8/9] devlink: add a command to set notification filter and use it for multicasts Jiri Pirko
2023-11-21 2:51 ` Jakub Kicinski
2023-11-21 7:35 ` Jiri Pirko
2023-11-20 8:46 ` [patch net-next v3 9/9] devlink: extend multicast filtering by port index Jiri Pirko
2023-11-21 2:29 ` [patch net-next v3 0/9] devlink: introduce notifications filtering Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231120084657.458076-7-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=amritha.nambiar@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jhs@mojatatu.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).