From: Stephen Hemminger <shemminger@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, xemul@sw.ru, devel@openvz.org,
bridge@lists.osdl.org
Subject: Re: [Bridge] [BRIDGE] Unaligned access on IA64 when comparing ethernet addresses
Date: Tue, 17 Apr 2007 13:37:23 -0700 [thread overview]
Message-ID: <20070417133723.00031f82@mini> (raw)
In-Reply-To: <20070417.130929.59470175.davem@davemloft.net>
The previous patch relied on the bridge id being aligned by
the compiler (which happens as a side effect). So please use
this instead.
compare_ether_addr() implicitly requires that the addresses
passed are 2-bytes aligned in memory.
This is not true for br_stp_change_bridge_id() and
br_stp_recalculate_bridge_id() in which one of the addresses
is unsigned char *, and thus may not be 2-bytes aligned.
Signed-off-by: Evgeny Kravtsunov <emkravts@openvz.org>
Signed-off-by: Kirill Korotaev <dev@openvz.org>
Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
--- linux-2.6.orig/net/bridge/br_stp_if.c 2007-04-16
20:03:04.000000000 -0700 +++ linux-2.6/net/bridge/br_stp_if.c
2007-04-17 13:25:52.000000000 -0700 @@ -126,23 +126,22 @@
/* called under bridge lock */
void br_stp_change_bridge_id(struct net_bridge *br, const unsigned
char *addr) {
- unsigned char oldaddr[6];
+ bridge_id old_id;
struct net_bridge_port *p;
int wasroot;
wasroot = br_is_root_bridge(br);
- memcpy(oldaddr, br->bridge_id.addr, ETH_ALEN);
+ old_id = br->bridge_id;
memcpy(br->bridge_id.addr, addr, ETH_ALEN);
memcpy(br->dev->dev_addr, addr, ETH_ALEN);
list_for_each_entry(p, &br->port_list, list) {
- if (!compare_ether_addr(p->designated_bridge.addr,
oldaddr))
+ if (!compare_ether_addr(p->designated_bridge.addr,
old_id.addr)) memcpy(p->designated_bridge.addr, addr, ETH_ALEN);
- if (!compare_ether_addr(p->designated_root.addr,
oldaddr))
+ if (!compare_ether_addr(p->designated_root.addr,
old_id.addr)) memcpy(p->designated_root.addr, addr, ETH_ALEN);
-
}
br_configuration_update(br);
@@ -151,19 +150,17 @@
br_become_root_bridge(br);
}
-static const unsigned char br_mac_zero[6];
-
/* called under bridge lock */
void br_stp_recalculate_bridge_id(struct net_bridge *br)
{
- const unsigned char *addr = br_mac_zero;
+ static const bridge_id id_zero;
+ const unsigned char *addr = id_zero.addr;
struct net_bridge_port *p;
list_for_each_entry(p, &br->port_list, list) {
- if (addr == br_mac_zero ||
+ if (addr == id_zero.addr ||
memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
addr = p->dev->dev_addr;
-
}
if (compare_ether_addr(br->bridge_id.addr, addr))
--- linux-2.6.orig/net/bridge/br_private.h 2007-04-17
13:26:48.000000000 -0700 +++ linux-2.6/net/bridge/br_private.h
2007-04-17 13:30:29.000000000 -0700 @@ -36,7 +36,7 @@
{
unsigned char prio[2];
unsigned char addr[6];
-};
+} __attribute__((aligned(8)));
struct mac_addr
{
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: David Miller <davem@davemloft.net>
Cc: xemul@sw.ru, netdev@vger.kernel.org, bridge@lists.osdl.org,
devel@openvz.org
Subject: Re: [BRIDGE] Unaligned access on IA64 when comparing ethernet addresses
Date: Tue, 17 Apr 2007 13:37:23 -0700 [thread overview]
Message-ID: <20070417133723.00031f82@mini> (raw)
In-Reply-To: <20070417.130929.59470175.davem@davemloft.net>
The previous patch relied on the bridge id being aligned by
the compiler (which happens as a side effect). So please use
this instead.
compare_ether_addr() implicitly requires that the addresses
passed are 2-bytes aligned in memory.
This is not true for br_stp_change_bridge_id() and
br_stp_recalculate_bridge_id() in which one of the addresses
is unsigned char *, and thus may not be 2-bytes aligned.
Signed-off-by: Evgeny Kravtsunov <emkravts@openvz.org>
Signed-off-by: Kirill Korotaev <dev@openvz.org>
Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
--- linux-2.6.orig/net/bridge/br_stp_if.c 2007-04-16
20:03:04.000000000 -0700 +++ linux-2.6/net/bridge/br_stp_if.c
2007-04-17 13:25:52.000000000 -0700 @@ -126,23 +126,22 @@
/* called under bridge lock */
void br_stp_change_bridge_id(struct net_bridge *br, const unsigned
char *addr) {
- unsigned char oldaddr[6];
+ bridge_id old_id;
struct net_bridge_port *p;
int wasroot;
wasroot = br_is_root_bridge(br);
- memcpy(oldaddr, br->bridge_id.addr, ETH_ALEN);
+ old_id = br->bridge_id;
memcpy(br->bridge_id.addr, addr, ETH_ALEN);
memcpy(br->dev->dev_addr, addr, ETH_ALEN);
list_for_each_entry(p, &br->port_list, list) {
- if (!compare_ether_addr(p->designated_bridge.addr,
oldaddr))
+ if (!compare_ether_addr(p->designated_bridge.addr,
old_id.addr)) memcpy(p->designated_bridge.addr, addr, ETH_ALEN);
- if (!compare_ether_addr(p->designated_root.addr,
oldaddr))
+ if (!compare_ether_addr(p->designated_root.addr,
old_id.addr)) memcpy(p->designated_root.addr, addr, ETH_ALEN);
-
}
br_configuration_update(br);
@@ -151,19 +150,17 @@
br_become_root_bridge(br);
}
-static const unsigned char br_mac_zero[6];
-
/* called under bridge lock */
void br_stp_recalculate_bridge_id(struct net_bridge *br)
{
- const unsigned char *addr = br_mac_zero;
+ static const bridge_id id_zero;
+ const unsigned char *addr = id_zero.addr;
struct net_bridge_port *p;
list_for_each_entry(p, &br->port_list, list) {
- if (addr == br_mac_zero ||
+ if (addr == id_zero.addr ||
memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
addr = p->dev->dev_addr;
-
}
if (compare_ether_addr(br->bridge_id.addr, addr))
--- linux-2.6.orig/net/bridge/br_private.h 2007-04-17
13:26:48.000000000 -0700 +++ linux-2.6/net/bridge/br_private.h
2007-04-17 13:30:29.000000000 -0700 @@ -36,7 +36,7 @@
{
unsigned char prio[2];
unsigned char addr[6];
-};
+} __attribute__((aligned(8)));
struct mac_addr
{
next prev parent reply other threads:[~2007-04-17 20:37 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-17 11:49 [Bridge] [BRIDGE] Unaligned access on IA64 when comparing ethernet addresses Pavel Emelianov
2007-04-17 11:49 ` Pavel Emelianov
2007-04-17 19:31 ` [Bridge] " David Miller
2007-04-17 19:31 ` David Miller
2007-04-17 19:55 ` [Bridge] " Stephen Hemminger
2007-04-17 19:55 ` Stephen Hemminger
2007-04-17 20:09 ` [Bridge] " David Miller
2007-04-17 20:09 ` David Miller
2007-04-17 20:37 ` Stephen Hemminger [this message]
2007-04-17 20:37 ` Stephen Hemminger
2007-04-17 21:09 ` [Bridge] " David Miller
2007-04-17 21:09 ` David Miller
2007-04-17 21:24 ` [Bridge] " Eric Dumazet
2007-04-17 21:24 ` Eric Dumazet
2007-04-17 21:27 ` [Bridge] " David Miller
2007-04-17 21:27 ` David Miller
2007-04-18 6:43 ` [Bridge] " Pavel Emelianov
2007-04-18 6:43 ` Pavel Emelianov
2007-04-18 8:28 ` [Bridge] " David Miller
2007-04-18 8:28 ` David Miller
2007-04-18 8:37 ` [Bridge] " Pavel Emelianov
2007-04-18 8:37 ` Pavel Emelianov
2007-04-18 14:44 ` [Bridge] " Stephen Hemminger
2007-04-18 14:44 ` Stephen Hemminger
2007-04-18 20:04 ` [Bridge] " David Miller
2007-04-18 20:04 ` David Miller
2007-04-19 14:14 ` Eric Dumazet
2007-04-19 14:14 ` Eric Dumazet
2007-04-19 18:18 ` Stephen Hemminger
2007-04-19 18:18 ` Stephen Hemminger
2007-04-19 20:01 ` [BRIDGE] " David Miller
2007-04-19 20:01 ` David Miller
2007-04-19 20:29 ` Eric Dumazet
2007-04-19 20:29 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070417133723.00031f82@mini \
--to=shemminger@linux-foundation.org \
--cc=bridge@lists.osdl.org \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=netdev@vger.kernel.org \
--cc=xemul@sw.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.