Skip to content

Commit b931c52

Browse files
committed
CA-414651 Fix device rename in PIF after RPU
After RPU from legacy network device name, the name in PIF object should be updated. The new network device name is in interface_tables.device_to_position_table. The position of old device name in PIF object can be get by its associated bridge and then correspond with the new name. In this procedure, a exsiting bridge is used to get the position. However, the bridge is used to update MTU. It is specially handled when the device is under a bond. The bridge is actually the parent bond bridge. This leads to no position is found for old device name and then device name is not updated correctly. Fix: use the associated bridge to find the position. Signed-off-by: Changlei Li <changlei.li@cloud.com>
1 parent 4f47090 commit b931c52

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ocaml/xapi/xapi_pif.ml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ let bridge_naming_convention (device : string) (pos_opt : int option) =
4848
let n_of_xenbrn_opt bridge =
4949
try Scanf.sscanf bridge "xenbr%d%!" Option.some with _ -> None
5050

51+
let get_pif_position ~__context pif =
52+
if pif.API.pIF_physical then
53+
let bridge = Db.Network.get_bridge ~__context ~self:pif.API.pIF_network in
54+
n_of_xenbrn_opt bridge
55+
else
56+
None
57+
5158
type tables = {
5259
device_to_position_table: (string * int) list
5360
; device_to_mac_table: (string * string) list
@@ -133,15 +140,12 @@ let refresh_internal ~__context ~interface_tables ~self =
133140
(* Pif device name maybe change. Look up device_to_position table to get the
134141
new device name. *)
135142
let pif_device_name =
136-
if pif.API.pIF_physical then (
137-
match n_of_xenbrn_opt bridge with
138-
| Some position ->
139-
find_name_by_position position pif.API.pIF_device
140-
| None ->
141-
info "PIF %s: no position found for this device" pif.API.pIF_device ;
142-
pif.API.pIF_device
143-
) else
144-
pif.API.pIF_device
143+
match get_pif_position ~__context pif with
144+
| Some position ->
145+
find_name_by_position position pif.API.pIF_device
146+
| None ->
147+
info "PIF %s: no position found for this device" pif.API.pIF_device ;
148+
pif.API.pIF_device
145149
in
146150
(* Update the specified PIF field in the database, if
147151
* and only if a corresponding value can be read from

0 commit comments

Comments
 (0)