aboutsummaryrefslogtreecommitdiff
path: root/datapath/brcompat.c
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2010-12-04 15:17:56 -0800
committerJesse Gross <jesse@nicira.com>2010-12-09 17:43:36 -0800
commit6d6266e6c9e387052e34f8434ee1d80690bff75d (patch)
tree897d417d256a4b60d1f635686561564cbade25be /datapath/brcompat.c
parent33b38b63e42c1f5aa80d1d7b4ce79cfbe371fae3 (diff)
brcompat: Simplify generation of bridge ID.
Currently we use a fairly complicated method of generating the bridge ID, since the actual struct is only available in a header file private to the Linux bridge. The current method appears to be correct but is difficult to reason about. This replaces it with a simple memcpy, which is more analogous to what the Linux bridge does. Flagged by sparse. Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath/brcompat.c')
-rw-r--r--datapath/brcompat.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/datapath/brcompat.c b/datapath/brcompat.c
index 2113eae0..f23db93c 100644
--- a/datapath/brcompat.c
+++ b/datapath/brcompat.c
@@ -224,14 +224,13 @@ static int brc_get_bridge_info(struct net_device *dev,
struct __bridge_info __user *ub)
{
struct __bridge_info b;
- u64 id = 0;
- int i;
memset(&b, 0, sizeof(struct __bridge_info));
- for (i=0; i<ETH_ALEN; i++)
- id |= (u64)dev->dev_addr[i] << (8*(ETH_ALEN-1 - i));
- b.bridge_id = cpu_to_be64(id);
+ /* First two bytes are the priority, which we should skip. This comes
+ * from struct bridge_id in br_private.h, which is unavailable to us.
+ */
+ memcpy((u8 *)&b.bridge_id + 2, dev->dev_addr, ETH_ALEN);
b.stp_enabled = 0;
if (copy_to_user(ub, &b, sizeof(struct __bridge_info)))