All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: netlink: remove netlink_broadcast_filtered
@ 2021-03-09 15:18 menglong8.dong
  2021-05-26  9:28 ` Daniel Lezcano
  0 siblings, 1 reply; 3+ messages in thread
From: menglong8.dong @ 2021-03-09 15:18 UTC (permalink / raw)
  To: kuba
  Cc: davem, mkubecek, dsahern, zhudi21, johannes.berg,
	marcelo.leitner, dong.menglong, ast, yhs, rdunlap, yangyingliang,
	0x7f454c46, linux-kernel, netdev

From: Menglong Dong <dong.menglong@zte.com.cn>

It seems that 'netlink_broadcast_filtered()' is not used anywhere
besides 'netlink_broadcast()'. In order to reduce function calls,
just remove it.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
 include/linux/netlink.h  |  4 ----
 net/netlink/af_netlink.c | 22 ++--------------------
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 0bcf98098c5a..277f33e64bb3 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -160,10 +160,6 @@ 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);
-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),
-			       void *filter_data);
 int netlink_set_err(struct sock *ssk, __u32 portid, __u32 group, int code);
 int netlink_register_notifier(struct notifier_block *nb);
 int netlink_unregister_notifier(struct notifier_block *nb);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index dd488938447f..b462fdc87e9b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1405,8 +1405,6 @@ struct netlink_broadcast_data {
 	int delivered;
 	gfp_t allocation;
 	struct sk_buff *skb, *skb2;
-	int (*tx_filter)(struct sock *dsk, struct sk_buff *skb, void *data);
-	void *tx_data;
 };
 
 static void do_one_broadcast(struct sock *sk,
@@ -1460,11 +1458,6 @@ static void do_one_broadcast(struct sock *sk,
 			p->delivery_failure = 1;
 		goto out;
 	}
-	if (p->tx_filter && p->tx_filter(sk, p->skb2, p->tx_data)) {
-		kfree_skb(p->skb2);
-		p->skb2 = NULL;
-		goto out;
-	}
 	if (sk_filter(sk, p->skb2)) {
 		kfree_skb(p->skb2);
 		p->skb2 = NULL;
@@ -1487,10 +1480,8 @@ static void do_one_broadcast(struct sock *sk,
 	sock_put(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),
-	void *filter_data)
+int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid,
+		      u32 group, gfp_t allocation)
 {
 	struct net *net = sock_net(ssk);
 	struct netlink_broadcast_data info;
@@ -1509,8 +1500,6 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid
 	info.allocation = allocation;
 	info.skb = skb;
 	info.skb2 = NULL;
-	info.tx_filter = filter;
-	info.tx_data = filter_data;
 
 	/* While we sleep in clone, do not allow to change socket list */
 
@@ -1536,14 +1525,7 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid
 	}
 	return -ESRCH;
 }
-EXPORT_SYMBOL(netlink_broadcast_filtered);
 
-int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid,
-		      u32 group, gfp_t allocation)
-{
-	return netlink_broadcast_filtered(ssk, skb, portid, group, allocation,
-		NULL, NULL);
-}
 EXPORT_SYMBOL(netlink_broadcast);
 
 struct netlink_set_err_data {
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: netlink: remove netlink_broadcast_filtered
  2021-03-09 15:18 [PATCH net-next] net: netlink: remove netlink_broadcast_filtered menglong8.dong
@ 2021-05-26  9:28 ` Daniel Lezcano
  2021-05-26 12:22   ` Menglong Dong
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2021-05-26  9:28 UTC (permalink / raw)
  To: menglong8.dong, kuba
  Cc: davem, mkubecek, dsahern, zhudi21, johannes.berg,
	marcelo.leitner, dong.menglong, ast, yhs, rdunlap, yangyingliang,
	0x7f454c46, linux-kernel, netdev

On 09/03/2021 16:18, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <dong.menglong@zte.com.cn>
> 
> It seems that 'netlink_broadcast_filtered()' is not used anywhere
> besides 'netlink_broadcast()'. In order to reduce function calls,
> just remove it.
> 
> Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>

I was trying to figure out if the function could be useful to filter out
some netlink messages when sending them to userspace.

Still looking for examples :/

On the other side, this function was put there as part of the network
namespace infrastructure. Even there is no user, it may be needed.

> ---
>  include/linux/netlink.h  |  4 ----
>  net/netlink/af_netlink.c | 22 ++--------------------
>  2 files changed, 2 insertions(+), 24 deletions(-)
> 
> diff --git a/include/linux/netlink.h b/include/linux/netlink.h
> index 0bcf98098c5a..277f33e64bb3 100644
> --- a/include/linux/netlink.h
> +++ b/include/linux/netlink.h
> @@ -160,10 +160,6 @@ 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);
> -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),
> -			       void *filter_data);
>  int netlink_set_err(struct sock *ssk, __u32 portid, __u32 group, int code);
>  int netlink_register_notifier(struct notifier_block *nb);
>  int netlink_unregister_notifier(struct notifier_block *nb);
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index dd488938447f..b462fdc87e9b 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -1405,8 +1405,6 @@ struct netlink_broadcast_data {
>  	int delivered;
>  	gfp_t allocation;
>  	struct sk_buff *skb, *skb2;
> -	int (*tx_filter)(struct sock *dsk, struct sk_buff *skb, void *data);
> -	void *tx_data;
>  };
>  
>  static void do_one_broadcast(struct sock *sk,
> @@ -1460,11 +1458,6 @@ static void do_one_broadcast(struct sock *sk,
>  			p->delivery_failure = 1;
>  		goto out;
>  	}
> -	if (p->tx_filter && p->tx_filter(sk, p->skb2, p->tx_data)) {
> -		kfree_skb(p->skb2);
> -		p->skb2 = NULL;
> -		goto out;
> -	}
>  	if (sk_filter(sk, p->skb2)) {
>  		kfree_skb(p->skb2);
>  		p->skb2 = NULL;
> @@ -1487,10 +1480,8 @@ static void do_one_broadcast(struct sock *sk,
>  	sock_put(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),
> -	void *filter_data)
> +int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid,
> +		      u32 group, gfp_t allocation)
>  {
>  	struct net *net = sock_net(ssk);
>  	struct netlink_broadcast_data info;
> @@ -1509,8 +1500,6 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid
>  	info.allocation = allocation;
>  	info.skb = skb;
>  	info.skb2 = NULL;
> -	info.tx_filter = filter;
> -	info.tx_data = filter_data;
>  
>  	/* While we sleep in clone, do not allow to change socket list */
>  
> @@ -1536,14 +1525,7 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid
>  	}
>  	return -ESRCH;
>  }
> -EXPORT_SYMBOL(netlink_broadcast_filtered);
>  
> -int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid,
> -		      u32 group, gfp_t allocation)
> -{
> -	return netlink_broadcast_filtered(ssk, skb, portid, group, allocation,
> -		NULL, NULL);
> -}
>  EXPORT_SYMBOL(netlink_broadcast);
>  
>  struct netlink_set_err_data {
> 


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: netlink: remove netlink_broadcast_filtered
  2021-05-26  9:28 ` Daniel Lezcano
@ 2021-05-26 12:22   ` Menglong Dong
  0 siblings, 0 replies; 3+ messages in thread
From: Menglong Dong @ 2021-05-26 12:22 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Jakub Kicinski, David Miller, mkubecek, dsahern, zhudi21,
	johannes.berg, marcelo.leitner, Menglong Dong, ast, yhs, rdunlap,
	yangyingliang, 0x7f454c46, LKML, netdev

On Wed, May 26, 2021 at 5:28 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
[...]
>
> I was trying to figure out if the function could be useful to filter out
> some netlink messages when sending them to userspace.
>
> Still looking for examples :/
>
> On the other side, this function was put there as part of the network
> namespace infrastructure. Even there is no user, it may be needed.
>

I noticed that the function has not been used since it was added over
ten years ago, and thought that it may not be used in the future.

If you think it may be needed, let's just keep it!

Thanks!
Menglong Dong

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26 12:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 15:18 [PATCH net-next] net: netlink: remove netlink_broadcast_filtered menglong8.dong
2021-05-26  9:28 ` Daniel Lezcano
2021-05-26 12:22   ` Menglong Dong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.