Skip to content

CP-312082 Implement APIs for configuration of lldp - #7200

Open
changlei-li wants to merge 6 commits into
xapi-project:feature/lldpfrom
changlei-li:private/changleli/lldp-apis
Open

CP-312082 Implement APIs for configuration of lldp#7200
changlei-li wants to merge 6 commits into
xapi-project:feature/lldpfrom
changlei-li:private/changleli/lldp-apis

Conversation

@changlei-li

@changlei-li changlei-li commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Design doc: https://github.com/xapi-project/xen-api/blob/master/doc/content/design/lldp.md

New fileds:
pool.lldp_enabled
pool.lldp_multicast_address (RW)
pif.lldp_mode

APIs:
pool.set_lldp_enabled
PIF.set_lldp_mode

CLI:
xe pool-set-lldp-enabled
xe pif-set-lldp-mode

Add the XAPI database fields and enums for the LLDP feature:

- pool.lldp_enabled (bool, DynamicRO): pool-wide LLDP toggle. Fresh-install
  default is true (set in create_pool_record); the datamodel default_value is
  false, which is the value applied on update/RPU from a release without LLDP.
- pool.lldp_multicast_address (enum lldp_multicast_address, RW): the multicast
  MAC address group used for LLDP advertising.
- PIF.lldp_mode (enum pif_lldp_mode, DynamicRO): per-PIF override of the
  pool-wide setting (default | enabled | disabled).

All existing Db.PIF.create and Db.Pool.create call sites are updated to pass
the new fields.

Signed-off-by: Changlei Li <changlei.li@citrix.com>
@changlei-li
changlei-li marked this pull request as draft July 30, 2026 05:32
Add the XenAPI messages and their implementations, forwarding and CLI:

- pool.set_lldp_enabled (self, value, force): sets pool.lldp_enabled and,
  for every managed physical PIF, re-applies the LLDP configuration via
  PIF.plug, returning a map of PIFs that failed and their error message.
  When force is false and value already matches the current setting it is
  a no-op returning an empty map.
- PIF.set_lldp_mode (self, value, force): sets PIF.lldp_mode on a managed
  physical PIF and re-applies via PIF.plug. Non-physical PIFs are rejected
  with PIF_IS_NOT_PHYSICAL.

For bond members, applies lldp config via pluging their bond master PIF.

CLI: 'xe pool-set-lldp-enabled', 'xe pif-set-lldp-mode', and read-only
param-list fields lldp-enabled, lldp-multicast-address (settable via
pool-param-set) and lldp-mode.

Signed-off-by: Changlei Li <changlei.li@citrix.com>
When bringing up the NIC of a managed physical PIF, build the networkd LLDP
record from the XAPI database and include it in the interface configuration
passed to networkd, replacing the previous hard-coded 'lldp = None'.

The effective state resolves the configuration matrix: PIF.lldp_mode of
enabled/disabled overrides pool.lldp_enabled, and 'enabled' additionally sets
'force' so networkd overrides its NIC-driver blocklist. The chassis id, system
name and description are taken from the host, and the multicast address from
pool.lldp_multicast_address.

Signed-off-by: Changlei Li <changlei.li@citrix.com>
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>
@changlei-li
changlei-li force-pushed the private/changleli/lldp-apis branch from 8523153 to 820ffbd Compare July 30, 2026 05:42
'default' is a reserved keyword in C#, which breaks the generated SDK.
Rename the pif_lldp_mode enum value to 'inherited' (it means the PIF
follows pool.lldp_enabled) and update the field default, descriptions,
CLI help accordingly.

Signed-off-by: Changlei Li <changlei.li@citrix.com>
Signed-off-by: Changlei Li <changlei.li@citrix.com>
@changlei-li
changlei-li force-pushed the private/changleli/lldp-apis branch from 820ffbd to af088e5 Compare July 30, 2026 06:25
@changlei-li

changlei-li commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Self test:

  1. XAPI update:
# xe pool-list params=lldp-enabled,lldp-multicast-address
lldp-enabled ( RO)              : false
    lldp-multicast-address ( RW): nearestbridge

# xe pif-list params=device,lldp-mode
device ( RO)       : eno12399np0
    lldp-mode ( RO): inherited

device ( RO)       : eno8303
    lldp-mode ( RO): inherited

device ( RO)       : eno12409np1
    lldp-mode ( RO): inherited

device ( RO)       : bond0
    lldp-mode ( RO): inherited

# lldpcli show neighbors
2026-07-30T07:24:11 [WARN/control] unable to connect to socket /run/lldpd/lldpd.socket: No such file or directory
# systemctl status lldpd
○ lldpd.service - LLDP daemon
     Loaded: loaded (/usr/lib/systemd/system/lldpd.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf, 50-keep-warm.conf
     Active: inactive (dead)
       Docs: man:lldpd(8)
  1. pool enable lldp
# xe pool-set-lldp-enabled value=true

# systemctl status lldpd
● lldpd.service - LLDP daemon
     Loaded: loaded (/usr/lib/systemd/system/lldpd.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf, 50-keep-warm.conf
     Active: active (running) since Thu 2026-07-30 07:31:31 UTC; 4s ago
...

# lldpcli show interfaces
-------------------------------------------------------------------------------
LLDP interfaces:
-------------------------------------------------------------------------------
Interface:    eno12399np0
  Administrative status: RX and TX
  ...
-------------------------------------------------------------------------------
Interface:    eno12409np1
  Administrative status: RX and TX
  ...
-------------------------------------------------------------------------------
Interface:    eno8303
  Administrative status: RX and TX
  ...
-------------------------------------------------------------------------------
Interface:    ovs-system
  Administrative status: disabled
  ...
-------------------------------------------------------------------------------
Interface:    xenbr2
  Administrative status: disabled
  ...
-------------------------------------------------------------------------------
Interface:    xapi1
  Administrative status: disabled
  ...

  1. set pif lldp-mode, override pool setting
# xe pif-set-lldp-mode uuid=45fd1556-ac44-2b31-a4a9-e3b1608e6dd3 value=disabled

# xe pif-list params=device,lldp-mode
device ( RO)       : eno12399np0
    lldp-mode ( RO): disabled

device ( RO)       : eno8303
    lldp-mode ( RO): inherited

device ( RO)       : eno12409np1
    lldp-mode ( RO): inherited

device ( RO)       : bond0
    lldp-mode ( RO): inherited

# lldpcli show interface
-------------------------------------------------------------------------------
LLDP interfaces:
-------------------------------------------------------------------------------
Interface:    eno12399np0
  Administrative status: disabled
...
-------------------------------------------------------------------------------
Interface:    eno12409np1
  Administrative status: RX and TX
...
-------------------------------------------------------------------------------
Interface:    eno8303
  Administrative status: RX and TX
...
  1. change lldp-multicast-address and force pool lldp enable
# lldpcli show configuration | grep  'Agent type'
  Agent type:   nearest bridge

# xe pool-param-set uuid=3f47a5e7-bd3b-3d25-edf6-2ed029f558df  lldp-multicast-address=nearestcustomerbridge

# xe pool-set-lldp-enabled value=true

# lldpcli show configuration | grep  'Agent type'
  Agent type:   nearest bridge
# xe pool-set-lldp-enabled value=true force=true

# lldpcli show configuration | grep  'Agent type'
  Agent type:   nearest customer bridge
  1. Try to change non-physical PIF
# xe pif-set-lldp-mode uuid=b1142cde-e083-0be2-93f8-e7b10b13cb8e value=disabled
You tried to perform an operation which is only available on physical PIF
PIF: b1142cde-e083-0be2-93f8-e7b10b13cb8e

@changlei-li
changlei-li marked this pull request as ready for review July 30, 2026 07:50
@changlei-li
changlei-li requested a review from minglumlu July 30, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant