Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Hong Zhiguo <honkiko@gmail.com>
Cc: netdev@vger.kernel.org, stephen@networkplumber.org,
	davem@davemloft.net, vyasevic@redhat.com,
	Hong Zhiguo <zhiguohong@tencent.com>
Subject: Re: [PATCH net-next] bridge: change the order of actions in addif/delif
Date: Tue, 17 Sep 2013 04:57:02 -0700	[thread overview]
Message-ID: <1379419022.3457.8.camel@edumazet-glaptop> (raw)
In-Reply-To: <1379403883-16219-1-git-send-email-zhiguohong@tencent.com>

On Tue, 2013-09-17 at 15:44 +0800, Hong Zhiguo wrote:
> From: Hong Zhiguo <zhiguohong@tencent.com>
> 
> netdev_rx_handler_register turns on the bridge traffic. It should
> be the last action of br_add_if, after the installation of fdb and
> stp staff. _Maybe_ traffic coming in before preparation of fdb and
> stp is taken care of, but we could make it easier.
> 
> Vise versa, netdev_rx_handler_unregister actually turns off bridge
> traffic from the dev. It should be the first action of br_del_if,
> before fdb and stp staff is uninstalled.
> 
> Signed-off-by: Hong Zhiguo <zhiguohong@tencent.com>
> ---
>  net/bridge/br_if.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
> index c41d5fb..6544154 100644
> --- a/net/bridge/br_if.c
> +++ b/net/bridge/br_if.c
> @@ -133,6 +133,8 @@ static void del_nbp(struct net_bridge_port *p)
>  
>  	sysfs_remove_link(br->ifobj, p->dev->name);
>  
> +	netdev_rx_handler_unregister(dev);
> +
>  	dev_set_promiscuity(dev, -1);
>  
>  	spin_lock_bh(&br->lock);
> @@ -148,8 +150,6 @@ static void del_nbp(struct net_bridge_port *p)
>  
>  	dev->priv_flags &= ~IFF_BRIDGE_PORT;
>  
> -	netdev_rx_handler_unregister(dev);
> -
>  	netdev_upper_dev_unlink(dev, br->dev);
>  

This was really your first patch, and I 'Acked' it.
(OK, changelog can be different now we fixed the bug)

The following should be part of a different patch

>  	br_multicast_del_port(p);
> @@ -336,8 +336,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
>  	if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit)
>  		return -ELOOP;
>  
> -	/* Device is already being bridged */
> -	if (br_port_exists(dev))
> +	/* Device is already being bridged or registered with other handler */
> +	if (br_port_exists(dev) || dev->rx_handler)
>  		return -EBUSY;

rcu_access_pointer(dev->rx_handler)

Anyway, this is risky, because it assumes netdev_rx_handler_register()
implementation wont change.

Just leave the code as is, I don't think its worth it.

  reply	other threads:[~2013-09-17 11:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17  7:44 [PATCH net-next] bridge: change the order of actions in addif/delif Hong Zhiguo
2013-09-17 11:57 ` Eric Dumazet [this message]
2013-09-17 16:24 ` Stephen Hemminger

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=1379419022.3457.8.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=honkiko@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=vyasevic@redhat.com \
    --cc=zhiguohong@tencent.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