Skip to content

[BMC] Add LLDP management interface tests#23471

Open
Blueve wants to merge 3 commits intosonic-net:masterfrom
Blueve:dev/jika/bmc6
Open

[BMC] Add LLDP management interface tests#23471
Blueve wants to merge 3 commits intosonic-net:masterfrom
Blueve:dev/jika/bmc6

Conversation

@Blueve
Copy link
Copy Markdown
Collaborator

@Blueve Blueve commented Mar 31, 2026

Description of PR

Summary: Add LLDP management interface tests (tests/lldp/test_lldp_mgmt.py).

Lab management infrastructure does not forward LLDP multicast, so we use a veth pair with tc mirred ingress redirect to inject crafted LLDP frames directly into eth0's receive path and verify lldpd processes them correctly.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

LLDP test coverage for management interfaces. The existing tests/lldp/test_lldp.py depends on ASIC front-panel ports, DEVICE_NEIGHBOR config, and neighbor VMs. This PR adds LLDP tests that target eth0 (the management port), applicable to BMC (bmc) topologies. In future, we could extend the t0,t1 topology too.

How did you do it?

Added tests/lldp/test_lldp_mgmt.py with 4 test cases:

Test Purpose
test_lldp_mgmt_interface_enabled Verify eth0 is registered in lldpcli with active TX
test_lldp_tx_frame_on_mgmt Capture LLDP TX frames on eth0 via tcpdump
test_lldp_neighbor_on_mgmt Inject crafted LLDP via veth+tc mirred, verify mock neighbor in LLDP table
test_lldp_neighbor_timeout Verify neighbor removed after TTL expiry

Packet injection approach: A veth pair (veth_lldp_inj <-> veth_lldp_sink) with tc mirred ingress redirect delivers frames into eth0's receive path via netif_receive_skb().

This bypasses the Linux kernel's IEEE 802.1D reserved multicast filtering (which blocks LLDP's 01:80:c2:00:00:0e in bridge/macvlan code paths) because eth0 is not enslaved to any bridge, so br_handle_frame never runs.

 veth_lldp_inj --(veth pair)--> veth_lldp_sink
                                     | tc mirred ingress redirect
                                     v
                                   eth0 RX <-- lldpd listens here

LLDP frames are built from raw bytes using Python struct -- no scapy dependency on the DUT. Sent via socket.AF_PACKET raw sockets.

How did you verify/test it?

Ran on VS/KVM testbed with t0 topology.

Any platform specific information?

Works on any topology with an eth0 management interface and lldpd running.

Supported testbed topology if it's a new test case?

bmc

Documentation

Part of the BMC support series:

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Blueve Blueve changed the title [BMC] Add LLDP management interface tests for BMC topology [BMC] Add LLDP management interface tests Mar 31, 2026
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Add test_lldp_mgmt.py under tests/lldp/ with 4 test cases for LLDP
on the BMC management interface (eth0):
- test_lldp_mgmt_interface_enabled: verify eth0 registered in lldpd
- test_lldp_tx_frame_on_mgmt: capture LLDP TX frames via tcpdump
- test_lldp_neighbor_on_mgmt: inject crafted LLDP via macvlan,
  verify mock neighbor appears in LLDP table
- test_lldp_neighbor_timeout: verify neighbor removed after TTL

Uses macvlan bridge mode to inject LLDP frames into eth0 receive
path since lab management infra does not forward LLDP multicast.
No scapy dependency on DUT - uses Python raw sockets.

Signed-off-by: Jing Kan <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Jing Kan <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Macvlan cannot deliver LLDP frames (IEEE 802.1D reserved multicast
01:80:c2:00:00:0e) from macvlan to parent interface - the Linux
kernel filters these at L2 in both bridge and macvlan code paths.

Use veth pair + tc mirred ingress redirect instead:
- Create veth_lldp_inj <-> veth_lldp_sink pair
- tc filter on veth_lldp_sink redirects ingress to eth0 RX path
- Bypasses IEEE 802.1D filtering since eth0 is not bridged
- tc mirred injects via netif_receive_skb() directly

Also removes debug logging from test_lldp_neighbor_on_mgmt that
was added during macvlan troubleshooting.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Jing Kan <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Only keep bmc topology marker since we cannot verify on t0
physical testbed.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Jing Kan <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Blueve Blueve marked this pull request as ready for review April 3, 2026 03:43
@Blueve Blueve closed this Apr 3, 2026
@Blueve Blueve reopened this Apr 3, 2026
@mssonicbld
Copy link
Copy Markdown
Collaborator

/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.

3 participants