[dhcpmon] Identify parent and aggregate counter disparities - #100
Draft
Xichen96 wants to merge 3 commits into
Draft
[dhcpmon] Identify parent and aggregate counter disparities#100Xichen96 wants to merge 3 commits into
Xichen96 wants to merge 3 commits into
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). |
5 tasks
There was a problem hiding this comment.
Pull request overview
This PR enhances dhcpmon’s hierarchy mismatch alerting by recording and reporting the specific parent → immediate-child aggregate edge where DHCP counter deltas diverge, improving operator diagnostics in nested interface hierarchies (e.g., Ethernet -> PortChannel -> VLAN SVI).
Changes:
- Switch aggregate-counter attribution to “immediate parent” via new
dhcp_devman_get_parent_ifname()/dhcp_devman_get_agg_counter_ifname(). - Capture and expose detailed mismatch context (IP family, direction, parent/child deltas, expected ratio, message type) and append it to existing hierarchy syslog alerts.
- Treat “child-only activity” as non-idle for hierarchy checks to avoid masking mismatches during the evaluation window.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/util.h | Removes the old inline aggregate-counter helper in favor of devman-owned logic. |
| src/packet_handler.cpp | Updates cache counter aggregation to use devman immediate-parent aggregate naming. |
| src/health_check.cpp | Appends last recorded hierarchy-mismatch detail to existing alert syslogs. |
| src/dhcp_mon.cpp | Updates aggregate-counter recalculation to use devman immediate-parent aggregation. |
| src/dhcp_devman.h | Adds APIs to retrieve immediate parent and corresponding aggregate-counter name. |
| src/dhcp_devman.cpp | Implements parent/aggregate lookup and adjusts PortChannel-member mapping for nested hierarchies. |
| src/dhcp_device.h | Exposes accessor for the most recent hierarchy mismatch detail string. |
| src/dhcp_device.cpp | Records mismatch detail on first delta divergence; updates hierarchy health evaluation logic. |
Comments suppressed due to low confidence (1)
src/dhcp_device.cpp:241
check_aggregate_health()takesratioasuint8_t, but callers passreadonly_access(...).size()sums (size_t). If the parent has >255 children (e.g., large VLAN membership), the value truncates and can produce incorrect health results and misleadingexpected_ratioin mismatch logs. Use a wider type (e.g.,size_t) forratiohere (and incheck_counters_delta_expected).
static dhcp_mon_status_t check_aggregate_health(const std::string &ifname, int sock, uint8_t ratio,
const int *monitored_msgs, size_t monitored_msg_cnt)
{
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 |
Xichen96
force-pushed
the
dev/xichenlin/log-hierarchy-mismatch-edge
branch
from
July 28, 2026 05:25
89400cf to
257b6b3
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Xichen96
force-pushed
the
dev/xichenlin/log-hierarchy-mismatch-edge
branch
from
July 28, 2026 05:40
257b6b3 to
8c0b84e
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Xichen96
force-pushed
the
dev/xichenlin/log-hierarchy-mismatch-edge
branch
from
July 28, 2026 05:58
8c0b84e to
3ab0905
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Xichen96
force-pushed
the
dev/xichenlin/log-hierarchy-mismatch-edge
branch
from
July 31, 2026 17:57
3ab0905 to
6cf80d6
Compare
Collaborator
|
/azp run |
1 task
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
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>
Populate one state per discovered VLAN or PortChannel check, derive aggregate ratios from topology, and format aggregate disparity errors with the interface and duration. 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/log-hierarchy-mismatch-edge
branch
from
July 31, 2026 19:20
6cf80d6 to
831de60
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/health_check.cpp:110
- Aggregate-disparity threshold logs only include the parent interface name (via state.ifname), but the PR goal is to report both the parent interface and the specific member-aggregate counter that diverged. Right now operators still can’t see which aggregate counter (e.g., Agg--) was compared.
if (++state.count > dhcp_unhealthy_max_count) {
int duration = state.count * window_interval_sec;
if (state.alert) {
state.alert(duration);
}
syslog(LOG_ALERT, state.error_format, state.ifname.c_str(), duration);
}
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
Report the exact parent interface and aggregate counter whose values diverged.
Dependency:
Review the final commit only:
831de60 [dhcpmon]: Track parent and aggregate counters per interfaceWork item tracking
Type of change
Approach
What is the motivation for this PR?
The existing aggregate counter alert says only that a VLAN/PortChannel
aggregate does not match. In the F2 path, operators must distinguish:
physical member -> PortChannel -> VLAN SVIwithout interpreting a pre-VLAN loss as a relay drop.
How did you do it?
aggregate, so a child-only increment is not treated as an idle window.
parent/aggregate pair has an independent persistence counter.
the interface topology instead of encoding equal/multiple in the check type.
format directly with the interface name and duration. The internal
Agg-*counter name is not exposed in the user-facing message.How did you verify/test it?
On F2 hardware with
PortChannel1005down due tomin_links, packets reachedthe PortChannel but not
Vlan1000. The equivalent comparison identified:Parent interface: Vlan1000, member aggregate: Agg-Vlan1000-Vlan1000No relay-disparity event was emitted for that pre-VLAN loss.
Fresh exact-head Azure PR CI is pending. No local compilation is used.
Any platform specific information?
No.
Back port request
None. This targets master only.
Tested branch
master, plus supplemental F2 topology validation with master-target PR
artifacts on SONiC 202503.
Test result
The equivalent parent/aggregate comparison identified the expected counters on
F2 hardware, and the traditional master DHCPv4/DHCPv6 regression passed
unchanged. Exact-head acceptance awaits the fresh PR build.
Documentation
Not applicable.