From: Stephen Hemminger <shemminger@vyatta.com>
To: Wang Chen <wangchen@cn.fujitsu.com>
Cc: "David S. Miller" <davem@davemloft.net>,
NETDEV <netdev@vger.kernel.org>,
Patrick McHardy <kaber@trash.net>
Subject: Re: [PATCH net-next 3/8] bridge: Check return of dev_set_promiscuity
Date: Thu, 19 Jun 2008 18:18:19 -0700 [thread overview]
Message-ID: <20080619181819.15b2cc9d@extreme> (raw)
In-Reply-To: <485AFFE4.4000300@cn.fujitsu.com>
On Fri, 20 Jun 2008 08:55:00 +0800
Wang Chen <wangchen@cn.fujitsu.com> wrote:
> dev_set_promiscuity/allmulti might overflow.
> Commit: "netdevice: Fix promiscuity and allmulti overflow" in net-next makes
> dev_set_promiscuity/allmulti return error number if overflow happened.
>
> Here, we check the positive increment for promiscuity to get error return.
>
> BTW, I have to add a function to handle cleanup for br_sysfs_addif().
> I know Stephen has removed br_sysfs_removeif() to keep kobjects in use
> even if not using sysfs.
> But here we have a new br_sysfs_removeif() which only cleanup the sysfs
> and doesn't touch kobjects.
>
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Not that hard way please. Instead just rearrange the order of setup to avoid having to
do the things that are harder to unwind. Sysfs calls seem to be more fragile/error
prone than the simple counters.
Like this (untested)
--- a/net/bridge/br_if.c 2008-06-19 18:09:59.000000000 -0700
+++ b/net/bridge/br_if.c 2008-06-19 18:16:44.000000000 -0700
@@ -373,6 +373,10 @@ int br_add_if(struct net_bridge *br, str
if (IS_ERR(p))
return PTR_ERR(p);
+ err = dev_set_promiscuity(dev, 1);
+ if (err)
+ goto put_kobj;
+
err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
SYSFS_BRIDGE_PORT_ATTR);
if (err)
@@ -387,7 +391,6 @@ int br_add_if(struct net_bridge *br, str
goto err2;
rcu_assign_pointer(dev->br_port, p);
- dev_set_promiscuity(dev, 1);
list_add_rcu(&p->list, &br->port_list);
@@ -416,6 +419,8 @@ err0:
kobject_put(&p->kobj);
put_back:
+ dev_set_promiscuity(dev, -1);
+put_dev:
dev_put(dev);
return err;
}
next prev parent reply other threads:[~2008-06-20 1:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-20 0:55 [PATCH net-next 3/8] bridge: Check return of dev_set_promiscuity Wang Chen
2008-06-20 1:18 ` Stephen Hemminger [this message]
2008-06-20 2:32 ` Wang Chen
2008-06-21 3:48 ` [PATCH] bridge: Check return of dev_set_promiscuity (v2) Stephen Hemminger
2008-06-21 5:45 ` [PATCH] bridge: Check return of dev_set_promiscuity (v3) Wang Chen
2008-06-20 2:08 ` [PATCH net-next 3/8] bridge: Check return of dev_set_promiscuity David Miller
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=20080619181819.15b2cc9d@extreme \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=wangchen@cn.fujitsu.com \
/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 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).