Skip to content

[dhcpmon] Track physical members beneath VLAN PortChannels - #99

Open
Xichen96 wants to merge 2 commits into
sonic-net:masterfrom
Xichen96:dev/xichenlin/nested-portchannel-hierarchy
Open

[dhcpmon] Track physical members beneath VLAN PortChannels#99
Xichen96 wants to merge 2 commits into
sonic-net:masterfrom
Xichen96:dev/xichenlin/nested-portchannel-hierarchy

Conversation

@Xichen96

@Xichen96 Xichen96 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description of PR

Track a physical member through its VLAN-backed PortChannel:

Ethernet312 -> PortChannel1005 -> Vlan1000

The current implementation records PortChannel1005 -> Vlan1000, but skips
the physical-member relation when the PortChannel is not itself a command-line
context interface.

Work item tracking
  • Microsoft ADO (number only): 38615656

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation update
  • Test improvement

Approach

What is the motivation for this PR?

Fungible F2 places PortChannels beneath the downstream VLAN. During LACP
convergence the kernel can deliver the packet on a bare physical member, which
must still resolve to the monitored VLAN context.

How did you do it?

  • Keep VLAN and PortChannel membership maps from CONFIG_DB.
  • Resolve physical member -> PortChannel -> VLAN recursively.
  • Increment only the immediate-parent aggregate at each observation point.
  • Preserve direct VLAN-member and DualToR behavior.
  • Ignore accidental self-referential mappings.

Immediate-parent aggregation is intentional: rolling a pre-VLAN physical or
PortChannel observation all the way into the root VLAN aggregate would recreate
the false relay-disparity signal from the F2 RCA.

How did you verify/test it?

Azure PR CI will validate the restacked head on amd64, arm64, and armhf. No
local compilation is used. Prior regular and F2 hardware validation covered
steady state, bare-member convergence, and PortChannel recreation with a
changed ifindex.

Any platform specific information?

No.

Back port request

None. This targets master only.

Tested branch

master

Test result

Direct and PortChannel-backed VLAN traffic counted correctly. Member, VLAN
membership, and full PortChannel recreation were handled with an unchanged
dhcpmon PID; the recreated PortChannel ifindex changed from 1004 to 1005.

Documentation

Not applicable.

Stack

Depends on #96. Review the final commit only:

1331563 [dhcpmon]: Track physical members beneath VLAN PortChannels

Copilot AI review requested due to automatic review settings July 26, 2026 06:40
@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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates sonic-dhcpmon’s interface relationship tracking so packets observed on a physical PortChannel member can be attributed through a nested hierarchy (e.g., Ethernet312 -> PortChannel1005 -> Vlan1000), enabling correct downstream VLAN-context monitoring during LACP convergence and PortChannel recreation scenarios.

Changes:

  • Extend device-context resolution to follow PortChannel membership recursively before VLAN membership.
  • Introduce “immediate parent” attribution helpers (dhcp_devman_get_parent_ifname, dhcp_devman_get_agg_counter_ifname) and migrate aggregate counter updates to use them.
  • Adjust PortChannel member mapping rules to allow nested PortChannels under monitored VLANs (with Dual-ToR caveats).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/util.h Removes the old context-parameter aggregate counter helper (now handled by devman).
src/packet_handler.cpp Switches per-packet aggregate counting to immediate-parent attribution; fixes a comment typo.
src/dhcp_mon.cpp Switches aggregate counter recalculation to immediate-parent attribution.
src/dhcp_devman.h Adds new APIs for parent resolution and aggregate counter naming.
src/dhcp_devman.cpp Implements recursive context resolution and the new immediate-parent attribution helpers; updates PortChannel mapping rules.

Comment thread src/dhcp_devman.cpp Outdated
Comment thread src/dhcp_devman.cpp Outdated
Copilot AI review requested due to automatic review settings July 26, 2026 07:26
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@Xichen96 Xichen96 changed the title [dhcpmon] Track nested PortChannel hierarchy [dhcpmon] Track physical members beneath VLAN PortChannels Jul 27, 2026
Copilot AI review requested due to automatic review settings July 27, 2026 03:26
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 27, 2026 03:30
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/dhcp_devman.h
Comment thread src/dhcp_devman.h Outdated
Copilot AI review requested due to automatic review settings July 27, 2026 03:57
@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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 28, 2026 02:08
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 28, 2026 05:58
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/dhcp_devman.cpp:240

  • Self-referential PORTCHANNEL_MEMBER entries (e.g., PORTCHANNEL_MEMBER|PortChannelX|PortChannelX) are still inserted into portchan_map/rev_portchan_map. While dhcp_devman_get_parent_ifname() ignores direct self-maps, keeping the self-member in rev_portchan_map can skew rev_portchan_map[portchan].size() and break the AGG_* ratio health checks (and may also create unnecessary counters). Since the PR description explicitly calls out ignoring accidental self-referential mappings, it’s safer to skip these keys here before inserting into the maps.
        auto portchannel = key.substr(first + 1, second - first - 1);
        auto ifname = key.substr(second + 1);
        bool portchannel_is_context = intfs.find(portchannel) != intfs.end();
        bool portchannel_is_vlan_member = vlan_map.find(portchannel) != vlan_map.end();
        // Dual-ToR downlink counters require MUX attribution that is unavailable on a nested PortChannel.

@Xichen96
Xichen96 force-pushed the dev/xichenlin/nested-portchannel-hierarchy branch from 1659bef to 3128da1 Compare July 31, 2026 17:57
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@Xichen96
Xichen96 marked this pull request as ready for review July 31, 2026 17:58
Copilot AI review requested due to automatic review settings July 31, 2026 17:58
@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Xichen96 and others added 2 commits August 1, 2026 05:01
Bound each raw-socket callback to 64 packets and reset the recvfrom address length for every receive attempt.

Rename three file-scope helpers that begin with underscores because C++ reserves those identifiers in the global namespace; static linkage already marks them as internal. Replace four nullptr comparisons with NULL to match the daemon's established style.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 39f979be-d826-4d5c-949a-f20abb58bb83

Signed-off-by: Xichen96 <lukelin0907@gmail.com>
Preserve VLAN and PortChannel membership so a physical member resolves through its immediate PortChannel parent to the monitored VLAN context. Keep direct VLAN-member precedence, bound hierarchy traversal, ignore self-references, and centralize parent, context, and aggregate-name lookup.

Aggregate only to the immediate parent so pre-VLAN observations are not rolled into the root VLAN counter and misreported as relay loss.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 39f979be-d826-4d5c-949a-f20abb58bb83
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
@Xichen96
Xichen96 force-pushed the dev/xichenlin/nested-portchannel-hierarchy branch from 3128da1 to 1331563 Compare July 31, 2026 19:20
Copilot AI review requested due to automatic review settings July 31, 2026 19:20
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

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