[dhcpmon] Track physical members beneath VLAN PortChannels - #99
Open
Xichen96 wants to merge 2 commits into
Open
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Jul 26, 2026
There was a problem hiding this comment.
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. |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
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 skewrev_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
force-pushed
the
dev/xichenlin/nested-portchannel-hierarchy
branch
from
July 31, 2026 17:57
1659bef to
3128da1
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Xichen96
marked this pull request as ready for review
July 31, 2026 17:58
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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
force-pushed
the
dev/xichenlin/nested-portchannel-hierarchy
branch
from
July 31, 2026 19:20
3128da1 to
1331563
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Track a physical member through its VLAN-backed PortChannel:
Ethernet312 -> PortChannel1005 -> Vlan1000The current implementation records
PortChannel1005 -> Vlan1000, but skipsthe physical-member relation when the PortChannel is not itself a command-line
context interface.
Work item tracking
Type of change
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?
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