Skip to content

Use FEATURE|dhcp_server state for DHCPv4 profile selection#69

Open
Xichen96 wants to merge 1 commit into
sonic-net:masterfrom
Xichen96:dev/xichenlin/string-comparison-cleanup
Open

Use FEATURE|dhcp_server state for DHCPv4 profile selection#69
Xichen96 wants to merge 1 commit into
sonic-net:masterfrom
Xichen96:dev/xichenlin/string-comparison-cleanup

Conversation

@Xichen96
Copy link
Copy Markdown
Contributor

@Xichen96 Xichen96 commented Apr 7, 2026

Why I did it

Previously dhcpmon selected the DHCPv4 check profile based on device type
string from DEVICE_METADATA, which was fragile and required maintaining a
mapping of device types to profiles.

How I did it

  • Read FEATURE|dhcp_server state from CONFIG_DB
  • If state == "enabled", use server check profiles
  • Otherwise, use first relay check profiles
  • DHCPv6 always uses relay profiles since dhcpmon only runs inside the
    dhcp_relay container
  • Removed the ToRRouter device type validation gate (no longer needed)

How to verify it

  • On a relay device (m0/t0): verify syslog shows "Set dhcp_check_profile
    to first relay profiles"
  • On a server device (mx with dhcp_server enabled): verify syslog shows
    "Set dhcp_check_profile to server profiles"
  • Run dhcp_relay tests on both topologies to confirm no regressions

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates dhcp_devman_init() to select the appropriate DHCPv4 health-check profile based on the device type read from SONiC CONFIG_DB, so that BmcMgmtToRRouter devices use server-oriented checks rather than relay-oriented checks.

Changes:

  • Read DEVICE_METADATA|localhost:type from CONFIG_DB during initialization and validate it contains ToRRouter.
  • Select DHCPv4 server check profiles for BmcMgmtToRRouter; otherwise default to first-relay profiles.
  • Minor syslog message tweak for DHCPv6 check profile selection.

Comment thread src/dhcp_devman.cpp Outdated
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@Xichen96 Xichen96 force-pushed the dev/xichenlin/string-comparison-cleanup branch from 36a060c to b4267aa Compare April 8, 2026 11:05
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Xichen96 Xichen96 force-pushed the dev/xichenlin/string-comparison-cleanup branch 2 times, most recently from 1126cfe to 23d406c Compare April 8, 2026 13:12
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@Xichen96 Xichen96 force-pushed the dev/xichenlin/string-comparison-cleanup branch from 23d406c to 1607f49 Compare April 8, 2026 13:13
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Xichen96 Xichen96 changed the title [dhcpmon] Select DHCPv4 check profile based on device type from CONFIG_DB Use FEATURE|dhcp_server state for DHCPv4 profile selection Apr 8, 2026
…in CONFIG_DB

Read FEATURE|dhcp_server state from CONFIG_DB. If enabled, use server
check profiles; otherwise use first relay profiles. DHCPv6 always uses
relay profiles since dhcpmon only runs inside the dhcp_relay container.

Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
@Xichen96 Xichen96 force-pushed the dev/xichenlin/string-comparison-cleanup branch from 1607f49 to 0a6bf3e Compare April 9, 2026 13:38
@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