* [PATCH 12/21] bridge: slight optimization of addr compare
@ 2013-12-23 5:10 Ding Tianhong
2013-12-23 8:33 ` Toshiaki Makita
0 siblings, 1 reply; 3+ messages in thread
From: Ding Tianhong @ 2013-12-23 5:10 UTC (permalink / raw)
To: Stephen Hemminger, David S. Miller, bridge, Netdev,
linux-kernel@vger.kernel.org
Use the recently added and possibly more efficient
ether_addr_equal_unaligned to instead of memcmp.
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: David Miller <davem@davemloft.net>
Cc: bridge@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
net/bridge/br_stp_if.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 656a6f3..04217d1 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -229,7 +229,7 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)
list_for_each_entry(p, &br->port_list, list) {
if (addr == br_mac_zero ||
- memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
+ !ether_addr_equal_unaligned(p->dev->dev_addr, addr) < 0)
addr = p->dev->dev_addr;
}
--
1.8.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 12/21] bridge: slight optimization of addr compare
2013-12-23 5:10 [PATCH 12/21] bridge: slight optimization of addr compare Ding Tianhong
@ 2013-12-23 8:33 ` Toshiaki Makita
2013-12-23 8:38 ` Ding Tianhong
0 siblings, 1 reply; 3+ messages in thread
From: Toshiaki Makita @ 2013-12-23 8:33 UTC (permalink / raw)
To: Ding Tianhong
Cc: Stephen Hemminger, David S. Miller, bridge, Netdev,
linux-kernel@vger.kernel.org
On Mon, 2013-12-23 at 13:10 +0800, Ding Tianhong wrote:
> Use the recently added and possibly more efficient
> ether_addr_equal_unaligned to instead of memcmp.
>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: David Miller <davem@davemloft.net>
> Cc: bridge@lists.linux-foundation.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
> ---
> net/bridge/br_stp_if.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
> index 656a6f3..04217d1 100644
> --- a/net/bridge/br_stp_if.c
> +++ b/net/bridge/br_stp_if.c
> @@ -229,7 +229,7 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)
>
> list_for_each_entry(p, &br->port_list, list) {
> if (addr == br_mac_zero ||
> - memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
> + !ether_addr_equal_unaligned(p->dev->dev_addr, addr) < 0)
> addr = p->dev->dev_addr;
>
> }
We cannot do this change.
!ether_addr_equal() isn't identical to memcmp().
memcmp() can return negative value but ether_addr_equal() cannot.
br_stp_recalculate_bridge_id() is searching the smallest address among
its ports. This change breaks it.
Thanks,
Toshiaki Makita
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 12/21] bridge: slight optimization of addr compare
2013-12-23 8:33 ` Toshiaki Makita
@ 2013-12-23 8:38 ` Ding Tianhong
0 siblings, 0 replies; 3+ messages in thread
From: Ding Tianhong @ 2013-12-23 8:38 UTC (permalink / raw)
To: Toshiaki Makita
Cc: Stephen Hemminger, Netdev, bridge, David S. Miller,
linux-kernel@vger.kernel.org
On 2013/12/23 16:33, Toshiaki Makita wrote:
> On Mon, 2013-12-23 at 13:10 +0800, Ding Tianhong wrote:
>> Use the recently added and possibly more efficient
>> ether_addr_equal_unaligned to instead of memcmp.
>>
>> Cc: Stephen Hemminger <stephen@networkplumber.org>
>> Cc: David Miller <davem@davemloft.net>
>> Cc: bridge@lists.linux-foundation.org
>> Cc: netdev@vger.kernel.org
>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
>> ---
>> net/bridge/br_stp_if.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
>> index 656a6f3..04217d1 100644
>> --- a/net/bridge/br_stp_if.c
>> +++ b/net/bridge/br_stp_if.c
>> @@ -229,7 +229,7 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)
>>
>> list_for_each_entry(p, &br->port_list, list) {
>> if (addr == br_mac_zero ||
>> - memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
>> + !ether_addr_equal_unaligned(p->dev->dev_addr, addr) < 0)
>> addr = p->dev->dev_addr;
>>
>> }
>
> We cannot do this change.
> !ether_addr_equal() isn't identical to memcmp().
> memcmp() can return negative value but ether_addr_equal() cannot.
> br_stp_recalculate_bridge_id() is searching the smallest address among
> its ports. This change breaks it.
>
> Thanks,
> Toshiaki Makita
Yes, I miss it, the negative value is useful here, thanks for point out.
Regards
Ding
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-23 8:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-23 5:10 [PATCH 12/21] bridge: slight optimization of addr compare Ding Tianhong
2013-12-23 8:33 ` Toshiaki Makita
2013-12-23 8:38 ` Ding Tianhong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).