From: Daniel Lezcano <dlezcano@meiosys.com>
To: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: netdev@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Lennert Buytenhek <buytenh@wantstofly.org>,
bridge@linux-foundation.org
Subject: [Bridge] Re: [PATCH] bridge: sysfs locking fix.
Date: Fri, 24 Aug 2007 10:18:07 +0200 [thread overview]
Message-ID: <46CE943F.9000308@meiosys.com> (raw)
In-Reply-To: <20070814145052.2d135d2f@oldman.hamilton.local>
Stephen Hemminger wrote:
> Forget earlier patch, it is wrong...
>
> The stp change code generates "sleeping function called from invalid context"
> because rtnl_lock() called with BH disabled. This fixes it by not acquiring then
> dropping the bridge lock.
>
> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
>
> --- a/net/bridge/br_sysfs_br.c 2007-08-06 09:26:48.000000000 +0100
> +++ b/net/bridge/br_sysfs_br.c 2007-08-14 14:29:52.000000000 +0100
> @@ -147,20 +147,26 @@ static ssize_t show_stp_state(struct dev
> return sprintf(buf, "%d\n", br->stp_enabled);
> }
>
> -static void set_stp_state(struct net_bridge *br, unsigned long val)
> -{
> - rtnl_lock();
> - spin_unlock_bh(&br->lock);
> - br_stp_set_enabled(br, val);
> - spin_lock_bh(&br->lock);
> - rtnl_unlock();
> -}
>
> static ssize_t store_stp_state(struct device *d,
> struct device_attribute *attr, const char *buf,
> size_t len)
> {
> - return store_bridge_parm(d, buf, len, set_stp_state);
> + struct net_bridge *br = to_bridge(d);
> + char *endp;
> + unsigned long val;
> +
> + if (!capable(CAP_NET_ADMIN))
> + return -EPERM;
> +
> + val = simple_strtoul(buf, &endp, 0);
> + if (endp == buf)
> + return -EINVAL;
> +
> + rtnl_lock();
> + br_stp_set_enabled(br, val);
> + rtnl_unlock();
> +
Shouldn't len value be returned at the end of the function ?
> }
> static DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state,
> store_stp_state);
> -
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Lezcano <dlezcano@meiosys.com>
To: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: Lennert Buytenhek <buytenh@wantstofly.org>,
Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, bridge@linux-foundation.org
Subject: Re: [PATCH] bridge: sysfs locking fix.
Date: Fri, 24 Aug 2007 10:18:07 +0200 [thread overview]
Message-ID: <46CE943F.9000308@meiosys.com> (raw)
In-Reply-To: <20070814145052.2d135d2f@oldman.hamilton.local>
Stephen Hemminger wrote:
> Forget earlier patch, it is wrong...
>
> The stp change code generates "sleeping function called from invalid context"
> because rtnl_lock() called with BH disabled. This fixes it by not acquiring then
> dropping the bridge lock.
>
> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
>
> --- a/net/bridge/br_sysfs_br.c 2007-08-06 09:26:48.000000000 +0100
> +++ b/net/bridge/br_sysfs_br.c 2007-08-14 14:29:52.000000000 +0100
> @@ -147,20 +147,26 @@ static ssize_t show_stp_state(struct dev
> return sprintf(buf, "%d\n", br->stp_enabled);
> }
>
> -static void set_stp_state(struct net_bridge *br, unsigned long val)
> -{
> - rtnl_lock();
> - spin_unlock_bh(&br->lock);
> - br_stp_set_enabled(br, val);
> - spin_lock_bh(&br->lock);
> - rtnl_unlock();
> -}
>
> static ssize_t store_stp_state(struct device *d,
> struct device_attribute *attr, const char *buf,
> size_t len)
> {
> - return store_bridge_parm(d, buf, len, set_stp_state);
> + struct net_bridge *br = to_bridge(d);
> + char *endp;
> + unsigned long val;
> +
> + if (!capable(CAP_NET_ADMIN))
> + return -EPERM;
> +
> + val = simple_strtoul(buf, &endp, 0);
> + if (endp == buf)
> + return -EINVAL;
> +
> + rtnl_lock();
> + br_stp_set_enabled(br, val);
> + rtnl_unlock();
> +
Shouldn't len value be returned at the end of the function ?
> }
> static DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state,
> store_stp_state);
> -
next prev parent reply other threads:[~2007-08-24 8:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-10 22:15 BUG: when using 'brctl stp' Daniel K.
[not found] ` <20070812012037.0195b610.akpm@linux-foundation.org>
2007-08-14 13:11 ` [Bridge] " Stephen Hemminger
2007-08-14 13:11 ` Stephen Hemminger
2007-08-14 13:18 ` [Bridge] " Lennert Buytenhek
2007-08-14 13:18 ` Lennert Buytenhek
2007-08-14 13:50 ` [Bridge] [PATCH] bridge: sysfs locking fix Stephen Hemminger
2007-08-14 13:50 ` Stephen Hemminger
2007-08-14 20:21 ` [Bridge] " David Miller
2007-08-14 20:21 ` David Miller
2007-08-24 8:18 ` Daniel Lezcano [this message]
2007-08-24 8:18 ` Daniel Lezcano
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=46CE943F.9000308@meiosys.com \
--to=dlezcano@meiosys.com \
--cc=akpm@linux-foundation.org \
--cc=bridge@linux-foundation.org \
--cc=buytenh@wantstofly.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
/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 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.