From 4507488b0f372ec1bec599453b3feedc96290e52 Mon Sep 17 00:00:00 2001 From: Zhaohui Sun Date: Mon, 27 Apr 2026 04:35:53 +0000 Subject: [PATCH] [lldp] Replace per-port portidsubtype loop with global ifname directive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the per-port portidsubtype configuration loop in lldpd.conf.j2 with a single global `configure lldp portidsubtype ifname` directive. The per-port loop was added to prevent MAC-based Port IDs on the first LLDP frame, but it causes startup delays proportional to port count (e.g., 20+ seconds on 512-port systems). The global ifname directive achieves the same goal — lldpd uses interface names as Port IDs from the start — while lldpmgrd subsequently sets the correct alias per port. Cherry-pick of https://github.com/sonic-net/sonic-buildimage/pull/26873 for the 202412 branch. Signed-off-by: Zhaohui Sun --- dockers/docker-lldp/lldpd.conf.j2 | 21 ++----------------- .../py3/lldp_conf/lldpd-ipv4-iface.conf | 1 + .../py3/lldp_conf/lldpd-ipv6-iface.conf | 1 + 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/dockers/docker-lldp/lldpd.conf.j2 b/dockers/docker-lldp/lldpd.conf.j2 index 82c3dfa564..a7e5b68fe3 100644 --- a/dockers/docker-lldp/lldpd.conf.j2 +++ b/dockers/docker-lldp/lldpd.conf.j2 @@ -19,24 +19,7 @@ configure ports eth0 lldp portidsubtype local {{ mgmt_if.port_name }} configure system ip management pattern {{ mgmt_if.ipv4 }} {% endif %} configure system hostname {{ DEVICE_METADATA['localhost']['hostname'] }} -{# Configure port ID subtype for front-panel ports at startup. - Without this, lldpd uses MAC address as default Port ID. When lldpd - auto-resumes after config processing, the first LLDP frame would carry - MAC-based Port IDs. Peers see a transient MSAP change when lldpmgrd - later reconfigures portidsubtype, causing unnecessary neighbor flaps. - Special ports (inband/recirculation/backplane) are excluded to match - lldpmgrd behavior which skips these port types. #} -{% if PORT %} -{% for port_name in PORT|sort %} -{% if not port_name.startswith('Ethernet-IB') and not port_name.startswith('Ethernet-Rec') and not port_name.startswith('Ethernet-BP') %} -{% set port_alias = PORT[port_name].alias|default('') %} -{% if port_alias %} -configure ports {{ port_name }} lldp portidsubtype local {{ port_alias }} -{% else %} -configure ports {{ port_name }} lldp portidsubtype local {{ port_name }} -{% endif %} -{% endif %} -{% endfor %} -{% endif %} +{# Use ifname globally to avoid MAC-as-Port-ID; lldpmgrd sets alias per port later. #} +configure lldp portidsubtype ifname {# pause lldpd operations until all interfaces are well configured, resume command will run in lldpmgrd #} pause diff --git a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf index c9cb2c8123..684791a0f2 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv4-iface.conf @@ -1,4 +1,5 @@ configure ports eth0 lldp portidsubtype local eth0 configure system ip management pattern 10.0.0.100 configure system hostname switch-t0 +configure lldp portidsubtype ifname pause diff --git a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf index f5727556fd..3f7ec2ee5e 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/lldp_conf/lldpd-ipv6-iface.conf @@ -1,2 +1,3 @@ configure system hostname switch-t0 +configure lldp portidsubtype ifname pause