[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <522600B2.8090507@xdin.com>
Date: Tue, 3 Sep 2013 17:30:58 +0200
From: Arvid Brodin <arvid.brodin@...n.com>
To: David Miller <davem@...emloft.net>
CC: <netdev@...r.kernel.org>, <shemminger@...tta.com>,
<joe@...ches.com>, <jboticario@...il.com>,
<balferreira@...glemail.com>
Subject: Re: [PATCH v3] net/hsr: Add support for the High-availability Seamless
Redundancy protocol (HSRv0)
On 2013-08-30 21:54, David Miller wrote:
> From: Arvid Brodin <arvid.brodin@...n.com>
> Date: Wed, 21 Aug 2013 20:20:17 +0200
>
>> This is a patch against net-next (2013-08-21).
>
> First of all, your email client corrupted the patch, chopping up long lines
> and making whitespace changes to the content of the patch. Please fix this
> before resubmitting, and do so by first sending a test patch to yourself
> and making sure you can apply the patch you receive in that email. Do not
> use attachments to deal with this issue.
Sorry about that - I forgot to disable Format=Flowed... :(
>> + if (dev->operstate != transition) {
>> + write_lock_bh(&dev_base_lock);
>> + dev->operstate = transition;
>> + write_unlock_bh(&dev_base_lock);
>> + netdev_state_change(dev);
>> + }
>
> This is racy. And it appears that set_operstate() in net/core/rtnetlink.c
> has the same bug, I guess that's what you used as a guide.
>
> Any "test and set" sequence must be guarded completely by the lock, it
> doesn't make any sense to only guard the change of the value.
I never did understand the purpose of the locking done in set_operstate(). Will fix.
Also, Stephen Hemminger told me to use rtnl_mutex instead, but when I pointed
to net/core/rtnetlink.c and asked if he was sure, I did not get a reply. This
function - __hsr_set_operstate() - is only called from a notifier_call function,
so rtnl_mutex is already held here. Do I even need additional locking?
(According to ULNI* pp 171 Stephen is right and net/core/rtnetlink.c is wrong...)
* ULNI = Understanding Linux Network Internals
--
Arvid Brodin | Consultant (Linux)
XDIN AB | Knarrarnäsgatan 7 | SE-164 40 Kista | Sweden | xdin.com
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists