All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces
@ 2019-02-02 14:29 Rundong Ge
  2019-02-02 17:05 ` Florian Fainelli
  0 siblings, 1 reply; 5+ messages in thread
From: Rundong Ge @ 2019-02-02 14:29 UTC (permalink / raw)
  To: andrew; +Cc: vivien.didelot, f.fainelli, davem, netdev, rdong.ge

The unbalance of master's promiscuity or allmulti will happen after ifdown
and ifup a slave interface which is in a bridge.

When we ifdown a slave interface , both the 'dsa_slave_close' and
'dsa_slave_change_rx_flags' will clear the master's flags. The flags
of master will be decrease twice.
In the other hand, if we ifup the slave interface again, since the
slave's flags were cleared the 'dsa_slave_open' won't set the master's
flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if'
will set the master's flags. The flags of master is increase once.

Only propagating flag changes when a slave interface is up makes
sure this does not happen. The 'vlan_dev_change_rx_flags' had the
same problem and was fixed, and changes here follows that fix.

Signed-off-by: Rundong Ge <rdong.ge@gmail.com>
---
 net/dsa/slave.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a3fcc1d..b5e4482 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -140,11 +140,14 @@ static int dsa_slave_close(struct net_device *dev)
 static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
 {
 	struct net_device *master = dsa_slave_to_master(dev);
-
-	if (change & IFF_ALLMULTI)
-		dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);
-	if (change & IFF_PROMISC)
-		dev_set_promiscuity(master, dev->flags & IFF_PROMISC ? 1 : -1);
+	if (dev->flags & IFF_UP) {
+		if (change & IFF_ALLMULTI)
+			dev_set_allmulti(master,
+					 dev->flags & IFF_ALLMULTI ? 1 : -1);
+		if (change & IFF_PROMISC)
+			dev_set_promiscuity(master,
+					    dev->flags & IFF_PROMISC ? 1 : -1);
+	}
 }
 
 static void dsa_slave_set_rx_mode(struct net_device *dev)
-- 
1.8.3.1


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

* Re: [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces
  2019-02-02 14:29 [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces Rundong Ge
@ 2019-02-02 17:05 ` Florian Fainelli
  2019-02-02 17:16   ` Andrew Lunn
  2019-02-05  2:29   ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Florian Fainelli @ 2019-02-02 17:05 UTC (permalink / raw)
  To: Rundong Ge, andrew; +Cc: vivien.didelot, davem, netdev

Le 2/2/19 à 6:29 AM, Rundong Ge a écrit :
> The unbalance of master's promiscuity or allmulti will happen after ifdown
> and ifup a slave interface which is in a bridge.
> 
> When we ifdown a slave interface , both the 'dsa_slave_close' and
> 'dsa_slave_change_rx_flags' will clear the master's flags. The flags
> of master will be decrease twice.
> In the other hand, if we ifup the slave interface again, since the
> slave's flags were cleared the 'dsa_slave_open' won't set the master's
> flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if'
> will set the master's flags. The flags of master is increase once.
> 
> Only propagating flag changes when a slave interface is up makes
> sure this does not happen. The 'vlan_dev_change_rx_flags' had the
> same problem and was fixed, and changes here follows that fix.

VLAN code under net/8021q/vlan_dev.c::vlan_dev_change_rx_flags() appears
to do the same thing that you are proposing, so this looks fine to me.
Since that is a bugfix, we should probably add:

Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol
support")

?

> 
> Signed-off-by: Rundong Ge <rdong.ge@gmail.com>
> ---
>  net/dsa/slave.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index a3fcc1d..b5e4482 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -140,11 +140,14 @@ static int dsa_slave_close(struct net_device *dev)
>  static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
>  {
>  	struct net_device *master = dsa_slave_to_master(dev);
> -
> -	if (change & IFF_ALLMULTI)
> -		dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);
> -	if (change & IFF_PROMISC)
> -		dev_set_promiscuity(master, dev->flags & IFF_PROMISC ? 1 : -1);
> +	if (dev->flags & IFF_UP) {
> +		if (change & IFF_ALLMULTI)
> +			dev_set_allmulti(master,
> +					 dev->flags & IFF_ALLMULTI ? 1 : -1);
> +		if (change & IFF_PROMISC)
> +			dev_set_promiscuity(master,
> +					    dev->flags & IFF_PROMISC ? 1 : -1);
> +	}
>  }
>  
>  static void dsa_slave_set_rx_mode(struct net_device *dev)
> 


-- 
Florian

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

* Re: [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces
  2019-02-02 17:05 ` Florian Fainelli
@ 2019-02-02 17:16   ` Andrew Lunn
  2019-02-03  5:34     ` 戈润栋
  2019-02-05  2:29   ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2019-02-02 17:16 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: Rundong Ge, vivien.didelot, davem, netdev

On Sat, Feb 02, 2019 at 09:05:11AM -0800, Florian Fainelli wrote:
> Le 2/2/19 à 6:29 AM, Rundong Ge a écrit :
> > The unbalance of master's promiscuity or allmulti will happen after ifdown
> > and ifup a slave interface which is in a bridge.
> > 
> > When we ifdown a slave interface , both the 'dsa_slave_close' and
> > 'dsa_slave_change_rx_flags' will clear the master's flags. The flags
> > of master will be decrease twice.
> > In the other hand, if we ifup the slave interface again, since the
> > slave's flags were cleared the 'dsa_slave_open' won't set the master's
> > flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if'
> > will set the master's flags. The flags of master is increase once.
> > 
> > Only propagating flag changes when a slave interface is up makes
> > sure this does not happen. The 'vlan_dev_change_rx_flags' had the
> > same problem and was fixed, and changes here follows that fix.
> 
> VLAN code under net/8021q/vlan_dev.c::vlan_dev_change_rx_flags() appears
> to do the same thing that you are proposing, so this looks fine to me.
> Since that is a bugfix, we should probably add:

Hi Rundong, Florian

I've seen issues with tcpdump causing the promiscuous count to go
negative. I wounder if this will fix that at well?

	  Andrew

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

* Re: [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces
  2019-02-02 17:16   ` Andrew Lunn
@ 2019-02-03  5:34     ` 戈润栋
  0 siblings, 0 replies; 5+ messages in thread
From: 戈润栋 @ 2019-02-03  5:34 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Florian Fainelli, vivien.didelot, davem, netdev

Hi Andrew

Sorry for the previous mails due to my error mail format setting on browser.

I have reproduced the tcpdump issue in my env, but not sure if it is the
same issue as you mentioned.
Ifdown a slave interface which is under tcpdump capturing will also decrease
the master's promiscuous twice.

So when I do:
a) tcpdump -i ethx
b) ifdown ethx
c) ifup ethx
d) goto a
for several times the promiscuous count of master will go negative.

Raydon


Andrew Lunn <andrew@lunn.ch> 于2019年2月3日周日 上午1:16写道:
>
> On Sat, Feb 02, 2019 at 09:05:11AM -0800, Florian Fainelli wrote:
> > Le 2/2/19 à 6:29 AM, Rundong Ge a écrit :
> > > The unbalance of master's promiscuity or allmulti will happen after ifdown
> > > and ifup a slave interface which is in a bridge.
> > >
> > > When we ifdown a slave interface , both the 'dsa_slave_close' and
> > > 'dsa_slave_change_rx_flags' will clear the master's flags. The flags
> > > of master will be decrease twice.
> > > In the other hand, if we ifup the slave interface again, since the
> > > slave's flags were cleared the 'dsa_slave_open' won't set the master's
> > > flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if'
> > > will set the master's flags. The flags of master is increase once.
> > >
> > > Only propagating flag changes when a slave interface is up makes
> > > sure this does not happen. The 'vlan_dev_change_rx_flags' had the
> > > same problem and was fixed, and changes here follows that fix.
> >
> > VLAN code under net/8021q/vlan_dev.c::vlan_dev_change_rx_flags() appears
> > to do the same thing that you are proposing, so this looks fine to me.
> > Since that is a bugfix, we should probably add:
>
> Hi Rundong, Florian
>
> I've seen issues with tcpdump causing the promiscuous count to go
> negative. I wounder if this will fix that at well?
>
>           Andrew

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

* Re: [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces
  2019-02-02 17:05 ` Florian Fainelli
  2019-02-02 17:16   ` Andrew Lunn
@ 2019-02-05  2:29   ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2019-02-05  2:29 UTC (permalink / raw)
  To: f.fainelli; +Cc: rdong.ge, andrew, vivien.didelot, netdev

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Sat, 2 Feb 2019 09:05:11 -0800

> Le 2/2/19 à 6:29 AM, Rundong Ge a écrit :
>> The unbalance of master's promiscuity or allmulti will happen after ifdown
>> and ifup a slave interface which is in a bridge.
>> 
>> When we ifdown a slave interface , both the 'dsa_slave_close' and
>> 'dsa_slave_change_rx_flags' will clear the master's flags. The flags
>> of master will be decrease twice.
>> In the other hand, if we ifup the slave interface again, since the
>> slave's flags were cleared the 'dsa_slave_open' won't set the master's
>> flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if'
>> will set the master's flags. The flags of master is increase once.
>> 
>> Only propagating flag changes when a slave interface is up makes
>> sure this does not happen. The 'vlan_dev_change_rx_flags' had the
>> same problem and was fixed, and changes here follows that fix.
> 
> VLAN code under net/8021q/vlan_dev.c::vlan_dev_change_rx_flags() appears
> to do the same thing that you are proposing, so this looks fine to me.
> Since that is a bugfix, we should probably add:
> 
> Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol
> support")

Applied with Fixes tag added, and queued up for -stable.

Thanks.

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

end of thread, other threads:[~2019-02-05 18:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-02 14:29 [PATCH] net: dsa: slave: Don't propagate flag changes on down slave interfaces Rundong Ge
2019-02-02 17:05 ` Florian Fainelli
2019-02-02 17:16   ` Andrew Lunn
2019-02-03  5:34     ` 戈润栋
2019-02-05  2:29   ` David Miller

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.