netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/5] bonding: add rtnl lock for bonding_store_xmit_hash
@ 2013-08-28  4:21 Ding Tianhong
  2013-08-29 14:25 ` Nikolay Aleksandrov
  0 siblings, 1 reply; 3+ messages in thread
From: Ding Tianhong @ 2013-08-28  4:21 UTC (permalink / raw)
  To: Jay Vosburgh, Andy Gospodarek, David S. Miller,
	Nikolay Aleksandrov, Veaceslav Falico, Netdev

The bonding_store_xmit_hash() call bond_set_mode_ops() to set bond xmit_policy,
the xmit_policy is used in xmit path for xor mode, so any changes may occur
problem without protection, add rtnl lock is fit here.

Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_sysfs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 0f539de..deb1d8e 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -382,6 +382,9 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
 	int new_value, ret = count;
 	struct bonding *bond = to_bond(d);
 
+	if (!rtnl_trylock())
+		return restart_syscall();
+
 	new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
 	if (new_value < 0)  {
 		pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
@@ -396,6 +399,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
 			xmit_hashtype_tbl[new_value].modename, new_value);
 	}
 
+	rtnl_unlock();
 	return ret;
 }
 static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
-- 
1.8.2.1

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

* Re: [PATCH 3/5] bonding: add rtnl lock for bonding_store_xmit_hash
  2013-08-28  4:21 [PATCH 3/5] bonding: add rtnl lock for bonding_store_xmit_hash Ding Tianhong
@ 2013-08-29 14:25 ` Nikolay Aleksandrov
  2013-08-30  3:26   ` Ding Tianhong
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Aleksandrov @ 2013-08-29 14:25 UTC (permalink / raw)
  To: Ding Tianhong
  Cc: Jay Vosburgh, Andy Gospodarek, David S. Miller, Veaceslav Falico,
	Netdev

On 08/28/2013 06:21 AM, Ding Tianhong wrote:
> The bonding_store_xmit_hash() call bond_set_mode_ops() to set bond xmit_policy,
> the xmit_policy is used in xmit path for xor mode, so any changes may occur
> problem without protection, add rtnl lock is fit here.
> 
> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
> ---
I don't think we need any locking there, nothing bad can happen.

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

* Re: [PATCH 3/5] bonding: add rtnl lock for bonding_store_xmit_hash
  2013-08-29 14:25 ` Nikolay Aleksandrov
@ 2013-08-30  3:26   ` Ding Tianhong
  0 siblings, 0 replies; 3+ messages in thread
From: Ding Tianhong @ 2013-08-30  3:26 UTC (permalink / raw)
  To: Nikolay Aleksandrov
  Cc: Jay Vosburgh, Andy Gospodarek, David S. Miller, Veaceslav Falico,
	Netdev

On 2013/8/29 22:25, Nikolay Aleksandrov wrote:
> On 08/28/2013 06:21 AM, Ding Tianhong wrote:
>> The bonding_store_xmit_hash() call bond_set_mode_ops() to set bond xmit_policy,
>> the xmit_policy is used in xmit path for xor mode, so any changes may occur
>> problem without protection, add rtnl lock is fit here.
>>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>> ---
> I don't think we need any locking there, nothing bad can happen.
> 
> 
> 
But I think bond->xmit_hash_policy need protect if write it, as the bond_3ad_xmit may use it,
or did I miss something? :) 

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

end of thread, other threads:[~2013-08-30  3:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-28  4:21 [PATCH 3/5] bonding: add rtnl lock for bonding_store_xmit_hash Ding Tianhong
2013-08-29 14:25 ` Nikolay Aleksandrov
2013-08-30  3:26   ` Ding Tianhong

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).