Skip to contentSkip to conversation

If bridge have no sub-interfaces, it's status may be still with 'RUNNING'

DISCUSSION NAK yzhu1 4 participants 13 messages Feb 13, 2015 – Mar 10, 2015

Subsystems (3)
lore
Share & tools
lore

yzhu1

author
#0 lore raw

Hi, all

I made this test on ubuntu 14.04 with kernel 3,19-rc7:

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

4. brctl addif br0 eth0

5. brctl delif br0 eth0

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

Thanks a lot.
Zhu Yanjun

author
#1 lore raw

Add the maintainer of bridge.

Any reply is appreciated.

Zhu Yanjun

Quoted 28 lines · On 02/13/2015 05:57 PM, yzhu1 wrote:

Hi, all

I made this test on ubuntu 14.04 with kernel 3,19-rc7:

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

4. brctl addif br0 eth0

5. brctl delif br0 eth0

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

Thanks a lot.
Zhu Yanjun

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to yzhu1
Quoted 14 lines · On Fri, 13 Feb 2015 17:57:45 +0800 yzhu1 <[email protected]> wrote:

Hi, all

I made this test on ubuntu 14.04 with kernel 3,19-rc7:

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

4. brctl addif br0 eth0

5. brctl delif br0 eth0

Quoted 7 lines

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

This is intentional. If there are no active ports in bridge, then we want to tell applications that packets will go nowhere.

#3 lore raw

Hi Stephen,
When we up a bridge without sub-interfaces, it has "RUNNING" flag as below. Is it correct or not?

1. brctl addbr br0
2. ifconfig br0 up
3. ifconfig br0
br0 Link encap:Ethernet HWaddr e6:6c:84:a6:fc:64
inet6 addr: fe80::e46c:84ff:fea6:fc64/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:168 (168.0 B)

Best Regards
Kuaikuai Wu

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Saturday, February 14, 2015 2:31 AM
To: Zhu, Yanjun
Cc: netdev; Wu, Kuaikuai; Tao, Yue
Subject: Re: If bridge have no sub-interfaces, it's status may be still with 'RUNNING'

Quoted 14 lines · On Fri, 13 Feb 2015 17:57:45 +0800 yzhu1 <[email protected]> wrote:

Hi, all

I made this test on ubuntu 14.04 with kernel 3,19-rc7:

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

4. brctl addif br0 eth0

5. brctl delif br0 eth0

Quoted 7 lines

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

This is intentional. If there are no active ports in bridge, then we want to tell applications that packets will go nowhere.

author
#4 lore raw
In reply to Stephen Hemminger

Hi, Stephen

Follow your advice, I made a new patch. This patch will turn off carrier when a new bridge interface is created. Please comment on it.

Thanks a lot.
Zhu Yanjun

Quoted 22 lines · Stephen Hemminger
Quoted 19 lines · On Fri, 13 Feb 2015 17:57:45 +0800 yzhu1 <[email protected]> wrote:

Hi, all

I made this test on ubuntu 14.04 with kernel 3,19-rc7:

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

4. brctl addif br0 eth0

5. brctl delif br0 eth0

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

Quoted 8 lines
Quoted 2 lines

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

This is intentional. If there are no active ports in bridge, then we want to tell applications that packets will go nowhere.

From e03af5263bcaeea15442601e2a9f65c6b582352b Mon Sep 17 00:00:00 2001

From: Zhu Yanjun <[email protected]>
Date: Mon, 16 Feb 2015 12:45:36 +0800
Subject: [PATCH 1/1] bridge: turn off carrier when the bridge is created

When a bridge interface is created, there is no any sub interface in it. In this case, the packets should not go to this bridge interface. As such, carrier is turned off.

---
 net/bridge/br_device.c | 5 +++++
 1 file changed, 5 insertions(+)
net/bridge/br_device.c +5 -0
index ffd379d..2d60474 100644
@@ -394,4 +394,9 @@ void br_dev_setup(struct net_device *dev)
 	br_netfilter_rtable_init(br);
 	br_stp_timer_init(br);
 	br_multicast_init(br);
+
+	/* Shutdown bridge to avoid packets */
+	if (netif_carrier_ok(dev)) {
+		netif_carrier_off(dev);
+	}
 }
Signature · 1 line
1.9.1
#5 lore raw
Quoted 6 lines · On 2/15/15 9:55 PM, yzhu1 wrote:
Quoted 6 lines
Quoted 6 lines

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

4. brctl addif br0 eth0

5. brctl delif br0 eth0

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

I do not see that behavior with Fedora 21 and 3.18.5-201.fc21.x86_64. ie., after interface is removed br0 is still in up state. Perhaps a regression with 3.19.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

This is intentional. If there are no active ports in bridge, then we want to tell applications that packets will go nowhere.

It changes current behavior with respect to tcpdump. Today I can launch tcpdump on a bridge interface before starting a VM. With this change I will not be able to do that.

David

#6 lore raw

Originally bridge code would start with carrier off, but there were users using bridge as a form of dummy device and this broke them. Therefore it was decided (like 5 yrs ago), that bridge should start with carrier on.

#7 lore raw

Hi, all

We should make it compatible. So I made a patch to turn on carrier on this bridge interface when the last sub interface is removed.

Hi, David

Please make tests with this latest patch. Thanks a lot.

Best Regards!
Zhu Yanjun
________________________________________
From: Stephen Hemminger [[email protected]]
Sent: Monday, February 16, 2015 8:51 AM
To: David Ahern
Cc: Zhu, Yanjun; netdev; Wu, Kuaikuai; Tao, Yue
Subject: Re: If bridge have no sub-interfaces, it's status may be still with 'RUNNING'

Originally bridge code would start with carrier off, but there were users using bridge as a form of dummy device and this broke them. Therefore it was decided (like 5 yrs ago), that bridge should start with carrier on.

From 0d16f302f23c9f5101f849450abc073045a193de Mon Sep 17 00:00:00 2001
From: Zhu Yanjun <[email protected]>
Date: Tue, 17 Feb 2015 23:59:08 +0800
Subject: [PATCH 1/1] bridge: turn on carrier after removing the last sub
interface

When the last sub interface is removed from the bridge, the bridge turn off the carrier. Maybe it is not compatible with firstly created bridge without any sub interface. At that time, the carrier of this bridge is turned on.

---
 net/bridge/br_if.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/bridge/br_if.c +6 -0
index ed307db..f391f8c 100644
@@ -565,6 +565,12 @@ int br_del_if(struct net_bridge *br, struct net_device *dev)
 
 	netdev_update_features(br->dev);
 
+	/* No sub interface in bridge, turn on carrier */
+	if (list_empty(&br->port_list)) {
+		eth_hw_addr_random(br->dev);
+		netif_carrier_on(br->dev);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
author
#8 lore raw

Hi, Stephen && David

Any update?

Zhu Yanjun

Quoted 21 lines · Yanjun

Hi, all

We should make it compatible. So I made a patch to turn on carrier on this bridge interface when the last sub interface is removed.

Hi, David

Please make tests with this latest patch. Thanks a lot.

Best Regards!
Zhu Yanjun
________________________________________
From: Stephen Hemminger [[email protected]]
Sent: Monday, February 16, 2015 8:51 AM
To: David Ahern
Cc: Zhu, Yanjun; netdev; Wu, Kuaikuai; Tao, Yue
Subject: Re: If bridge have no sub-interfaces, it's status may be still with 'RUNNING'

Originally bridge code would start with carrier off, but there were users using bridge as a form of dummy device and this broke them. Therefore it was decided (like 5 yrs ago), that bridge should start with carrier on.

#9 lore raw
Quoted 3 lines · On 2/24/15 7:55 PM, yzhu1 wrote:

Hi, Stephen && David

Any update?

As I mentioned in my last response I see no problem with the existing behavior -- 3.18, 3.19 and 4.0-rc1. With all of them the bridge stays in the running state after all interfaces are removed.

David

author
#10 lore raw
Quoted 11 lines · David Ahern
Quoted 3 lines · On 2/24/15 7:55 PM, yzhu1 wrote:

Hi, Stephen && David

Any update?

As I mentioned in my last response I see no problem with the existing behavior -- 3.18, 3.19 and 4.0-rc1. With all of them the bridge stays in the running state after all interfaces are removed.

David

Hi, David

I made tests on kernel 3.19-rc7.

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

br0 Link encap:Ethernet HWaddr 0a:70:0b:06:34:8f
inet6 addr: fe80::870:bff:fe06:348f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:16 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:5054 (5.0 KB)

4. brctl addif br0 eth1

5. brctl delif br0 eth1

6. ifconfig br0 (br0's status is without 'RUNNING')

br0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet6 addr: fe80::870:bff:fe06:348f/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:328 errors:0 dropped:5 overruns:0 frame:0 TX packets:19 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:39997 (39.9 KB) TX bytes:5760 (5.7 KB)

Please compare with the outputs of step 3 and step 6, we can find the difference.

uname:

Linux wind-virtual-machine 3.19.0-rc7 #2 SMP Wed Jan 28 18:36:44 CST 2015 x86_64 x86_64 x86_64 GNU/Linux

So I think we should apply the latest patch to make consistent.

Any reply is appreciated.

Zhu Yanjun

#11 lore raw
In reply to yzhu1
Quoted 7 lines · On Mon, 16 Feb 2015 12:55:47 +0800 yzhu1 <[email protected]> wrote:

Hi, Stephen

Follow your advice, I made a new patch. This patch will turn off carrier when a new bridge interface is created. Please comment on it.

Thanks a lot.
Zhu Yanjun

NAK.
We need to keep the current behavior to not break corner case users.

author
#12 lore raw
In reply to yzhu1

Hi, Stephen && David

Any update ?

Best Regards!
Zhu Yanjun

Quoted 37 lines · On 02/16/2015 12:55 PM, yzhu1 wrote:

Hi, Stephen

Follow your advice, I made a new patch. This patch will turn off carrier when a new bridge interface is created. Please comment on it.

Thanks a lot.
Zhu Yanjun

Quoted 28 lines · Stephen Hemminger
Quoted 14 lines · On Fri, 13 Feb 2015 17:57:45 +0800 yzhu1 <[email protected]> wrote:

Hi, all

I made this test on ubuntu 14.04 with kernel 3,19-rc7:

1. brctl addbr br0

2. ifconfig br0 up

3. ifconfig br0 (br0's status is with 'RUNNING')

4. brctl addif br0 eth0

5. brctl delif br0 eth0

Quoted 7 lines

6. ifconfig br0 (br0's status is without 'RUNNING')

When there is no sub-interface, the flag "RUNNING" is missing after the last sub-interface is removed.

As such, should we keep "RUNNING" flag after the last sub-interface is removed?

This is intentional. If there are no active ports in bridge, then we want to tell applications that packets will go nowhere.