Netdev List
 help / color / mirror / Atom feed
* [PATCH 09/11] xfrm: pass xfrm_user module to netlink_dump_start
From: Gao feng @ 2012-09-26  4:52 UTC (permalink / raw)
  To: davem
  Cc: netfilter-devel, linux-rdma, netdev, eric.dumazet, pablo,
	steffen.klassert, linux-crypto, jengelh, stephen.hemminger,
	Gao feng
In-Reply-To: <1348635140-20225-1-git-send-email-gaofeng@cn.fujitsu.com>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/xfrm/xfrm_user.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 289f4bf..fb6b06b 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -867,6 +867,7 @@ static int xfrm_dump_sa_done(struct netlink_callback *cb)
 {
 	struct xfrm_state_walk *walk = (struct xfrm_state_walk *) &cb->args[1];
 	xfrm_state_walk_done(walk);
+	netlink_dump_done(cb);
 	return 0;
 }
 
@@ -1538,6 +1539,7 @@ static int xfrm_dump_policy_done(struct netlink_callback *cb)
 	struct xfrm_policy_walk *walk = (struct xfrm_policy_walk *) &cb->args[1];
 
 	xfrm_policy_walk_done(walk);
+	netlink_dump_done(cb);
 	return 0;
 }
 
@@ -2308,17 +2310,20 @@ static struct xfrm_link {
 	int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **);
 	int (*dump)(struct sk_buff *, struct netlink_callback *);
 	int (*done)(struct netlink_callback *);
+	struct module *module;
 } xfrm_dispatch[XFRM_NR_MSGTYPES] = {
 	[XFRM_MSG_NEWSA       - XFRM_MSG_BASE] = { .doit = xfrm_add_sa        },
 	[XFRM_MSG_DELSA       - XFRM_MSG_BASE] = { .doit = xfrm_del_sa        },
 	[XFRM_MSG_GETSA       - XFRM_MSG_BASE] = { .doit = xfrm_get_sa,
 						   .dump = xfrm_dump_sa,
-						   .done = xfrm_dump_sa_done  },
+						   .done = xfrm_dump_sa_done,
+						   .module = THIS_MODULE      },
 	[XFRM_MSG_NEWPOLICY   - XFRM_MSG_BASE] = { .doit = xfrm_add_policy    },
 	[XFRM_MSG_DELPOLICY   - XFRM_MSG_BASE] = { .doit = xfrm_get_policy    },
 	[XFRM_MSG_GETPOLICY   - XFRM_MSG_BASE] = { .doit = xfrm_get_policy,
 						   .dump = xfrm_dump_policy,
-						   .done = xfrm_dump_policy_done },
+						   .done = xfrm_dump_policy_done,
+						   .module = THIS_MODULE      },
 	[XFRM_MSG_ALLOCSPI    - XFRM_MSG_BASE] = { .doit = xfrm_alloc_userspi },
 	[XFRM_MSG_ACQUIRE     - XFRM_MSG_BASE] = { .doit = xfrm_add_acquire   },
 	[XFRM_MSG_EXPIRE      - XFRM_MSG_BASE] = { .doit = xfrm_add_sa_expire },
@@ -2362,6 +2367,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 			struct netlink_dump_control c = {
 				.dump = link->dump,
 				.done = link->done,
+				.module = link->module,
 			};
 			return netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c);
 		}
-- 
1.7.7.6

^ permalink raw reply related

* Re: [PATCH 01/11] netlink: add reference of module in netlink_dump_start
From: Steffen Klassert @ 2012-09-26  5:41 UTC (permalink / raw)
  To: Gao feng
  Cc: davem, netfilter-devel, linux-rdma, netdev, eric.dumazet, pablo,
	linux-crypto, jengelh, stephen.hemminger
In-Reply-To: <1348635140-20225-1-git-send-email-gaofeng@cn.fujitsu.com>

On Wed, Sep 26, 2012 at 12:52:10PM +0800, Gao feng wrote:
> +
>  int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>  		       const struct nlmsghdr *nlh,
>  		       struct netlink_dump_control *control)
> @@ -1786,6 +1794,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>  	cb->done = control->done;
>  	cb->nlh = nlh;
>  	cb->data = control->data;
> +	cb->module = control->module;
>  	cb->min_dump_alloc = control->min_dump_alloc;
>  	atomic_inc(&skb->users);
>  	cb->skb = skb;
> @@ -1796,19 +1805,27 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>  		return -ECONNREFUSED;
>  	}
>  	nlk = nlk_sk(sk);
> -	/* A dump is in progress... */
> +
>  	mutex_lock(nlk->cb_mutex);
> +	/* A dump is in progress... */
>  	if (nlk->cb) {
>  		mutex_unlock(nlk->cb_mutex);
>  		netlink_destroy_callback(cb);
> -		sock_put(sk);
> -		return -EBUSY;
> +		ret = -EBUSY;
> +		goto out;
> +	}
> +	/* add reference of module witch cb->dump belone to */
> +	if (cb->module && !try_module_get(cb->module)) {
> +		mutex_unlock(nlk->cb_mutex);
> +		ret = -EPROTONOSUPPORT;
> +		goto out;

Looks like you leak the allocated netlink_callback here.
You should call netlink_destroy_callback() before you exit.

>  	}
> +
>  	nlk->cb = cb;
>  	mutex_unlock(nlk->cb_mutex);
>  
>  	ret = netlink_dump(sk);
> -
> +out:
>  	sock_put(sk);
>  
>  	if (ret)
> -- 

^ permalink raw reply

* Re: [PATCH 08/11] crypto: pass crypto_user module to netlink_dump_start
From: Steffen Klassert @ 2012-09-26  5:49 UTC (permalink / raw)
  To: Gao feng
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, jengelh-9+2X+4sQBs8,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA, Herbert Xu
In-Reply-To: <1348635140-20225-8-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

On Wed, Sep 26, 2012 at 12:52:17PM +0800, Gao feng wrote:
> use proper netlink_dump_control.done and .module to avoid panic.
> 
> Signed-off-by: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
> Cc: Herbert Xu <herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
> ---
>  crypto/crypto_user.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
> index ba2c611..b5cb32b 100644
> --- a/crypto/crypto_user.c
> +++ b/crypto/crypto_user.c
> @@ -249,6 +249,7 @@ out_err:
>  
>  static int crypto_dump_report_done(struct netlink_callback *cb)
>  {
> +	netlink_dump_done(cb);
>  	return 0;

It's probaply better to return the return value of netlink_dump_done()
instead. Right now, netlink_dump_done() returns 0 in any case,
but this might change over time.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 01/11] netlink: add reference of module in netlink_dump_start
From: Gao feng @ 2012-09-26  6:05 UTC (permalink / raw)
  To: Steffen Klassert
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, jengelh-9+2X+4sQBs8,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA
In-Reply-To: <20120926054102.GD4221-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org>

于 2012年09月26日 13:41, Steffen Klassert 写道:
> On Wed, Sep 26, 2012 at 12:52:10PM +0800, Gao feng wrote:
>> +
>>  int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>>  		       const struct nlmsghdr *nlh,
>>  		       struct netlink_dump_control *control)
>> @@ -1786,6 +1794,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>>  	cb->done = control->done;
>>  	cb->nlh = nlh;
>>  	cb->data = control->data;
>> +	cb->module = control->module;
>>  	cb->min_dump_alloc = control->min_dump_alloc;
>>  	atomic_inc(&skb->users);
>>  	cb->skb = skb;
>> @@ -1796,19 +1805,27 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>>  		return -ECONNREFUSED;
>>  	}
>>  	nlk = nlk_sk(sk);
>> -	/* A dump is in progress... */
>> +
>>  	mutex_lock(nlk->cb_mutex);
>> +	/* A dump is in progress... */
>>  	if (nlk->cb) {
>>  		mutex_unlock(nlk->cb_mutex);
>>  		netlink_destroy_callback(cb);
>> -		sock_put(sk);
>> -		return -EBUSY;
>> +		ret = -EBUSY;
>> +		goto out;
>> +	}
>> +	/* add reference of module witch cb->dump belone to */
>> +	if (cb->module && !try_module_get(cb->module)) {
>> +		mutex_unlock(nlk->cb_mutex);
>> +		ret = -EPROTONOSUPPORT;
>> +		goto out;
> 
> Looks like you leak the allocated netlink_callback here.
> You should call netlink_destroy_callback() before you exit.
> 

oops, I will fix it,thanks very much!
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 01/11] netlink: add reference of module in netlink_dump_start
From: Eric Dumazet @ 2012-09-26  7:07 UTC (permalink / raw)
  To: Gao feng
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	pablo-Cap9r6Oaw4JrovVCs/uTlw,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, jengelh-9+2X+4sQBs8,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA
In-Reply-To: <1348635140-20225-1-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

On Wed, 2012-09-26 at 12:52 +0800, Gao feng wrote:

> +int netlink_dump_done(struct netlink_callback *cb)
> +{
> +	if (cb->module)
> +		module_put(cb->module);
> +	return 0;
> +}
> +EXPORT_SYMBOL(netlink_dump_done);
> +

No need to test cb->module being not NULL


int netlink_dump_done(struct netlink_callback *cb)
{
	module_put(cb->module);
	return 0;
}

Same remark for try_module_get() call


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 08/11] crypto: pass crypto_user module to netlink_dump_start
From: Gao feng @ 2012-09-26  7:21 UTC (permalink / raw)
  To: Steffen Klassert
  Cc: davem, netfilter-devel, linux-rdma, netdev, eric.dumazet, pablo,
	linux-crypto, jengelh, stephen.hemminger, Herbert Xu
In-Reply-To: <20120926054945.GE4221@secunet.com>

于 2012年09月26日 13:49, Steffen Klassert 写道:
> On Wed, Sep 26, 2012 at 12:52:17PM +0800, Gao feng wrote:
>> use proper netlink_dump_control.done and .module to avoid panic.
>>
>> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
>> Cc: Herbert Xu <herbert@gondor.apana.org.au>
>> ---
>>  crypto/crypto_user.c |    6 +++++-
>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
>> index ba2c611..b5cb32b 100644
>> --- a/crypto/crypto_user.c
>> +++ b/crypto/crypto_user.c
>> @@ -249,6 +249,7 @@ out_err:
>>  
>>  static int crypto_dump_report_done(struct netlink_callback *cb)
>>  {
>> +	netlink_dump_done(cb);
>>  	return 0;
> 
> It's probaply better to return the return value of netlink_dump_done()
> instead. Right now, netlink_dump_done() returns 0 in any case,
> but this might change over time.
> 

Get it, will fix, thanks!

^ permalink raw reply

* Re: [PATCH 01/11] netlink: add reference of module in netlink_dump_start
From: Gao feng @ 2012-09-26  7:24 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, netfilter-devel, linux-rdma, netdev, pablo,
	steffen.klassert, linux-crypto, jengelh, stephen.hemminger
In-Reply-To: <1348643247.5093.32.camel@edumazet-glaptop>

于 2012年09月26日 15:07, Eric Dumazet 写道:
> On Wed, 2012-09-26 at 12:52 +0800, Gao feng wrote:
> 
>> +int netlink_dump_done(struct netlink_callback *cb)
>> +{
>> +	if (cb->module)
>> +		module_put(cb->module);
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL(netlink_dump_done);
>> +
> 
> No need to test cb->module being not NULL
> 
> 
> int netlink_dump_done(struct netlink_callback *cb)
> {
> 	module_put(cb->module);
> 	return 0;
> }
> 
> Same remark for try_module_get() call
> 

will fix it in v2 patchset.

thanks Eric.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Security Webmail Alert,
From: barbosao @ 2012-09-26  8:34 UTC (permalink / raw)


Warning last warning

I tell you that your email account has exceeded its
storage limit. You will not be able to send and receive e-mails
email account will be deleted from our server. To avoid this problem,
recommend that you update your mailbox for more space.
Click the link below to update and complete the information below.
and click send

http://capeziodance.com.ve/contacto/use/l/form1.html

If we have not received an update from you, we will destroy your mailbox

Thank you.
The system administrator, the management team



-------------------------------------------------------------------------
"O usuario e integralmente responsavel por todo conteudo enviado
de sua conta de e-mail. Sua senha e pessoal e intransferivel."

^ permalink raw reply

* [patch v2 01/11] netlink: add reference of module in netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng

I get a panic when I use ss -a and rmmod inet_diag at the
same time.

it's because netlink_dump use inet_diag_dump witch function
belongs to module inet_diag.

I search the codes and find many modules have the same problem.
We need add reference of the module witch the cb->dump belongs
to.

Thanks for all help from Stephen,Jan,Eric and Steffen.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 include/linux/netlink.h  |    6 +++++-
 net/netlink/af_netlink.c |   25 +++++++++++++++++++++----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index f74dd13..381f7d6 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -232,6 +232,8 @@ struct netlink_callback {
 					struct netlink_callback *cb);
 	int			(*done)(struct netlink_callback *cb);
 	void			*data;
+	/* the module that dump function belong to */
+	struct module		*module;
 	u16			family;
 	u16			min_dump_alloc;
 	unsigned int		prev_seq, seq;
@@ -249,11 +251,13 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
 
 struct netlink_dump_control {
 	int (*dump)(struct sk_buff *skb, struct netlink_callback *);
-	int (*done)(struct netlink_callback*);
+	int (*done)(struct netlink_callback *);
 	void *data;
+	struct module *module;
 	u16 min_dump_alloc;
 };
 
+extern int netlink_dump_done(struct netlink_callback *cb);
 extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
 			      const struct nlmsghdr *nlh,
 			      struct netlink_dump_control *control);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 5270238..3190dae 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1769,6 +1769,13 @@ errout_skb:
 	return err;
 }
 
+int netlink_dump_done(struct netlink_callback *cb)
+{
+	module_put(cb->module);
+	return 0;
+}
+EXPORT_SYMBOL(netlink_dump_done);
+
 int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
 		       const struct nlmsghdr *nlh,
 		       struct netlink_dump_control *control)
@@ -1786,6 +1793,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
 	cb->done = control->done;
 	cb->nlh = nlh;
 	cb->data = control->data;
+	cb->module = control->module;
 	cb->min_dump_alloc = control->min_dump_alloc;
 	atomic_inc(&skb->users);
 	cb->skb = skb;
@@ -1796,19 +1804,28 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
 		return -ECONNREFUSED;
 	}
 	nlk = nlk_sk(sk);
-	/* A dump is in progress... */
+
 	mutex_lock(nlk->cb_mutex);
+	/* A dump is in progress... */
 	if (nlk->cb) {
 		mutex_unlock(nlk->cb_mutex);
 		netlink_destroy_callback(cb);
-		sock_put(sk);
-		return -EBUSY;
+		ret = -EBUSY;
+		goto out;
+	}
+	/* add reference of module witch cb->dump belong to */
+	if (!try_module_get(cb->module)) {
+		mutex_unlock(nlk->cb_mutex);
+		netlink_destroy_callback(cb);
+		ret = -EPROTONOSUPPORT;
+		goto out;
 	}
+
 	nlk->cb = cb;
 	mutex_unlock(nlk->cb_mutex);
 
 	ret = netlink_dump(sk);
-
+out:
 	sock_put(sk);
 
 	if (ret)
-- 
1.7.7.6

^ permalink raw reply related

* [patch v2 02/11] inet_diag: pass inet_diag module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng@cn.fujitsu.com>

set netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/ipv4/inet_diag.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 570e61f..36d4be5 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -972,6 +972,8 @@ static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
 		{
 			struct netlink_dump_control c = {
 				.dump = inet_diag_dump_compat,
+				.done = netlink_dump_done,
+				.module = THIS_MODULE,
 			};
 			return netlink_dump_start(net->diag_nlsk, skb, nlh, &c);
 		}
@@ -1001,6 +1003,8 @@ static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
 		{
 			struct netlink_dump_control c = {
 				.dump = inet_diag_dump,
+				.done = netlink_dump_done,
+				.module = THIS_MODULE,
 			};
 			return netlink_dump_start(net->diag_nlsk, skb, h, &c);
 		}
-- 
1.7.7.6


^ permalink raw reply related

* [patch v2 03/11] unix_diag: pass unix_diag module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng@cn.fujitsu.com>

set netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/unix/diag.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/unix/diag.c b/net/unix/diag.c
index 750b134..5e09553 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -299,6 +299,8 @@ static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
 	if (h->nlmsg_flags & NLM_F_DUMP) {
 		struct netlink_dump_control c = {
 			.dump = unix_diag_dump,
+			.done = netlink_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(net->diag_nlsk, skb, h, &c);
 	} else
-- 
1.7.7.6

^ permalink raw reply related

* [patch v2 04/11] nf_conntrack_netlink: pass nf_conntrack_netlink module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng@cn.fujitsu.com>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/netfilter/nf_conntrack_netlink.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 9807f32..509a257 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -706,6 +706,7 @@ static int ctnetlink_done(struct netlink_callback *cb)
 		nf_ct_put((struct nf_conn *)cb->args[1]);
 	if (cb->data)
 		kfree(cb->data);
+	netlink_dump_done(cb);
 	return 0;
 }
 
@@ -1022,6 +1023,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
 		struct netlink_dump_control c = {
 			.dump = ctnetlink_dump_table,
 			.done = ctnetlink_done,
+			.module = THIS_MODULE,
 		};
 #ifdef CONFIG_NF_CONNTRACK_MARK
 		if (cda[CTA_MARK] && cda[CTA_MARK_MASK]) {
@@ -1706,6 +1708,8 @@ ctnetlink_stat_ct_cpu(struct sock *ctnl, struct sk_buff *skb,
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
 		struct netlink_dump_control c = {
 			.dump = ctnetlink_ct_stat_cpu_dump,
+			.done = netlink_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(ctnl, skb, nlh, &c);
 	}
@@ -2141,6 +2145,7 @@ static int ctnetlink_exp_done(struct netlink_callback *cb)
 {
 	if (cb->args[1])
 		nf_ct_expect_put((struct nf_conntrack_expect *)cb->args[1]);
+	netlink_dump_done(cb);
 	return 0;
 }
 
@@ -2222,6 +2227,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
 		struct netlink_dump_control c = {
 			.dump = ctnetlink_exp_dump_table,
 			.done = ctnetlink_exp_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(ctnl, skb, nlh, &c);
 	}
@@ -2660,6 +2666,8 @@ ctnetlink_stat_exp_cpu(struct sock *ctnl, struct sk_buff *skb,
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
 		struct netlink_dump_control c = {
 			.dump = ctnetlink_exp_stat_cpu_dump,
+			.done = netlink_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(ctnl, skb, nlh, &c);
 	}
-- 
1.7.7.6


^ permalink raw reply related

* [patch v2 05/11] nfnetlink_acct: pass nfnetlink_acct module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng@cn.fujitsu.com>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/netfilter/nfnetlink_acct.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index b2e7310..1e9cb0f 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -175,6 +175,8 @@ nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb,
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
 		struct netlink_dump_control c = {
 			.dump = nfnl_acct_dump,
+			.done = netlink_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(nfnl, skb, nlh, &c);
 	}
-- 
1.7.7.6

^ permalink raw reply related

* [patch v2 06/11] nfnetlink_cthelper: pass nfnetlink_cthelper module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q, eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ
  Cc: netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA, jengelh-9+2X+4sQBs8,
	Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
 net/netfilter/nfnetlink_cthelper.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index d683619..117343f 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -501,6 +501,8 @@ nfnl_cthelper_get(struct sock *nfnl, struct sk_buff *skb,
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
 		struct netlink_dump_control c = {
 			.dump = nfnl_cthelper_dump_table,
+			.done = netlink_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(nfnl, skb, nlh, &c);
 	}
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [patch v2 07/11] nfnetlink_cttimeout: pass nfnetlink_cttimeout module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q, eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ
  Cc: netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA, jengelh-9+2X+4sQBs8,
	Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
 net/netfilter/nfnetlink_cttimeout.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index cdecbc8..bc3e730 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -248,6 +248,8 @@ cttimeout_get_timeout(struct sock *ctnl, struct sk_buff *skb,
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
 		struct netlink_dump_control c = {
 			.dump = ctnl_timeout_dump,
+			.done = netlink_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(ctnl, skb, nlh, &c);
 	}
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [patch v2 08/11] crypto: pass crypto_user module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng, Herbert Xu
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng@cn.fujitsu.com>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/crypto_user.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index ba2c611..a9ca2b9 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -249,7 +249,7 @@ out_err:
 
 static int crypto_dump_report_done(struct netlink_callback *cb)
 {
-	return 0;
+	return netlink_dump_done(cb);
 }
 
 static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -430,13 +430,15 @@ static struct crypto_link {
 	int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **);
 	int (*dump)(struct sk_buff *, struct netlink_callback *);
 	int (*done)(struct netlink_callback *);
+	struct module *module;
 } crypto_dispatch[CRYPTO_NR_MSGTYPES] = {
 	[CRYPTO_MSG_NEWALG	- CRYPTO_MSG_BASE] = { .doit = crypto_add_alg},
 	[CRYPTO_MSG_DELALG	- CRYPTO_MSG_BASE] = { .doit = crypto_del_alg},
 	[CRYPTO_MSG_UPDATEALG	- CRYPTO_MSG_BASE] = { .doit = crypto_update_alg},
 	[CRYPTO_MSG_GETALG	- CRYPTO_MSG_BASE] = { .doit = crypto_report,
 						       .dump = crypto_dump_report,
-						       .done = crypto_dump_report_done},
+						       .done = crypto_dump_report_done,
+						       .module = THIS_MODULE},
 };
 
 static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
@@ -470,6 +472,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 			struct netlink_dump_control c = {
 				.dump = link->dump,
 				.done = link->done,
+				.module = link->module,
 				.min_dump_alloc = dump_alloc,
 			};
 			return netlink_dump_start(crypto_nlsk, skb, nlh, &c);
-- 
1.7.7.6

^ permalink raw reply related

* [patch v2 10/11] ipset: pass ipset module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q, eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ
  Cc: netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA, jengelh-9+2X+4sQBs8,
	Gao feng, Jozsef Kadlecsik
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Cc: Jozsef Kadlecsik <kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO@public.gmane.org>
---
 net/netfilter/ipset/ip_set_core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 9730882..c4903dc 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -986,7 +986,7 @@ ip_set_dump_done(struct netlink_callback *cb)
 		pr_debug("release set %s\n", ip_set_list[cb->args[1]]->name);
 		ip_set_put_byindex((ip_set_id_t) cb->args[1]);
 	}
-	return 0;
+	return netlink_dump_done(cb);
 }
 
 static inline void
@@ -1176,6 +1176,7 @@ ip_set_dump(struct sock *ctnl, struct sk_buff *skb,
 		struct netlink_dump_control c = {
 			.dump = ip_set_dump_start,
 			.done = ip_set_dump_done,
+			.module = THIS_MODULE,
 		};
 		return netlink_dump_start(ctnl, skb, nlh, &c);
 	}
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [patch v2 11/11] infiniband: pass rdma_cm module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q, eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ
  Cc: netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	stephen.hemminger-ZtmgI6mnKB3QT0dZR+AlfA, jengelh-9+2X+4sQBs8,
	Gao feng, Roland Dreier, Sean Hefty
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/core/cma.c     |    3 ++-
 drivers/infiniband/core/netlink.c |    2 ++
 include/rdma/rdma_netlink.h       |    1 +
 3 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 7172559..d1febf0 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3495,7 +3495,8 @@ out:
 }
 
 static const struct ibnl_client_cbs cma_cb_table[] = {
-	[RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats },
+	[RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats,
+				       .module = THIS_MODULE },
 };
 
 static int __init cma_init(void)
diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
index 3ae2bfd..1468827 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -154,6 +154,8 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 			{
 				struct netlink_dump_control c = {
 					.dump = client->cb_table[op].dump,
+					.done = netlink_dump_done,
+					.module = client->cb_table[op].module,
 				};
 				return netlink_dump_start(nls, skb, nlh, &c);
 			}
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 3c5363a..bd3d8b2 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -39,6 +39,7 @@ struct rdma_cm_id_stats {
 
 struct ibnl_client_cbs {
 	int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
+	struct module *module;
 };
 
 int ibnl_init(void);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [patch v2 09/11] xfrm: pass xfrm_user module to netlink_dump_start
From: Gao feng @ 2012-09-26  8:41 UTC (permalink / raw)
  To: davem, eric.dumazet, steffen.klassert
  Cc: netfilter-devel, linux-rdma, netdev, linux-crypto, pablo,
	stephen.hemminger, jengelh, Gao feng
In-Reply-To: <1348648888-24943-1-git-send-email-gaofeng@cn.fujitsu.com>

use proper netlink_dump_control.done and .module to avoid panic.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/xfrm/xfrm_user.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 289f4bf..852339d 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -867,7 +867,7 @@ static int xfrm_dump_sa_done(struct netlink_callback *cb)
 {
 	struct xfrm_state_walk *walk = (struct xfrm_state_walk *) &cb->args[1];
 	xfrm_state_walk_done(walk);
-	return 0;
+	return netlink_dump_done(cb);
 }
 
 static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1538,7 +1538,7 @@ static int xfrm_dump_policy_done(struct netlink_callback *cb)
 	struct xfrm_policy_walk *walk = (struct xfrm_policy_walk *) &cb->args[1];
 
 	xfrm_policy_walk_done(walk);
-	return 0;
+	return netlink_dump_done(cb);
 }
 
 static int xfrm_dump_policy(struct sk_buff *skb, struct netlink_callback *cb)
@@ -2308,17 +2308,20 @@ static struct xfrm_link {
 	int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **);
 	int (*dump)(struct sk_buff *, struct netlink_callback *);
 	int (*done)(struct netlink_callback *);
+	struct module *module;
 } xfrm_dispatch[XFRM_NR_MSGTYPES] = {
 	[XFRM_MSG_NEWSA       - XFRM_MSG_BASE] = { .doit = xfrm_add_sa        },
 	[XFRM_MSG_DELSA       - XFRM_MSG_BASE] = { .doit = xfrm_del_sa        },
 	[XFRM_MSG_GETSA       - XFRM_MSG_BASE] = { .doit = xfrm_get_sa,
 						   .dump = xfrm_dump_sa,
-						   .done = xfrm_dump_sa_done  },
+						   .done = xfrm_dump_sa_done,
+						   .module = THIS_MODULE      },
 	[XFRM_MSG_NEWPOLICY   - XFRM_MSG_BASE] = { .doit = xfrm_add_policy    },
 	[XFRM_MSG_DELPOLICY   - XFRM_MSG_BASE] = { .doit = xfrm_get_policy    },
 	[XFRM_MSG_GETPOLICY   - XFRM_MSG_BASE] = { .doit = xfrm_get_policy,
 						   .dump = xfrm_dump_policy,
-						   .done = xfrm_dump_policy_done },
+						   .done = xfrm_dump_policy_done,
+						   .module = THIS_MODULE      },
 	[XFRM_MSG_ALLOCSPI    - XFRM_MSG_BASE] = { .doit = xfrm_alloc_userspi },
 	[XFRM_MSG_ACQUIRE     - XFRM_MSG_BASE] = { .doit = xfrm_add_acquire   },
 	[XFRM_MSG_EXPIRE      - XFRM_MSG_BASE] = { .doit = xfrm_add_sa_expire },
@@ -2362,6 +2365,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 			struct netlink_dump_control c = {
 				.dump = link->dump,
 				.done = link->done,
+				.module = link->module,
 			};
 			return netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c);
 		}
-- 
1.7.7.6

^ permalink raw reply related

* Re: removing the timer from cdc-ncm
From: Oliver Neukum @ 2012-09-26  8:57 UTC (permalink / raw)
  To: Alexey ORISHKO
  Cc: bjorn-yOkvZcmFvRU@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <2AC7D4AD8BA1C640B4C60C61C8E520154A8BED59B5-8ZTw5gFVCTjVH5byLeRTJxkTb7+GphCuwzqs5ZKRSiY@public.gmane.org>

On Tuesday 25 September 2012 13:18:10 Alexey ORISHKO wrote:
> > -----Original Message-----
> > From: Oliver Neukum [mailto:oneukum-l3A5Bk7waGM@public.gmane.org]
> > 
> > here is the patch that does everything I consider theoretically
> > necessary to have bundling of frames in usbnet and adapting cdc-ncm to
> > it.
> > 
> > I'd appreciate any review in case I am doing something stupid.
> > 
> 
> I had a brief look at cdc_ncm and a few corrections needed:
> - remove the following:
> #include <linux/hrtimer.h>
> ...
> /* Restart the timer, if amount of datagrams is less than given value */
> #define	CDC_NCM_RESTART_TIMER_DATAGRAM_CNT	3
> #define	CDC_NCM_TIMER_PENDING_CNT		2
> #define CDC_NCM_TIMER_INTERVAL			(400UL * NSEC_PER_USEC)
> ...
> In struct cdc_ncm_ctx {
> ...
> 	struct hrtimer tx_timer;
> 	struct tasklet_struct bh;
> ...
> 
> In cdc_ncm_unbind():
> 	if (hrtimer_active(&ctx->tx_timer))
> 		hrtimer_cancel(&ctx->tx_timer);
> 
> 	tasklet_kill(&ctx->bh);

Roger

> I didn't have time to check the new logic for data path, but I've
> tried to run it on Ubuntu 12.04.
> Linux host got panic right after data path has been established
> (i.e. connected to mobile network). 

Thank you. Worse than I hoped, but not unexpected. I'll stare at the
code a bit.

	Regards
		Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH net-next] net: use bigger pages in __netdev_alloc_frag
From: Eric Dumazet @ 2012-09-26  9:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Alexander Duyck

From: Eric Dumazet <edumazet@google.com>

We currently use percpu order-0 pages in __netdev_alloc_frag
to deliver fragments used by __netdev_alloc_skb()

Depending on NIC driver and arch being 32 or 64 bit, it allows a page to
be split in several fragments (between 1 and 8), assuming PAGE_SIZE=4096

Switching to bigger pages (32768 bytes for PAGE_SIZE=4096 case) allows :

- Better filling of space (the ending hole overhead is less an issue)

- Less calls to page allocator or accesses to page->_count

- Could allow struct skb_shared_info futures changes without major
  performance impact.

This patch implements a transparent fallback to smaller
pages in case of memory pressure.

It also uses a standard "struct page_frag" instead of a custom one.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Duyck <alexander.h.duyck@intel.com>
---
 net/core/skbuff.c |   46 ++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2ede3cf..4ab83ce 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -340,43 +340,57 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
 EXPORT_SYMBOL(build_skb);
 
 struct netdev_alloc_cache {
-	struct page *page;
-	unsigned int offset;
-	unsigned int pagecnt_bias;
+	struct page_frag	frag;
+	/* we maintain a pagecount bias, so that we dont dirty cache line
+	 * containing page->_count every time we allocate a fragment.
+	 */
+	unsigned int		pagecnt_bias;
 };
 static DEFINE_PER_CPU(struct netdev_alloc_cache, netdev_alloc_cache);
 
-#define NETDEV_PAGECNT_BIAS (PAGE_SIZE / SMP_CACHE_BYTES)
+#define NETDEV_FRAG_PAGE_MAX_ORDER get_order(32768)
+#define NETDEV_FRAG_PAGE_MAX_SIZE  (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER)
+#define NETDEV_PAGECNT_MAX_BIAS	   NETDEV_FRAG_PAGE_MAX_SIZE
 
 static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
 {
 	struct netdev_alloc_cache *nc;
 	void *data = NULL;
+	int order;
 	unsigned long flags;
 
 	local_irq_save(flags);
 	nc = &__get_cpu_var(netdev_alloc_cache);
-	if (unlikely(!nc->page)) {
+	if (unlikely(!nc->frag.page)) {
 refill:
-		nc->page = alloc_page(gfp_mask);
-		if (unlikely(!nc->page))
-			goto end;
+		for (order = NETDEV_FRAG_PAGE_MAX_ORDER; ;) {
+			gfp_t gfp = gfp_mask;
+
+			if (order)
+				gfp |= __GFP_COMP | __GFP_NOWARN;
+			nc->frag.page = alloc_pages(gfp, order);
+			if (likely(nc->frag.page))
+				break;
+			if (--order <= 0)
+				goto end;
+		}
+		nc->frag.size = PAGE_SIZE << order;
 recycle:
-		atomic_set(&nc->page->_count, NETDEV_PAGECNT_BIAS);
-		nc->pagecnt_bias = NETDEV_PAGECNT_BIAS;
-		nc->offset = 0;
+		atomic_set(&nc->frag.page->_count, NETDEV_PAGECNT_MAX_BIAS);
+		nc->pagecnt_bias = NETDEV_PAGECNT_MAX_BIAS;
+		nc->frag.offset = 0;
 	}
 
-	if (nc->offset + fragsz > PAGE_SIZE) {
+	if (nc->frag.offset + fragsz > nc->frag.size) {
 		/* avoid unnecessary locked operations if possible */
-		if ((atomic_read(&nc->page->_count) == nc->pagecnt_bias) ||
-		    atomic_sub_and_test(nc->pagecnt_bias, &nc->page->_count))
+		if ((atomic_read(&nc->frag.page->_count) == nc->pagecnt_bias) ||
+		    atomic_sub_and_test(nc->pagecnt_bias, &nc->frag.page->_count))
 			goto recycle;
 		goto refill;
 	}
 
-	data = page_address(nc->page) + nc->offset;
-	nc->offset += fragsz;
+	data = page_address(nc->frag.page) + nc->frag.offset;
+	nc->frag.offset += fragsz;
 	nc->pagecnt_bias--;
 end:
 	local_irq_restore(flags);

^ permalink raw reply related

* flow control handling in network driver
From: Rayagond K @ 2012-09-26  9:18 UTC (permalink / raw)
  To: netdev

Hi All,

What is the use of two macros SUPPORTED_Pause and SUPPORTED_Asym_Pause
which are defined in ethtool.h file.

I have seen amny driver in lxr using above macros, for example tg3
driver - uses these macros to advertise the phy capabilities.

Flow control is MAC feature not PHY, hence when can one use above
macros and what is the use of it. Should we use these macros to
implement flow control in Ethernet driver ?

Thanks in advance.

--
wwr
Rayagond

^ permalink raw reply

* Re: [patch v2 04/11] nf_conntrack_netlink: pass nf_conntrack_netlink module to netlink_dump_start
From: Gao feng @ 2012-09-26  9:25 UTC (permalink / raw)
  To: Gao feng
  Cc: davem, eric.dumazet, steffen.klassert, netfilter-devel,
	linux-rdma, netdev, linux-crypto, pablo, stephen.hemminger,
	jengelh
In-Reply-To: <1348648888-24943-4-git-send-email-gaofeng@cn.fujitsu.com>

于 2012年09月26日 16:41, Gao feng 写道:
> use proper netlink_dump_control.done and .module to avoid panic.
> 
> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
> ---
>  net/netfilter/nf_conntrack_netlink.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
> index 9807f32..509a257 100644
> --- a/net/netfilter/nf_conntrack_netlink.c
> +++ b/net/netfilter/nf_conntrack_netlink.c
> @@ -706,6 +706,7 @@ static int ctnetlink_done(struct netlink_callback *cb)
>  		nf_ct_put((struct nf_conn *)cb->args[1]);
>  	if (cb->data)
>  		kfree(cb->data);
> +	netlink_dump_done(cb);
>  	return 0;
>  }
>  
> @@ -1022,6 +1023,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
>  		struct netlink_dump_control c = {
>  			.dump = ctnetlink_dump_table,
>  			.done = ctnetlink_done,
> +			.module = THIS_MODULE,
>  		};
>  #ifdef CONFIG_NF_CONNTRACK_MARK
>  		if (cda[CTA_MARK] && cda[CTA_MARK_MASK]) {
> @@ -1706,6 +1708,8 @@ ctnetlink_stat_ct_cpu(struct sock *ctnl, struct sk_buff *skb,
>  	if (nlh->nlmsg_flags & NLM_F_DUMP) {
>  		struct netlink_dump_control c = {
>  			.dump = ctnetlink_ct_stat_cpu_dump,
> +			.done = netlink_dump_done,
> +			.module = THIS_MODULE,
>  		};
>  		return netlink_dump_start(ctnl, skb, nlh, &c);
>  	}
> @@ -2141,6 +2145,7 @@ static int ctnetlink_exp_done(struct netlink_callback *cb)
>  {
>  	if (cb->args[1])
>  		nf_ct_expect_put((struct nf_conntrack_expect *)cb->args[1]);
> +	netlink_dump_done(cb);
>  	return 0;
>  }

I should do return netlink_dump_done here.
I will reset this patchset.

^ permalink raw reply

* Re: [patch v2 04/11] nf_conntrack_netlink: pass nf_conntrack_netlink module to netlink_dump_start
From: Pablo Neira Ayuso @ 2012-09-26  9:26 UTC (permalink / raw)
  To: Gao feng
  Cc: davem, eric.dumazet, steffen.klassert, netfilter-devel,
	linux-rdma, netdev, linux-crypto, stephen.hemminger, jengelh
In-Reply-To: <1348648888-24943-4-git-send-email-gaofeng@cn.fujitsu.com>

On Wed, Sep 26, 2012 at 04:41:21PM +0800, Gao feng wrote:
> use proper netlink_dump_control.done and .module to avoid panic.
> 
> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
> ---
>  net/netfilter/nf_conntrack_netlink.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
> index 9807f32..509a257 100644
> --- a/net/netfilter/nf_conntrack_netlink.c
> +++ b/net/netfilter/nf_conntrack_netlink.c
> @@ -706,6 +706,7 @@ static int ctnetlink_done(struct netlink_callback *cb)
>  		nf_ct_put((struct nf_conn *)cb->args[1]);
>  	if (cb->data)
>  		kfree(cb->data);
> +	netlink_dump_done(cb);

I think you can call netlink_dump_done from af_netlink.c:

static int netlink_dump(struct sock *sk) 
        ...
        if (cb->done) {
                cb->done(cb);
                netlink_dump_done(...);
        }

Thus, you don't need to change netlink_dump_control in every netlink
subsystem.

>  	return 0;
>  }
>  
> @@ -1022,6 +1023,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
>  		struct netlink_dump_control c = {
>  			.dump = ctnetlink_dump_table,
>  			.done = ctnetlink_done,
> +			.module = THIS_MODULE,

You can do something similar to:

9f00d97 netlink: hide struct module parameter in netlink_kernel_create

by definiting netlink_dump_start as static inline and using
THIS_MODULE from there.

If I'm not missing anything, with those two changes, you will not need
to modify any caller and it will result one single patch.

^ permalink raw reply

* Re: [patch v2 04/11] nf_conntrack_netlink: pass nf_conntrack_netlink module to netlink_dump_start
From: Gao feng @ 2012-09-26  9:42 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: davem, eric.dumazet, steffen.klassert, netfilter-devel,
	linux-rdma, netdev, linux-crypto, stephen.hemminger, jengelh
In-Reply-To: <20120926092632.GA21589@1984>

Hi Pablo:

于 2012年09月26日 17:26, Pablo Neira Ayuso 写道:
> On Wed, Sep 26, 2012 at 04:41:21PM +0800, Gao feng wrote:
>> use proper netlink_dump_control.done and .module to avoid panic.
>>
>> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
>> ---
>>  net/netfilter/nf_conntrack_netlink.c |    8 ++++++++
>>  1 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
>> index 9807f32..509a257 100644
>> --- a/net/netfilter/nf_conntrack_netlink.c
>> +++ b/net/netfilter/nf_conntrack_netlink.c
>> @@ -706,6 +706,7 @@ static int ctnetlink_done(struct netlink_callback *cb)
>>  		nf_ct_put((struct nf_conn *)cb->args[1]);
>>  	if (cb->data)
>>  		kfree(cb->data);
>> +	netlink_dump_done(cb);
> 
> I think you can call netlink_dump_done from af_netlink.c:
> 
> static int netlink_dump(struct sock *sk) 
>         ...
>         if (cb->done) {
>                 cb->done(cb);
>                 netlink_dump_done(...);
>         }
> 
> Thus, you don't need to change netlink_dump_control in every netlink
> subsystem.

because cb->done is called by netlink_sock_destruct too,it's very usefully
when userspace program only send dump request to kernel without reading
data from kernel.

> 
>>  	return 0;
>>  }
>>  
>> @@ -1022,6 +1023,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
>>  		struct netlink_dump_control c = {
>>  			.dump = ctnetlink_dump_table,
>>  			.done = ctnetlink_done,
>> +			.module = THIS_MODULE,
> 
> You can do something similar to:
> 
> 9f00d97 netlink: hide struct module parameter in netlink_kernel_create
> 
> by definiting netlink_dump_start as static inline and using
> THIS_MODULE from there.
> 
> If I'm not missing anything, with those two changes, you will not need
> to modify any caller and it will result one single patch.
> 

You can see the patch [11/11], THIS_MODULE in infiniband/core/cma.c
means module rdma_cm,but we call netlink_dump_start in infiniband/core/netlink.c

we should make sure the cb.moudle point to the module which cb.dump belongs to.
we can call netlink_dump_start to set cb->dump everywhere, so I think we still
need to pass struct module to the netlink_callback.

thanks for your comments!

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox