Skip to content

[dhcpmon] Cleanup stale v6 counters from COUNTERS_DB#74

Open
Xichen96 wants to merge 1 commit into
sonic-net:masterfrom
Xichen96:dev/xichenlin/dhcpmon-cleanup-stale-v6-counters
Open

[dhcpmon] Cleanup stale v6 counters from COUNTERS_DB#74
Xichen96 wants to merge 1 commit into
sonic-net:masterfrom
Xichen96:dev/xichenlin/dhcpmon-cleanup-stale-v6-counters

Conversation

@Xichen96
Copy link
Copy Markdown
Contributor

@Xichen96 Xichen96 commented May 8, 2026

Why I did it

Follow-up to PR #62 (DHCPv6 support). cleanup_stale_db_counters() only scans DHCPV4_COUNTER_TABLE:* keys, so stale DHCPV6_COUNTER_TABLE:* entries (e.g. interfaces removed from a VLAN, or a VLAN that flipped between dhcpv4_relay and dhcpv6_relay configs) are never purged from COUNTERS_DB.

Work item tracking
  • Microsoft ADO (number only): N/A

How I did it

Wrap the existing match/delete logic in for (bool is_v6 : {false, true}) and pass is_v6 to construct_counter_db_table_key(). Both call sites — startup (initialize_all_intf_counters()) and the periodic db_update_callback() — pick up the v6 path automatically.

How to verify it

On a v6-relay testbed, remove an interface from a Vlan (or flip its relay config from v6 back to v4) and confirm that the corresponding DHCPV6_COUNTER_TABLE:<vlan>:<ifname> entry is removed from COUNTERS_DB after the next db_update_callback() tick.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

  • master

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

`cleanup_stale_db_counters()` was added in PR sonic-net#62 alongside the v6
support, but it only scans `DHCPV4_COUNTER_TABLE:` keys. As a result,
stale `DHCPV6_COUNTER_TABLE:` entries (e.g. interfaces removed from a
VLAN, or VLANs that flipped between dhcpv4_relay and dhcpv6_relay
configs) are never deleted from COUNTERS_DB.

Wrap the existing match/delete logic in a loop over `{false, true}`
so both DHCPV4_COUNTER_TABLE and DHCPV6_COUNTER_TABLE prefixes are
scanned. Both call sites — startup
(`initialize_all_intf_counters()`) and the periodic
`db_update_callback()` — pick up the v6 path automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
@Xichen96 Xichen96 force-pushed the dev/xichenlin/dhcpmon-cleanup-stale-v6-counters branch from 3299183 to 7fc6cab Compare May 10, 2026 12:21
@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.

2 participants