Skip to content

[lldp]: Fix remote management address cache updates - #386

Open
lrt950 wants to merge 1 commit into
sonic-net:masterfrom
lrt950:agent/fix-lldp-rem-man-addr-cache
Open

[lldp]: Fix remote management address cache updates#386
lrt950 wants to merge 1 commit into
sonic-net:masterfrom
lrt950:agent/fix-lldp-rem-man-addr-cache

Conversation

@lrt950

@lrt950 lrt950 commented Jul 29, 2026

Copy link
Copy Markdown

- What I did

  • Fixed stale and duplicate lldpRemManAddrTable cache entries after LLDP neighbor updates.
  • Preserved all valid IPv4 and IPv6 management addresses advertised by the same neighbor.
  • Removed stale entries when the Redis row is deleted, missing, empty, malformed, or belongs to an interface outside the exported MIB interface map.
  • Added focused unit coverage for refresh, delete, malformed data, interface filtering, and multi-address behavior.

- How I did it

LLDPRemManAddrUpdater previously appended every SET result to if_range, so repeated updates accumulated duplicate rows and changes to the time mark or management address left old rows visible. The DEL path also compared if_index with sub_oid[0], but index position 0 is the LLDP time mark; the interface index is at position 1.

The updater now builds the complete new row set for one interface first, then replaces all cached rows for that interface in one assignment. SET and DEL notifications both refresh from the current DB state, which also handles delete/recreate races without duplicating cache invalidation logic.

- How to verify it

  • python3 -m pytest tests/test_lldp.py -q
  • python3 -m compileall -q src tests/test_lldp.py
  • git diff --check

The local LLDP test run completed with 22 passed, 3 subtests passed. The five new cache tests cover eight scenarios, including repeated SET, changed values, multiple IPv4/IPv6 addresses, DEL, empty/invalid/incomplete data, preservation of unrelated interfaces, and non-exported interfaces.

- Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605

Tracking issue/work item for backport/cherry-pick request: N/A
Failure type: day-one issue

- Tested branch

  • master
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605
  • N/A

- Test result

  • master: tests/test_lldp.py — 22 passed, 3 subtests passed

- Description for the changelog

Fix stale and duplicate LLDP remote management address MIB cache entries after neighbor updates.

Signed-off-by: lrt950 <37255967+lrt950@users.noreply.github.com>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 29, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: lrt950 / name: lrt950 (505dcbd)

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@lrt950
lrt950 marked this pull request as ready for review July 29, 2026 09:02
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks!

---Powered by SONiC BuildBot

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.

2 participants