diff mbox

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

Message ID 54E17853.8070106@windriver.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

yzhu1 Feb. 16, 2015, 4:55 a.m. UTC
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
On 02/14/2015 02:30 AM, Stephen Hemminger wrote:
> On Fri, 13 Feb 2015 17:57:45 +0800
> yzhu1 <Yanjun.Zhu@windriver.com> 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?
> This is intentional. If there are no active ports in bridge, then
> we want to tell applications that packets will go nowhere.
>
>

Comments

David Ahern Feb. 16, 2015, 3:47 p.m. UTC | #1
On 2/15/15 9:55 PM, yzhu1 wrote:
>>> 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.

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.

>>>
>>> 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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Hemminger Feb. 16, 2015, 4:51 p.m. UTC | #2
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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Hemminger Feb. 16, 2015, 4:52 p.m. UTC | #3
On Mon, 16 Feb 2015 12:55:47 +0800
yzhu1 <Yanjun.Zhu@windriver.com> 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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
yzhu1 March 10, 2015, 6:07 a.m. UTC | #4
Hi, Stephen && David

Any update ?

Best Regards!
Zhu Yanjun
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
> On 02/14/2015 02:30 AM, Stephen Hemminger wrote:
>> On Fri, 13 Feb 2015 17:57:45 +0800
>> yzhu1 <Yanjun.Zhu@windriver.com> 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?
>> This is intentional. If there are no active ports in bridge, then
>> we want to tell applications that packets will go nowhere.
>>
>>
>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

From e03af5263bcaeea15442601e2a9f65c6b582352b Mon Sep 17 00:00:00 2001
From: Zhu Yanjun <Yanjun.Zhu@windriver.com>
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.

Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Zhu Yanjun <Yanjun.Zhu@windriver.com>
---
 net/bridge/br_device.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index ffd379d..2d60474 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -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);
+	}
 }
-- 
1.9.1