# HG changeset patch # User Rob Hoes 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/. This patch fixes the Netdev.get_address function to take this into account. Signed-off-by: Rob Hoes 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 =