WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] CA-47144: PIFs were not recreated correctly after pool

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-47144: PIFs were not recreated correctly after pool.eject
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Tue, 19 Oct 2010 17:31:31 +0100
Delivery-date: Tue, 19 Oct 2010 09:31:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
CA-47144: PIFs were not recreated correctly after pool.eject

Problems arose when the slave had a plugged bond, especially if management was 
on the bond, but only when the bridging backend is in use.

The linux bonding driver sets the MAC addresses of the bond interface, as well 
as the slave interfaces, all to same MAC when the bond is up. The "real" MAC 
adresses of the slaves can be found in /proc/net/bonding/<bond if>. This patch 
fixes the Netdev.get_address function to take this into account.

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r de0776a9ff18 netdev/netdev.ml
--- a/netdev/netdev.ml
+++ b/netdev/netdev.ml
@@ -354,7 +354,28 @@
 
 let getpath dev attr = Printf.sprintf "/sys/class/net/%s/%s" dev attr
 
-let get_address name = Internal.read_one_line (getpath name "address")
+let get_address name =
+       try
+               let master_path = Unix.readlink (getpath name "master") in
+               let master = List.hd (List.rev (String.split '/' master_path)) 
in
+               let proc ac line =
+                       try
+                               let a = String.index line ':' in
+                               let k = String.sub line 0 a in
+                               let v = String.sub_to_end line (a + 2) in
+                               if k = "Slave Interface" && v = name then
+                                       Some ""
+                               else if ac = Some "" && k = "Permanent HW addr" 
then
+                                       Some v
+                               else
+                                       ac
+                       with _ -> ac
+               in
+               match Unixext.file_lines_fold proc None ("/proc/net/bonding/" ^ 
master) with
+               | None -> raise Not_found
+               | Some address -> address
+       with _ -> 
+               Internal.read_one_line (getpath name "address")
 
 let get_mtu name = Internal.read_one_line (getpath name "mtu")
 let set_mtu name mtu =

Attachment: bond-slave-mac
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] CA-47144: PIFs were not recreated correctly after pool.eject, Rob Hoes <=