2005-12-21 19:56:44

by Mika Kukkonen

[permalink] [raw]
Subject: [PATCH] BRIDGE: Fix faulty check in br_stp_recalculate_bridge_id()

I did a compile with extra gcc warnings, and found a bug in
net/bridge/br_stp_if.c function br_stp_recalculate_bridge_id():
compare_ether_addr() returns 0 if match, positive if not, so
checking it for negative is wrong.

Signed-of-by: Mika Kukkonen <[email protected]>

---

net/bridge/br_stp_if.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index ac09b6a..08c52c2 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -158,7 +158,7 @@ void br_stp_recalculate_bridge_id(struct

list_for_each_entry(p, &br->port_list, list) {
if (addr == br_mac_zero ||
- compare_ether_addr(p->dev->dev_addr, addr) < 0)
+ compare_ether_addr(p->dev->dev_addr, addr))
addr = p->dev->dev_addr;

}


2005-12-21 21:25:48

by Stephen Hemminger

[permalink] [raw]
Subject: Re: [PATCH] BRIDGE: Fix faulty check in br_stp_recalculate_bridge_id()

On Wed, 21 Dec 2005 21:55:27 +0200
[email protected] wrote:

> I did a compile with extra gcc warnings, and found a bug in
> net/bridge/br_stp_if.c function br_stp_recalculate_bridge_id():
> compare_ether_addr() returns 0 if match, positive if not, so
> checking it for negative is wrong.
>
> Signed-of-by: Mika Kukkonen <[email protected]>
>
> ---
>
> net/bridge/br_stp_if.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> index ac09b6a..08c52c2 100644
> --- a/net/bridge/br_stp_if.c
> +++ b/net/bridge/br_stp_if.c
> @@ -158,7 +158,7 @@ void br_stp_recalculate_bridge_id(struct
>
> list_for_each_entry(p, &br->port_list, list) {
> if (addr == br_mac_zero ||
> - compare_ether_addr(p->dev->dev_addr, addr) < 0)
> + compare_ether_addr(p->dev->dev_addr, addr))
> addr = p->dev->dev_addr;
>
> }

Actually that compare_ether_addr needs to be replaced by memcmp again.
Because for bridge id calc it wants the min() of all the device addresses.

--
Stephen Hemminger <[email protected]>
OSDL http://developer.osdl.org/~shemminger

2005-12-22 03:51:07

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] BRIDGE: Fix faulty check in br_stp_recalculate_bridge_id()

From: Stephen Hemminger <[email protected]>
Date: Wed, 21 Dec 2005 13:25:27 -0800

> On Wed, 21 Dec 2005 21:55:27 +0200
> [email protected] wrote:
>
> > I did a compile with extra gcc warnings, and found a bug in
> > net/bridge/br_stp_if.c function br_stp_recalculate_bridge_id():
> > compare_ether_addr() returns 0 if match, positive if not, so
> > checking it for negative is wrong.
> >
> > Signed-of-by: Mika Kukkonen <[email protected]>
...
> > diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> > index ac09b6a..08c52c2 100644
> > --- a/net/bridge/br_stp_if.c
> > +++ b/net/bridge/br_stp_if.c
> > @@ -158,7 +158,7 @@ void br_stp_recalculate_bridge_id(struct
> >
> > list_for_each_entry(p, &br->port_list, list) {
> > if (addr == br_mac_zero ||
> > - compare_ether_addr(p->dev->dev_addr, addr) < 0)
> > + compare_ether_addr(p->dev->dev_addr, addr))
> > addr = p->dev->dev_addr;
> >
> > }
>
> Actually that compare_ether_addr needs to be replaced by memcmp again.
> Because for bridge id calc it wants the min() of all the device addresses.

I'll hold on this patch until that is worked out.

Thanks.

2006-01-03 18:42:13

by Stephen Hemminger

[permalink] [raw]
Subject: [PATCH] BRIDGE: Fix faulty check in br_stp_recalculate_bridge_id()

One of the conversions from memcmp to compare_ether_addr is incorrect.
We need to do relative comparison to determine min MAC address to
use in bridge id.

Signed-off-by: Stephen Hemminger <[email protected]>

--- linux-2.6.15.orig/net/bridge/br_stp_if.c
+++ linux-2.6.15/net/bridge/br_stp_if.c
@@ -158,7 +158,7 @@ void br_stp_recalculate_bridge_id(struct

list_for_each_entry(p, &br->port_list, list) {
if (addr == br_mac_zero ||
- compare_ether_addr(p->dev->dev_addr, addr) < 0)
+ memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
addr = p->dev->dev_addr;

}

2006-01-03 22:36:48

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] BRIDGE: Fix faulty check in br_stp_recalculate_bridge_id()

From: Stephen Hemminger <[email protected]>
Date: Tue, 3 Jan 2006 10:41:57 -0800

> One of the conversions from memcmp to compare_ether_addr is incorrect.
> We need to do relative comparison to determine min MAC address to
> use in bridge id.
>
> Signed-off-by: Stephen Hemminger <[email protected]>

Applied, thanks.

Is this -stable material?