bridge: few enhancements and small fixes
Subsystems (4)
cover bridge: few enhancements and small fixes
Here's a few fixes I've been carrying around. I've now tested them on as many systems / environments as I can. They should be ready.
Luis R. Rodriguez (3):
bridge: preserve random init MAC address
bridge: trigger a bridge calculation upon port changes
bridge: fix bridge root block on designated port
net/bridge/br_device.c | 1 + net/bridge/br_netlink.c | 24 ++++++++++++++++ net/bridge/br_private.h | 2 ++ net/bridge/br_stp.c | 73 +++++++++++++++++++++++++++++++++++++++++++++---- net/bridge/br_stp_if.c | 6 +++- 5 files changed, 99 insertions(+), 7 deletions(-)
Signature · 1 line
1.8.5.3
PATCH 1/3 bridge: preserve random init MAC address
From: "Luis R. Rodriguez" <[email protected]>
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a net_device as a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.
If you manually set the bridge address that will always be respected. This change only takes effect if at the time of computing the new root port we determine we have found no candidates.
--- net/bridge/br_device.c | 1 + net/bridge/br_private.h | 1 + net/bridge/br_stp_if.c | 3 +++ 3 files changed, 5 insertions(+)
net/bridge/br_device.c +1 -0
@@ -368,6 +368,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_id.prio[1 ] =0x00 ;ether_addr_copy (br->group_addr, eth_reserved_addr_base); +ether_addr_copy (br->random_init_addr, dev->dev_addr); br->stp_enabled =BR_NO_STP ; br->group_fwd_mask =BR_GROUPFWD_DEFAULT ;
net/bridge/br_private.h +1 -0
@@ -240,6 +240,7 @@ struct net_bridgeunsigned long bridge_hello_time;unsigned long bridge_forward_delay; +u8 random_init_addr[ETH_ALEN ];u8 group_addr[ETH_ALEN ];u16 root_port;
net/bridge/br_stp_if.c +3 -0
@@ -239,6 +239,9 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */ +if (ether_addr_equal (addr, br_mac_zero)) + addr = br->random_init_addr; +br_stp_change_bridge_id (br, addr);return true; }
Signature · 1 line
1.8.5.3
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 55 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.If you manually set the bridge address that will always be respected. This change only takes effect if at the time of computing the new root port we determine we have found no candidates.
Cc Stephen Hemminger <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- net/bridge/br_device.c | 1 + net/bridge/br_private.h | 1 + net/bridge/br_stp_if.c | 3 +++ 3 files changed, 5 insertions(+)net/bridge/br_device.c +1
-0@@ -368,6 +368,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_id.prio[1 ] =0x00 ;ether_addr_copy (br->group_addr, eth_reserved_addr_base); +ether_addr_copy (br->random_init_addr, dev->dev_addr); br->stp_enabled =BR_NO_STP ; br->group_fwd_mask =BR_GROUPFWD_DEFAULT ;net/bridge/br_private.h +1
-0@@ -240,6 +240,7 @@ struct net_bridgeunsigned long bridge_hello_time;unsigned long bridge_forward_delay; +u8 random_init_addr[ETH_ALEN ];u8 group_addr[ETH_ALEN ];u16 root_port;net/bridge/br_stp_if.c +0
-0
net/bridge/br_stp_if.c bool br_stp_recalculate_bridge_id(struct net_bridge *br) · line 247
Quoted 9 lines
net/bridge/br_stp_if.c +3
-0@@ -239,6 +239,9 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */ +if (ether_addr_equal (addr, br_mac_zero)) + addr = br->random_init_addr; +br_stp_change_bridge_id (br, addr);return true; }
nit,
If the last detached port happens to have the same addr as random_init_addr, this seems to call br_stp_change_bridge_id() even though bridge_id is not changed.
Shouldn't the assignment of random_init_addr be done before the check of "no change"?
Toshiaki Makita
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.
Ah good point.
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?
Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
Stephen?
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.Ah good point.
Quoted 7 lines
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
This was recently discussed by Stephen and me.
I'm thinking it should be allowed.
http://marc.info/?l=linux-netdev&m=139182743919257&w=2
Toshiaki Makita
Quoted 4 lines
Stephen?
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 18 lines · Toshiaki Makita
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.Ah good point.
Quoted 7 lines
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
Quoted 4 lines
This was recently discussed by Stephen and me.
I'm thinking it should be allowed.
Great now that that's sorted out though I still think calling br_stp_change_bridge_id() is right just as calling the update features as the device is different. It could however be confusing when this situation is run and folks might report odd bugs unless we could tell them apart clearly. Thoughts?
Luis
Re: [Bridge] [PATCH 1/3] bridge: preserve random init MAC address
Quoted 23 lines · Luis R. Rodriguez
Quoted 21 lines · Toshiaki Makita
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.Ah good point.
Quoted 7 lines
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
This was recently discussed by Stephen and me.
I'm thinking it should be allowed.
Quoted 7 lines
Great now that that's sorted out though I still think calling
br_stp_change_bridge_id()is right just as calling the update features as the device is different. It could however be confusing when this situation is run and folks might report odd bugs unless we could tell them apart clearly. Thoughts?
br_stp_change_bridge_id() is currently called only if bridge_id.addr should be changed.
If the addr should not be changed but some updates are needed, br_stp_recalculate_bridge_id() doesn't seem to fit into it.
Toshiaki Makita
Re: [Bridge] [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 23 lines · Luis R. Rodriguez
Quoted 21 lines · Toshiaki Makita
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.Ah good point.
Quoted 7 lines
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
This was recently discussed by Stephen and me.
I'm thinking it should be allowed.
Quoted 7 lines
Great now that that's sorted out though I still think calling
br_stp_change_bridge_id()is right just as calling the update features as the device is different. It could however be confusing when this situation is run and folks might report odd bugs unless we could tell them apart clearly. Thoughts?
br_stp_change_bridge_id() is currently called only if bridge_id.addr should be changed.
If the addr should not be changed but some updates are needed, br_stp_recalculate_bridge_id() doesn't seem to fit into it.
Toshiaki Makita
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Toshiaki MakitaQuoted 18 lines · Toshiaki Makita
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.Ah good point.
Quoted 7 lines
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
Quoted 4 lines
This was recently discussed by Stephen and me.
I'm thinking it should be allowed.
Great now that that's sorted out though I still think calling br_stp_change_bridge_id() is right just as calling the update features as the device is different. It could however be confusing when this situation is run and folks might report odd bugs unless we could tell them apart clearly. Thoughts?
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.Ah good point.
Quoted 7 lines
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
This was recently discussed by Stephen and me.
I'm thinking it should be allowed.
http://marc.info/?l=linux-netdev&m=139182743919257&w=2
Toshiaki Makita
Quoted 4 lines
Stephen?
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Toshiaki MakitaQuoted 4 lines · Toshiaki Makita
nit,
If the last detached port happens to have the same addr asrandom_init_addr, this seems to callbr_stp_change_bridge_id()even thoughbridge_idis not changed.
Ah good point.
Quoted 2 lines
Shouldn't the assignment of
random_init_addrbe done before the check of "no change"?
Good question, should we even allow two ports to have the same MAC address or should we complain and refuse to add it? If so that should mean we should also have to monitor any manual address changes or events for address changes on the ports.
Stephen?
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 55 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.If you manually set the bridge address that will always be respected. This change only takes effect if at the time of computing the new root port we determine we have found no candidates.
Cc Stephen Hemminger <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- net/bridge/br_device.c | 1 + net/bridge/br_private.h | 1 + net/bridge/br_stp_if.c | 3 +++ 3 files changed, 5 insertions(+)net/bridge/br_device.c +1
-0@@ -368,6 +368,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_id.prio[1 ] =0x00 ;ether_addr_copy (br->group_addr, eth_reserved_addr_base); +ether_addr_copy (br->random_init_addr, dev->dev_addr); br->stp_enabled =BR_NO_STP ; br->group_fwd_mask =BR_GROUPFWD_DEFAULT ;net/bridge/br_private.h +1
-0@@ -240,6 +240,7 @@ struct net_bridgeunsigned long bridge_hello_time;unsigned long bridge_forward_delay; +u8 random_init_addr[ETH_ALEN ];u8 group_addr[ETH_ALEN ];u16 root_port;net/bridge/br_stp_if.c +0
-0
net/bridge/br_stp_if.c bool br_stp_recalculate_bridge_id(struct net_bridge *br) · line 247
Quoted 9 lines
net/bridge/br_stp_if.c +3
-0@@ -239,6 +239,9 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */ +if (ether_addr_equal (addr, br_mac_zero)) + addr = br->random_init_addr; +br_stp_change_bridge_id (br, addr);return true; }
nit,
If the last detached port happens to have the same addr as random_init_addr, this seems to call br_stp_change_bridge_id() even though bridge_id is not changed.
Shouldn't the assignment of random_init_addr be done before the check of "no change"?
Toshiaki Makita
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.
What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this that just keeps the old value. The bridge is in a meaningless state when there are no ports, and when the first port is added back it will be used as the new bridge id.
net/bridge/br_stp_if.c +3 -0
@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + +if (addr == br_mac_zero) +return false;/* keep original address */ if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 9 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.
Quoted 4 lines
What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
OK I'll go and add some changes for this then.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Stephen HemmingerQuoted 9 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.
Quoted 4 lines
What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
OK I'll go and add some changes for this then.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Stephen HemmingerQuoted 28 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this
net/bridge/br_stp_if.c +3
-0@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + +if (addr == br_mac_zero) +return false;/* keep original address */ if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */
Quoted 1 line
that just keeps the old value.
The old value could be a port which got root blocked, I think it can be confusing to see that happen. Either way feel free to make the call, I'll provide more details below on perhaps one reason to keep the original MAC address.
Quoted 1 line
The bridge is in a meaningless state when there are no ports,
Some virtualization topologies may want a backend with no link (or perhaps one which is dynamic, with the option to have none) to the internet but just a bridge so guests sharing the bridge can talk to each other. In this case bridging can be used only to link the batch of guests.
In this case the bridge simply acts as a switch, but also can be used as the interface for DHCP, for example. In such a case the guests will be doing ARP to get to the DHCP server. There's a flurry of ways one can try to get all this meshed together including enablign an ARP proxy but I'm looking at ways to optimize this further -- but I'd like to address the current usage cases first.
Quoted 2 lines
and when the first port is added back it will be used as the new bridge id.
Sure. Let me know how you think we should proceed with this patch based on the above.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 29 lines · Luis R. Rodriguez
Quoted 28 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this
net/bridge/br_stp_if.c 2014-03-18 20:09:09.334388826 -0700 renamed from net/bridge/br_stp_if.c 2014-02-12 08:21:56.733857356 -0800 +3
-0@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + + if (addr == br_mac_zero) + return false; /* keep original address */ if (ether_addr_equal(br->bridge_id.addr, addr)) return false; /* no change */
Quoted 6 lines
Quoted 1 line
that just keeps the old value.
The old value could be a port which got root blocked, I think it can be confusing to see that happen. Either way feel free to make the call, I'll provide more details below on perhaps one reason to keep the original MAC address.
Stephen, I'd like to respin this series to address all pending feedback, I'd still like your feedback / call / judgement on this part. I'm fine either way, just wanted to ensure I highlight the reasoning of why I kept the original random MAC address. Please keep in mind that at this point I'm convinced bridging is the *wrong* solution to networking with guests but it is being used in a lot of current topologies, this would just help with smoothing out corner cases.
Quoted 15 lines
Quoted 1 line
The bridge is in a meaningless state when there are no ports,
Some virtualization topologies may want a backend with no link (or perhaps one which is dynamic, with the option to have none) to the internet but just a bridge so guests sharing the bridge can talk to each other. In this case bridging can be used only to link the batch of guests.
In this case the bridge simply acts as a switch, but also can be used as the interface for DHCP, for example. In such a case the guests will be doing ARP to get to the DHCP server. There's a flurry of ways one can try to get all this meshed together including enablign an ARP proxy but I'm looking at ways to optimize this further -- but I'd like to address the current usage cases first.
Quoted 5 lines
Quoted 2 lines
and when the first port is added back it will be used as the new bridge id.
Sure. Let me know how you think we should proceed with this patch based on the above.
Thanks in advance.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
Quoted 4 lines · Luis R. Rodriguez
Stephen, I'd like to respin this series to address all pending feedback, I'd still like your feedback / call / judgement on this part. I'm fine either way, just wanted to ensure I highlight the reasoning of why I kept the original random MAC address.
Re-poke.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 4 lines · Luis R. Rodriguez
Stephen, I'd like to respin this series to address all pending feedback, I'd still like your feedback / call / judgement on this part. I'm fine either way, just wanted to ensure I highlight the reasoning of why I kept the original random MAC address.
Re-poke.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 37 lines · Luis R. Rodriguez
Quoted 29 lines · Luis R. Rodriguez
Quoted 28 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this
net/bridge/br_stp_if.c 2014-03-18 20:09:09.334388826 -0700 renamed from net/bridge/br_stp_if.c 2014-02-12 08:21:56.733857356 -0800 +3
-0@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + + if (addr == br_mac_zero) + return false; /* keep original address */ if (ether_addr_equal(br->bridge_id.addr, addr)) return false; /* no change */Quoted 6 lines
Quoted 1 line
that just keeps the old value.
The old value could be a port which got root blocked, I think it can be confusing to see that happen. Either way feel free to make the call, I'll provide more details below on perhaps one reason to keep the original MAC address.
Quoted 9 lines
Stephen, I'd like to respin this series to address all pending feedback, I'd still like your feedback / call / judgement on this part. I'm fine either way, just wanted to ensure I highlight the reasoning of why I kept the original random MAC address. Please keep in mind that at this point I'm convinced bridging is the *wrong* solution to networking with guests but it is being used in a lot of current topologies, this would just help with smoothing out corner cases.
Hi Luis
I took at this series again, I think it might make to generate a new random address instead of storing the original. There is not much point in storing the original since it's been gone, and most likely not advertised anywhere anyway.
As for virtualization configuration you described, a lot of times there is a single port in the down state that remains. At least that's how libvirt manages it's bridged networks.
Thanks
-vlad
Quoted 29 lines
Quoted 15 lines
Quoted 1 line
The bridge is in a meaningless state when there are no ports,
Some virtualization topologies may want a backend with no link (or perhaps one which is dynamic, with the option to have none) to the internet but just a bridge so guests sharing the bridge can talk to each other. In this case bridging can be used only to link the batch of guests.
In this case the bridge simply acts as a switch, but also can be used as the interface for DHCP, for example. In such a case the guests will be doing ARP to get to the DHCP server. There's a flurry of ways one can try to get all this meshed together including enablign an ARP proxy but I'm looking at ways to optimize this further -- but I'd like to address the current usage cases first.
Quoted 5 lines
Quoted 2 lines
and when the first port is added back it will be used as the new bridge id.
Sure. Let me know how you think we should proceed with this patch based on the above.
Thanks in advance.
Luis
--
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
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 37 lines · Luis R. Rodriguez
Quoted 29 lines · Luis R. Rodriguez
Quoted 28 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this
net/bridge/br_stp_if.c 2014-03-18 20:09:09.334388826 -0700 renamed from net/bridge/br_stp_if.c 2014-02-12 08:21:56.733857356 -0800 +3
-0@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + + if (addr == br_mac_zero) + return false; /* keep original address */ if (ether_addr_equal(br->bridge_id.addr, addr)) return false; /* no change */Quoted 6 lines
Quoted 1 line
that just keeps the old value.
The old value could be a port which got root blocked, I think it can be confusing to see that happen. Either way feel free to make the call, I'll provide more details below on perhaps one reason to keep the original MAC address.
Quoted 9 lines
Stephen, I'd like to respin this series to address all pending feedback, I'd still like your feedback / call / judgement on this part. I'm fine either way, just wanted to ensure I highlight the reasoning of why I kept the original random MAC address. Please keep in mind that at this point I'm convinced bridging is the *wrong* solution to networking with guests but it is being used in a lot of current topologies, this would just help with smoothing out corner cases.
Hi Luis
I took at this series again, I think it might make to generate a new random address instead of storing the original. There is not much point in storing the original since it's been gone, and most likely not advertised anywhere anyway.
As for virtualization configuration you described, a lot of times there is a single port in the down state that remains. At least that's how libvirt manages it's bridged networks.
Thanks
-vlad
Quoted 29 lines
Quoted 15 lines
Quoted 1 line
The bridge is in a meaningless state when there are no ports,
Some virtualization topologies may want a backend with no link (or perhaps one which is dynamic, with the option to have none) to the internet but just a bridge so guests sharing the bridge can talk to each other. In this case bridging can be used only to link the batch of guests.
In this case the bridge simply acts as a switch, but also can be used as the interface for DHCP, for example. In such a case the guests will be doing ARP to get to the DHCP server. There's a flurry of ways one can try to get all this meshed together including enablign an ARP proxy but I'm looking at ways to optimize this further -- but I'd like to address the current usage cases first.
Quoted 5 lines
Quoted 2 lines
and when the first port is added back it will be used as the new bridge id.
Sure. Let me know how you think we should proceed with this patch based on the above.
Thanks in advance.
Luis
--
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
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 29 lines · Luis R. Rodriguez
Quoted 28 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this
net/bridge/br_stp_if.c 2014-03-18 20:09:09.334388826 -0700 renamed from net/bridge/br_stp_if.c 2014-02-12 08:21:56.733857356 -0800 +3
-0@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + + if (addr == br_mac_zero) + return false; /* keep original address */ if (ether_addr_equal(br->bridge_id.addr, addr)) return false; /* no change */
Quoted 6 lines
Quoted 1 line
that just keeps the old value.
The old value could be a port which got root blocked, I think it can be confusing to see that happen. Either way feel free to make the call, I'll provide more details below on perhaps one reason to keep the original MAC address.
Stephen, I'd like to respin this series to address all pending feedback, I'd still like your feedback / call / judgement on this part. I'm fine either way, just wanted to ensure I highlight the reasoning of why I kept the original random MAC address. Please keep in mind that at this point I'm convinced bridging is the *wrong* solution to networking with guests but it is being used in a lot of current topologies, this would just help with smoothing out corner cases.
Quoted 15 lines
Quoted 1 line
The bridge is in a meaningless state when there are no ports,
Some virtualization topologies may want a backend with no link (or perhaps one which is dynamic, with the option to have none) to the internet but just a bridge so guests sharing the bridge can talk to each other. In this case bridging can be used only to link the batch of guests.
In this case the bridge simply acts as a switch, but also can be used as the interface for DHCP, for example. In such a case the guests will be doing ARP to get to the DHCP server. There's a flurry of ways one can try to get all this meshed together including enablign an ARP proxy but I'm looking at ways to optimize this further -- but I'd like to address the current usage cases first.
Quoted 5 lines
Quoted 2 lines
and when the first port is added back it will be used as the new bridge id.
Sure. Let me know how you think we should proceed with this patch based on the above.
Thanks in advance.
Luis
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Stephen HemmingerQuoted 28 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this
net/bridge/br_stp_if.c +3
-0@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + +if (addr == br_mac_zero) +return false;/* keep original address */ if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */
Quoted 1 line
that just keeps the old value.
The old value could be a port which got root blocked, I think it can be confusing to see that happen. Either way feel free to make the call, I'll provide more details below on perhaps one reason to keep the original MAC address.
Quoted 1 line
The bridge is in a meaningless state when there are no ports,
Some virtualization topologies may want a backend with no link (or perhaps one which is dynamic, with the option to have none) to the internet but just a bridge so guests sharing the bridge can talk to each other. In this case bridging can be used only to link the batch of guests.
In this case the bridge simply acts as a switch, but also can be used as the interface for DHCP, for example. In such a case the guests will be doing ARP to get to the DHCP server. There's a flurry of ways one can try to get all this meshed together including enablign an ARP proxy but I'm looking at ways to optimize this further -- but I'd like to address the current usage cases first.
Quoted 2 lines
and when the first port is added back it will be used as the new bridge id.
Sure. Let me know how you think we should proceed with this patch based on the above.
Luis
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/3] bridge: preserve random init MAC address
In reply to Luis R. RodriguezQuoted 5 lines · On Wed, 12 Mar 2014 20:15:25 -0700 "Luis R. Rodriguez"…
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a
net_deviceas a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.
What is supposed to happen is that the recalculate chooses the lowest MAC address of the slaves. If there are no slaves it might as well just calculate a new random value. There is not great merit in preserving the original defunct address.
Or something like this that just keeps the old value. The bridge is in a meaningless state when there are no ports, and when the first port is added back it will be used as the new bridge id.
net/bridge/br_stp_if.c +3 -0
@@ -235,6 +235,9 @@ bool br_stp_recalculate_bridge_id(struct addr = p->dev->dev_addr; } + +if (addr == br_mac_zero) +return false;/* keep original address */ if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */
PATCH 1/3 bridge: preserve random init MAC address
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
As it is now if you add create a bridge it gets started with a random MAC address and if you then add a net_device as a slave but later kick it out you end up with a zero MAC address. Instead preserve the original random MAC address and use it.
If you manually set the bridge address that will always be respected. This change only takes effect if at the time of computing the new root port we determine we have found no candidates.
--- net/bridge/br_device.c | 1 + net/bridge/br_private.h | 1 + net/bridge/br_stp_if.c | 3 +++ 3 files changed, 5 insertions(+)
net/bridge/br_device.c +1 -0
@@ -368,6 +368,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_id.prio[1 ] =0x00 ;ether_addr_copy (br->group_addr, eth_reserved_addr_base); +ether_addr_copy (br->random_init_addr, dev->dev_addr); br->stp_enabled =BR_NO_STP ; br->group_fwd_mask =BR_GROUPFWD_DEFAULT ;
net/bridge/br_private.h +1 -0
@@ -240,6 +240,7 @@ struct net_bridgeunsigned long bridge_hello_time;unsigned long bridge_forward_delay; +u8 random_init_addr[ETH_ALEN ];u8 group_addr[ETH_ALEN ];u16 root_port;
net/bridge/br_stp_if.c +3 -0
@@ -239,6 +239,9 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)if (ether_addr_equal (br->bridge_id.addr, addr))return false;/* no change */ +if (ether_addr_equal (addr, br_mac_zero)) + addr = br->random_init_addr; +br_stp_change_bridge_id (br, addr);return true; }
Signature · 1 line
1.8.5.3
PATCH 2/3 bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
If netlink is used to tune a port we currently don't trigger a new recalculation of the bridge id, ensure that happens just as if we're adding a new net_device onto the bridge.
--- net/bridge/br_netlink.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bridge/br_netlink.c +6 -0
@@ -364,6 +364,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh)struct net_bridge_port *p;struct nlattr *tb[IFLA_BRPORT_MAX +1 ];int err =0 ; +bool changed; protinfo =nlmsg_find_attr (nlh,sizeof (struct ifinfomsg ),IFLA_PROTINFO ); afspec =nlmsg_find_attr (nlh,sizeof (struct ifinfomsg ),IFLA_AF_SPEC );
@@ -386,7 +387,12 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh)spin_lock_bh (&p->br->lock); err =br_setport (p, tb); + changed =br_stp_recalculate_bridge_id (p->br);spin_unlock_bh (&p->br->lock); +if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev); }else {/* Binary compatibility with old RSTP */ if (nla_len (protinfo) <sizeof (u8))
Signature · 1 line
1.8.5.3
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 3 lines · Luis R. Rodriguez
spin_lock_bh(&p->br->lock); err = br_setport(p, tb);+ changed =
br_stp_recalculate_bridge_id(p->br);
Looks like you only want to check if the mac addr gets changed here, but br_stp_recalculate_bridge_id() does more than just checking it, are you sure the side-effects are all what you want here?
net/bridge/br_netlink.c int br_setlink(struct net_device *dev, struct nlmsghdr *nlh) · line 395
Quoted 5 lines
spin_unlock_bh(&p->br->lock);net/bridge/br_netlink.c +4
-0+if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev);
I think this is supposed to be in netdev event handler of br->dev instead of here.
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 7 lines · Cong Wang
Quoted 3 lines · Luis R. Rodriguez
spin_lock_bh(&p->br->lock); err = br_setport(p, tb);+ changed =
br_stp_recalculate_bridge_id(p->br);Looks like you only want to check if the mac addr gets changed here,
Nope, the reason why we want a full thorough check is that br_setport() may change currently any of these:
* IFLA_BRPORT_MODE
* IFLA_BRPORT_GUARD
* IFLA_BRPORT_FAST_LEAVE
* IFLA_BRPORT_PROTECT
* IFLA_BRPORT_LEARNING,
* IFLA_BRPORT_UNICAST_FLOOD
* IFLA_BRPORT_COST
* IFLA_BRPORT_PRIORITY
* IFLA_BRPORT_STATE
That's good reason to trigger a good inspection. Having the MAC address change would be simply collateral and its just something we need to do some additional work for outside of the locking context.
Quoted 2 lines
but
br_stp_recalculate_bridge_id()does more than just checking it, are you sure the side-effects are all what you want here?
Yeap.
Quoted 8 lines
net/bridge/br_netlink.c int br_setlink(struct net_device *dev, struct nlmsghdr *nlh) · line 395
Quoted 5 lines
spin_unlock_bh(&p->br->lock);net/bridge/br_netlink.c +4
-0+if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev);I think this is supposed to be in netdev event handler of
br->devinstead of here.
Do you mean netdev_update_features() ? I mimic'd what was being done on br_del_if() given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to change br_del_if() too. Let me know if you see any reason for something else.
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);net/bridge/br_netlink.c +4
-0+if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev);
Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.
Yeah, for me it looks like it's better to call netdev_update_features() in the event handler of br->dev, rather than where calling call_netdevice_notifiers(..., br->dev);.
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.
Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.
I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix br_features_recompute() to take into consideration BR_ROOT_BLOCK as below. Notice how netdev_update_features() is called above even if the MAC address did not change, just as is done on br_del_if(). There is an NETDEV_FEAT_CHANGE event so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)
for both the above then and also br_del_if()? How about the below change?
net/bridge/br_if.c +2 -0
@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 42 lines · Luis R. Rodriguez
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()? How about the below change?net/bridge/br_if.c +0
-0
net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 8 lines
net/bridge/br_if.c +2
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }
Cong, can you provide feedback on this? I tried to grow confidence on the hunk above but its not clear but the other points still hold and I'd love your feedback on those.
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 45 lines · Luis R. Rodriguez
Quoted 44 lines · Luis R. Rodriguez
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()? How about the below change?net/bridge/br_if.c +0
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;
Quoted 10 lines
net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 6 lines
net/bridge/br_if.c +2
-0list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Cong, can you provide feedback on this? I tried to grow confidence on the hunk above but its not clear but the other points still hold and I'd love your feedback on those.
Re-poke.
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 45 lines · Luis R. Rodriguez
Quoted 44 lines · Luis R. Rodriguez
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()? How about the below change?net/bridge/br_if.c +0
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;
Quoted 10 lines
net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 6 lines
net/bridge/br_if.c +2
-0list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Cong, can you provide feedback on this? I tried to grow confidence on the hunk above but its not clear but the other points still hold and I'd love your feedback on those.
Re-poke.
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 45 lines · Luis R. Rodriguez
Quoted 44 lines · Luis R. Rodriguez
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()? How about the below change?net/bridge/br_if.c +0
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;
Quoted 11 lines
net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 6 lines
net/bridge/br_if.c +2
-0list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Cong, can you provide feedback on this? I tried to grow confidence on the hunk above but its not clear but the other points still hold and I'd love your feedback on those.
Hi Luis
The hunk above isn't right. Just because you set ROOT_BLOCK on the port doesn't mean that you should ignore it's device features. If the device you just added happens to disable or enable some device offload feature, you should take that into account.
Thanks
-vlad
Quoted 6 lines
Luis
--
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
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 17 lines · Vlad Yasevich
Quoted 6 lines · Luis R. Rodriguez
net/bridge/br_if.c +0
-0net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 8 lines
net/bridge/br_if.c +2
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Hi Luis
Quoted 4 lines
The hunk above isn't right. Just because you set
ROOT_BLOCKon the port doesn't mean that you should ignore it's device features. If the device you just added happens to disable or enable some device offload feature, you should take that into account.
OK thanks, how about this part:
Quoted 33 lines · Luis R. Rodriguez
On Tue, Mar 18, 2014 at 02:22:43PM -0700, Luis R. Rodriguez wrote:
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
Quoted 3 lines
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()?
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
Quoted 18 lines · Luis R. Rodriguez
Quoted 17 lines · Vlad Yasevich
Quoted 6 lines · Luis R. Rodriguez
net/bridge/br_if.c +0
-0net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 8 lines
net/bridge/br_if.c +2
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Hi Luis
Quoted 20 lines
Quoted 4 lines
The hunk above isn't right. Just because you set
ROOT_BLOCKon the port doesn't mean that you should ignore it's device features. If the device you just added happens to disable or enable some device offload feature, you should take that into account.OK thanks, how about this part:
Quoted 12 lines · Luis R. Rodriguez
On Tue, Mar 18, 2014 at 02:22:43PM -0700, Luis R. Rodriguez wrote:
Quoted 10 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);
This is actually just a part of it. You also need to handle the sysfs changing the flag.
Look at the first 2 patches in this series:
http://www.spinics.net/lists/netdev/msg280863.html
You might need that functionality.
-vlad
Quoted 27 lines
Quoted 21 lines
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just callQuoted 3 lines
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()?Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 18 lines · Luis R. Rodriguez
Quoted 17 lines · Vlad Yasevich
Quoted 6 lines · Luis R. Rodriguez
net/bridge/br_if.c +0
-0net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 8 lines
net/bridge/br_if.c +2
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Hi Luis
Quoted 20 lines
Quoted 4 lines
The hunk above isn't right. Just because you set
ROOT_BLOCKon the port doesn't mean that you should ignore it's device features. If the device you just added happens to disable or enable some device offload feature, you should take that into account.OK thanks, how about this part:
Quoted 12 lines · Luis R. Rodriguez
On Tue, Mar 18, 2014 at 02:22:43PM -0700, Luis R. Rodriguez wrote:
Quoted 10 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);
This is actually just a part of it. You also need to handle the sysfs changing the flag.
Look at the first 2 patches in this series:
http://www.spinics.net/lists/netdev/msg280863.html
You might need that functionality.
-vlad
Quoted 27 lines
Quoted 21 lines
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just callQuoted 3 lines
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()?Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Vlad YasevichQuoted 17 lines · Vlad Yasevich
Quoted 6 lines · Luis R. Rodriguez
net/bridge/br_if.c +0
-0net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 8 lines
net/bridge/br_if.c +2
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Hi Luis
Quoted 4 lines
The hunk above isn't right. Just because you set
ROOT_BLOCKon the port doesn't mean that you should ignore it's device features. If the device you just added happens to disable or enable some device offload feature, you should take that into account.
OK thanks, how about this part:
Quoted 33 lines · Luis R. Rodriguez
On Tue, Mar 18, 2014 at 02:22:43PM -0700, Luis R. Rodriguez wrote:
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
Quoted 3 lines
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()?
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 45 lines · Luis R. Rodriguez
Quoted 44 lines · Luis R. Rodriguez
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()? How about the below change?net/bridge/br_if.c +0
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;
Quoted 11 lines
net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 6 lines
net/bridge/br_if.c +2
-0list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }Cong, can you provide feedback on this? I tried to grow confidence on the hunk above but its not clear but the other points still hold and I'd love your feedback on those.
Hi Luis
The hunk above isn't right. Just because you set ROOT_BLOCK on the port doesn't mean that you should ignore it's device features. If the device you just added happens to disable or enable some device offload feature, you should take that into account.
Thanks
-vlad
Quoted 6 lines
Luis
--
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
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 42 lines · Luis R. Rodriguez
Quoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix
br_features_recompute()to take into considerationBR_ROOT_BLOCKas below. Notice hownetdev_update_features()is called above even if the MAC address did not change, just as is done onbr_del_if(). There is anNETDEV_FEAT_CHANGEevent so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)for both the above then and also
br_del_if()? How about the below change?net/bridge/br_if.c +0
-0
net/bridge/br_if.c netdev_features_t br_features_recompute(struct net_bridge *br, · line 322
Quoted 8 lines
net/bridge/br_if.c +2
-0@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }
Cong, can you provide feedback on this? I tried to grow confidence on the hunk above but its not clear but the other points still hold and I'd love your feedback on those.
Luis
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Cong WangQuoted 20 lines · Cong Wang
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);(quoted diff) +4
-0+ if (changed) + call_netdevice_notifiers(NETDEV_CHANGEADDR, + p->br->dev); + netdev_update_features(p->br->dev);Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.
Quoted 3 lines
Yeah, for me it looks like it's better to call
netdev_update_features()in the event handler ofbr->dev, rather than where callingcall_netdevice_notifiers(..., br->dev);.
I still don't see why, in fact trying to verify this I am wondering now if instead we should actually fix br_features_recompute() to take into consideration BR_ROOT_BLOCK as below. Notice how netdev_update_features() is called above even if the MAC address did not change, just as is done on br_del_if(). There is an NETDEV_FEAT_CHANGE event so would it be more appropriate we just call
call_netdevice_notifiers(NETDEV_FEAT_CHANGE, p->br->dev)
for both the above then and also br_del_if()? How about the below change?
net/bridge/br_if.c +2 -0
@@ -315,6 +315,8 @@ netdev_features_t br_features_recompute(struct net_bridge *br, features &= ~NETIF_F_ONE_FOR_ALL ;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ; features =netdev_increment_features (features, p->dev->features, mask); }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Cong Wang
Quoted 5 lines · Luis R. Rodriguez
spin_unlock_bh(&p->br->lock);net/bridge/br_netlink.c +4
-0+if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev);
Quoted 9 lines
Quoted 2 lines
I think this is supposed to be in netdev event handler of
br->devinstead of here.Do you mean
netdev_update_features()? I mimic'd what was being done onbr_del_if()given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to changebr_del_if()too. Let me know if you see any reason for something else.
Yeah, for me it looks like it's better to call netdev_update_features() in the event handler of br->dev, rather than where calling call_netdevice_notifiers(..., br->dev);.
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Cong WangQuoted 7 lines · Cong Wang
Quoted 3 lines · Luis R. Rodriguez
spin_lock_bh(&p->br->lock); err = br_setport(p, tb);+ changed =
br_stp_recalculate_bridge_id(p->br);Looks like you only want to check if the mac addr gets changed here,
Nope, the reason why we want a full thorough check is that br_setport() may change currently any of these:
* IFLA_BRPORT_MODE
* IFLA_BRPORT_GUARD
* IFLA_BRPORT_FAST_LEAVE
* IFLA_BRPORT_PROTECT
* IFLA_BRPORT_LEARNING,
* IFLA_BRPORT_UNICAST_FLOOD
* IFLA_BRPORT_COST
* IFLA_BRPORT_PRIORITY
* IFLA_BRPORT_STATE
That's good reason to trigger a good inspection. Having the MAC address change would be simply collateral and its just something we need to do some additional work for outside of the locking context.
Quoted 2 lines
but
br_stp_recalculate_bridge_id()does more than just checking it, are you sure the side-effects are all what you want here?
Yeap.
Quoted 8 lines
net/bridge/br_netlink.c int br_setlink(struct net_device *dev, struct nlmsghdr *nlh) · line 395
Quoted 5 lines
spin_unlock_bh(&p->br->lock);net/bridge/br_netlink.c +4
-0+if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev);I think this is supposed to be in netdev event handler of
br->devinstead of here.
Do you mean netdev_update_features() ? I mimic'd what was being done on br_del_if() given that root blocking is doing something similar. If we need to change something for the above then I suppose it means we need to change br_del_if() too. Let me know if you see any reason for something else.
Luis
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/3] bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezQuoted 3 lines · Luis R. Rodriguez
spin_lock_bh(&p->br->lock); err = br_setport(p, tb);+ changed =
br_stp_recalculate_bridge_id(p->br);
Looks like you only want to check if the mac addr gets changed here, but br_stp_recalculate_bridge_id() does more than just checking it, are you sure the side-effects are all what you want here?
net/bridge/br_netlink.c int br_setlink(struct net_device *dev, struct nlmsghdr *nlh) · line 395
Quoted 5 lines
spin_unlock_bh(&p->br->lock);net/bridge/br_netlink.c +4
-0+if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev);
I think this is supposed to be in netdev event handler of br->dev instead of here.
PATCH 2/3 bridge: trigger a bridge calculation upon port changes
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
If netlink is used to tune a port we currently don't trigger a new recalculation of the bridge id, ensure that happens just as if we're adding a new net_device onto the bridge.
--- net/bridge/br_netlink.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bridge/br_netlink.c +6 -0
@@ -364,6 +364,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh)struct net_bridge_port *p;struct nlattr *tb[IFLA_BRPORT_MAX +1 ];int err =0 ; +bool changed; protinfo =nlmsg_find_attr (nlh,sizeof (struct ifinfomsg ),IFLA_PROTINFO ); afspec =nlmsg_find_attr (nlh,sizeof (struct ifinfomsg ),IFLA_AF_SPEC );
@@ -386,7 +387,12 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh)spin_lock_bh (&p->br->lock); err =br_setport (p, tb); + changed =br_stp_recalculate_bridge_id (p->br);spin_unlock_bh (&p->br->lock); +if (changed) +call_netdevice_notifiers (NETDEV_CHANGEADDR , + p->br->dev); +netdev_update_features (p->br->dev); }else {/* Binary compatibility with old RSTP */ if (nla_len (protinfo) <sizeof (u8))
Signature · 1 line
1.8.5.3
PATCH 3/3 bridge: fix bridge root block on designated port
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Root port blocking was designed so that a bridge port can opt out of becoming the designated root port for a bridge. If a port however first becomes the designated root port and we then toggle the root port block on it we currently don't kick that port out of the designated root port. This fixes that. This is particularly important for net_devices that would wish to never become a root port from the start, currently toggling that off will enable root port flag but it won't really kick the bridge and do what you'd expect, the MAC address is kept on the bridge of the toggled port for root_block if it was the designated port.
In order to catch if a port with root port block preference is set we need to move our check for root block prior to the root selection so check for root blocked ports upon eveyr br_configuration_update(). We also simply just prevent the root-blocked ports from consideration as root port candidates on br_should_become_root_port() and br_stp_recalculate_bridge_id().
The issue that this patch is trying to address and fix can be tested easily before and after this patch is applied using 2 TAP net_devices and then toggling at will with the root_block knob.
ip tuntap add dev tap0 mode tap
ip tuntap add dev tap1 mode tap
ip link add dev br0 type bridge
ip link show br0
echo -------------------------------------------
ip link set dev tap0 master br0
ip link
echo -------------------------------------------
ip link set dev tap1 master br0
ip link
echo -------------------------------------------
Upon review at the above results you can toggle root_block on each port to see if you see the results you expect.
bridge link set dev tap0 root_block on
ip link
bridge link set dev tap1 root_block on
ip link
Toggling off root_block on any port should will bring back the port to be a candidate for designated root port:
bridge link set dev tap1 root_block off
ip link
bridge link set dev tap0 root_block off
ip link
To nuke:
ip tuntap del tap0 mode tap
ip tuntap del tap0 mode tap
--- net/bridge/br_netlink.c | 18 ++++++++++++ net/bridge/br_private.h | 1 + net/bridge/br_stp.c | 73 +++++++++++++++++++++++++++++++++++++++++++++---- net/bridge/br_stp_if.c | 3 +- 4 files changed, 88 insertions(+), 7 deletions(-)
net/bridge/br_netlink.c +18 -0
@@ -324,6 +324,21 @@ static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[], } } +static void br_kick_bridge_port (struct net_bridge_port *p) +{ +struct net_bridge *br = p->br; +bool wasroot; + + wasroot =br_is_root_bridge (br); +br_become_designated_port (p); + +br_configuration_update (br); +br_port_state_selection (br); + +if (br_is_root_bridge (br) && !wasroot) +br_become_root_bridge (br); +} +/* Process bridge protocol info on port */ static int br_setport (struct net_bridge_port *p,struct nlattr *tb[]) {
@@ -353,6 +368,9 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])if (err)return err; } + +br_kick_bridge_port (p); +return 0 ; }
net/bridge/br_private.h +1 -0
@@ -150,6 +150,7 @@ struct net_bridge_portu8 priority;u8 state;u16 port_no; +bool root_block_enabled;unsigned char topology_change_ack;unsigned char config_pending;port_id port_id;
net/bridge/br_stp.c +67 -6
101 lines not on this page · raw message
net/bridge/br_stp_if.c +2 -1
@@ -230,10 +230,11 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)return false;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ;if (addr == br_mac_zero ||memcmp (p->dev->dev_addr, addr,ETH_ALEN ) <0 ) addr = p->dev->dev_addr; - }if (ether_addr_equal (br->bridge_id.addr, addr))
Signature · 1 line
1.8.5.3
Re: [PATCH 3/3] bridge: fix bridge root block on designated port
net/bridge/br_private.h struct net_bridge_port · line 154
Quoted 8 lines · On Wed, 12 Mar 2014 20:15:27 -0700 "Luis R. Rodriguez"…
net/bridge/br_private.h +1
-0@@ -150,6 +150,7 @@ struct net_bridge_portu8 priority;u8 state;u16 port_no; +bool root_block_enabled;unsigned char topology_change_ack;
It seems a bit confusing to have both a ROOT_BLOCK flag in the data structure and and additional root_block_enabled flag. If nothing else it is a waste of space.
Looks like you are changing the meaning slightly. is possible to have BR_ROOT_BLOCK set but !root_block_enabled? and what about the inverse?
Re: [PATCH 3/3] bridge: fix bridge root block on designated port
Quoted 15 lines · Stephen Hemminger
net/bridge/br_private.h struct net_bridge_port · line 154
Quoted 8 lines · On Wed, 12 Mar 2014 20:15:27 -0700 "Luis R. Rodriguez"…
net/bridge/br_private.h +1
-0@@ -150,6 +150,7 @@ struct net_bridge_portu8 priority;u8 state;u16 port_no; +bool root_block_enabled;unsigned char topology_change_ack;It seems a bit confusing to have both a
ROOT_BLOCKflag in the data structure and and additionalroot_block_enabledflag. If nothing else it is a waste of space.
Indeed, however there is a use for it. Consider the case where we loop over each port and check to see if its root blocked and need to tickle it or the bridge. In the case that root port block was enabled before and someone is lifting it the flag would be removed and therefore not on but it was root blocked though and we need a way to keep track of that.
The flag then is a toggle for userspace, while the bool tells us about the current state.
Quoted 1 line
Looks like you are changing the meaning slightly.
Let me know in what way. I can't see it.
Quoted 1 line
is possible to have
BR_ROOT_BLOCKset but !root_block_enabled?
Yeah in the case a new request to set it to root block then BR_ROOT_BLOCK would be set but root_block_enabled would not be set.
Quoted 1 line
and what about the inverse?
BR_ROOT_BLOCK would not be set when userspace wants to disable root port block and root_block_enabled would be enabled in this case if it used to be enabled. So yes, both are possible.
Luis
Re: [PATCH 3/3] bridge: fix bridge root block on designated port
In reply to Stephen HemmingerQuoted 15 lines · Stephen Hemminger
net/bridge/br_private.h struct net_bridge_port · line 154
Quoted 8 lines · On Wed, 12 Mar 2014 20:15:27 -0700 "Luis R. Rodriguez"…
net/bridge/br_private.h +1
-0@@ -150,6 +150,7 @@ struct net_bridge_portu8 priority;u8 state;u16 port_no; +bool root_block_enabled;unsigned char topology_change_ack;It seems a bit confusing to have both a
ROOT_BLOCKflag in the data structure and and additionalroot_block_enabledflag. If nothing else it is a waste of space.
Indeed, however there is a use for it. Consider the case where we loop over each port and check to see if its root blocked and need to tickle it or the bridge. In the case that root port block was enabled before and someone is lifting it the flag would be removed and therefore not on but it was root blocked though and we need a way to keep track of that.
The flag then is a toggle for userspace, while the bool tells us about the current state.
Quoted 1 line
Looks like you are changing the meaning slightly.
Let me know in what way. I can't see it.
Quoted 1 line
is possible to have
BR_ROOT_BLOCKset but !root_block_enabled?
Yeah in the case a new request to set it to root block then BR_ROOT_BLOCK would be set but root_block_enabled would not be set.
Quoted 1 line
and what about the inverse?
BR_ROOT_BLOCK would not be set when userspace wants to disable root port block and root_block_enabled would be enabled in this case if it used to be enabled. So yes, both are possible.
Luis
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] bridge: fix bridge root block on designated port
In reply to Luis R. Rodrigueznet/bridge/br_private.h struct net_bridge_port · line 154
Quoted 8 lines · On Wed, 12 Mar 2014 20:15:27 -0700 "Luis R. Rodriguez"…
net/bridge/br_private.h +1
-0@@ -150,6 +150,7 @@ struct net_bridge_portu8 priority;u8 state;u16 port_no; +bool root_block_enabled;unsigned char topology_change_ack;
It seems a bit confusing to have both a ROOT_BLOCK flag in the data structure and and additional root_block_enabled flag. If nothing else it is a waste of space.
Looks like you are changing the meaning slightly. is possible to have BR_ROOT_BLOCK set but !root_block_enabled? and what about the inverse?
PATCH 3/3 bridge: fix bridge root block on designated port
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Root port blocking was designed so that a bridge port can opt out of becoming the designated root port for a bridge. If a port however first becomes the designated root port and we then toggle the root port block on it we currently don't kick that port out of the designated root port. This fixes that. This is particularly important for net_devices that would wish to never become a root port from the start, currently toggling that off will enable root port flag but it won't really kick the bridge and do what you'd expect, the MAC address is kept on the bridge of the toggled port for root_block if it was the designated port.
In order to catch if a port with root port block preference is set we need to move our check for root block prior to the root selection so check for root blocked ports upon eveyr br_configuration_update(). We also simply just prevent the root-blocked ports from consideration as root port candidates on br_should_become_root_port() and br_stp_recalculate_bridge_id().
The issue that this patch is trying to address and fix can be tested easily before and after this patch is applied using 2 TAP net_devices and then toggling at will with the root_block knob.
ip tuntap add dev tap0 mode tap
ip tuntap add dev tap1 mode tap
ip link add dev br0 type bridge
ip link show br0
echo -------------------------------------------
ip link set dev tap0 master br0
ip link
echo -------------------------------------------
ip link set dev tap1 master br0
ip link
echo -------------------------------------------
Upon review at the above results you can toggle root_block on each port to see if you see the results you expect.
bridge link set dev tap0 root_block on
ip link
bridge link set dev tap1 root_block on
ip link
Toggling off root_block on any port should will bring back the port to be a candidate for designated root port:
bridge link set dev tap1 root_block off
ip link
bridge link set dev tap0 root_block off
ip link
To nuke:
ip tuntap del tap0 mode tap
ip tuntap del tap0 mode tap
--- net/bridge/br_netlink.c | 18 ++++++++++++ net/bridge/br_private.h | 1 + net/bridge/br_stp.c | 73 +++++++++++++++++++++++++++++++++++++++++++++---- net/bridge/br_stp_if.c | 3 +- 4 files changed, 88 insertions(+), 7 deletions(-)
net/bridge/br_netlink.c +18 -0
@@ -324,6 +324,21 @@ static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[], } } +static void br_kick_bridge_port (struct net_bridge_port *p) +{ +struct net_bridge *br = p->br; +bool wasroot; + + wasroot =br_is_root_bridge (br); +br_become_designated_port (p); + +br_configuration_update (br); +br_port_state_selection (br); + +if (br_is_root_bridge (br) && !wasroot) +br_become_root_bridge (br); +} +/* Process bridge protocol info on port */ static int br_setport (struct net_bridge_port *p,struct nlattr *tb[]) {
@@ -353,6 +368,9 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])if (err)return err; } + +br_kick_bridge_port (p); +return 0 ; }
net/bridge/br_private.h +1 -0
@@ -150,6 +150,7 @@ struct net_bridge_portu8 priority;u8 state;u16 port_no; +bool root_block_enabled;unsigned char topology_change_ack;unsigned char config_pending;port_id port_id;
net/bridge/br_stp.c +67 -6
101 lines not on this page · raw message
net/bridge/br_stp_if.c +2 -1
@@ -230,10 +230,11 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)return false;list_for_each_entry (p, &br->port_list, list) { +if (p->flags &BR_ROOT_BLOCK ) +continue ;if (addr == br_mac_zero ||memcmp (p->dev->dev_addr, addr,ETH_ALEN ) <0 ) addr = p->dev->dev_addr; - }if (ether_addr_equal (br->bridge_id.addr, addr))
Signature · 1 line
1.8.5.3
Quoted 7 lines · Luis R. Rodriguez
Here's a few fixes I've been carrying around. I've now tested them on as many systems / environments as I can. They should be ready.
Luis R. Rodriguez (3):
bridge: preserve random init MAC address
bridge: trigger a bridge calculation upon port changes
bridge: fix bridge root block on designated port
Folks, let me know if there are any other questions or if you spot any other possible issues.
Luis
Quoted 7 lines · Luis R. Rodriguez
Here's a few fixes I've been carrying around. I've now tested them on as many systems / environments as I can. They should be ready.
Luis R. Rodriguez (3):
bridge: preserve random init MAC address
bridge: trigger a bridge calculation upon port changes
bridge: fix bridge root block on designated port
Folks, let me know if there are any other questions or if you spot any other possible issues.
Luis