Skip to content

Sanitize LLDP text and tolerate malformed port IDs - #86

Draft
ashutosh-agrawal wants to merge 1 commit into
sonic-net:masterfrom
ashutosh-agrawal:codex/lldp-sanitize-and-port-id
Draft

ashutosh-agrawal wants to merge 1 commit into
sonic-net:masterfrom
ashutosh-agrawal:codex/lldp-sanitize-and-port-id

Conversation

@ashutosh-agrawal

@ashutosh-agrawal ashutosh-agrawal commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Harden LLDP synchronization against malformed remote text and port identifiers. Parse otherwise-valid lldpctl JSON containing raw control characters, strip C0/C1 controls recursively from keys and values before they reach Redis or logs, and keep unknown or malformed port-ID shapes from aborting the entire update.

Motivation

A malformed TLV should not disable LLDP synchronization for unrelated interfaces. The existing parser can also raise on an unknown or non-object port ID before its exception handler runs.

Changes

  • Sanitize parsed LLDP text at the subprocess-output boundary.
  • Preserve a usable port ID value when its subtype is unknown, while defaulting malformed fields safely.
  • Add regression cases for control characters and malformed port-ID shapes.

Testing

The Azure sonic-dbsyncd pipeline passed at PR head 2b0160df. Its Python 3 job runs python3 setup.py test and publishes test results and coverage. A separate local attempt to run tests/test_lldpSyncDaemon.py stopped during collection because mockredis was unavailable; no local pass is claimed.

Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
@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

/azp run

@azure-pipelines

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

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