Skip to content

Commit 55ad492

Browse files
committed
CP-312082: [xapi] Only re-plug attached PIFs when applying LLDP
Apply the LLDP change to networkd only for PIFs that are currently attached; an unplugged PIF has its DB value updated and picks up the setting the next time it is brought up. This avoids bringing up interfaces that were deliberately down as a side effect of a pure LLDP configuration change. PIF.set_lldp_mode re-plugs the target (self, or the bond master for a bond member) only if it is currently_attached; pool.set_lldp_enabled re-plugs only currently-attached standalone physical PIFs and bond masters. Signed-off-by: Changlei Li <changlei.li@citrix.com>
1 parent e991c65 commit 55ad492

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

ocaml/xapi/xapi_pif.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,10 +990,13 @@ let set_lldp_mode ~__context ~self ~value ~force =
990990
assert_lldp_configurable ~__context ~self ;
991991
if force || Db.PIF.get_lldp_mode ~__context ~self <> value then (
992992
Db.PIF.set_lldp_mode ~__context ~self ~value ;
993+
(* Re-apply to networkd only if the NIC is up; an unplugged PIF will pick
994+
up the new setting the next time it is brought up. *)
993995
let to_plug = pif_to_plug_for_lldp ~__context ~self in
994-
Helpers.call_api_functions ~__context (fun rpc session_id ->
995-
Client.Client.PIF.plug ~rpc ~session_id ~self:to_plug
996-
)
996+
if Db.PIF.get_currently_attached ~__context ~self:to_plug then
997+
Helpers.call_api_functions ~__context (fun rpc session_id ->
998+
Client.Client.PIF.plug ~rpc ~session_id ~self:to_plug
999+
)
9971000
)
9981001

9991002
let set_property ~__context ~self ~name ~value =

ocaml/xapi/xapi_pool.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3862,11 +3862,13 @@ let set_lldp_enabled ~__context ~self ~value ~force =
38623862
Db.Pool.set_lldp_enabled ~__context ~self ~value ;
38633863
(* LLDP runs on physical NICs. Standalone physical PIFs are plugged
38643864
directly; bonded NICs are (re)configured by plugging the bond master.
3865-
Both apply the per-PIF PIF.lldp_mode against the new pool setting. *)
3865+
Only currently-attached PIFs are re-plugged; an unplugged PIF will pick
3866+
up the new pool setting the next time it is brought up. *)
38663867
let pifs =
38673868
Db.PIF.get_all_records ~__context
38683869
|> List.filter (fun (_, r) ->
38693870
r.API.pIF_managed
3871+
&& r.API.pIF_currently_attached
38703872
&& (r.API.pIF_physical && r.API.pIF_bond_slave_of = Ref.null
38713873
|| r.API.pIF_bond_master_of <> []
38723874
)

0 commit comments

Comments
 (0)