Skip to content

[dhcp_relay]: sonic dhcp relay agent for IPv4#4004

Merged
Blueve merged 7 commits intosonic-net:masterfrom
cshivashgit:sonic-dhcp4relay
Nov 5, 2025
Merged

[dhcp_relay]: sonic dhcp relay agent for IPv4#4004
Blueve merged 7 commits intosonic-net:masterfrom
cshivashgit:sonic-dhcp4relay

Conversation

@cshivashgit
Copy link
Contributor

Changes for SONiC DHCPv4 Relay feature

Currently SONiC uses the 'isc-dhcp-relay' package to allow DHCP relay functionality on IPv4 networks.
With this PR we are adding sonic dhcp relay agent for IPv4 as described in this HLD(sonic-net/SONiC#1938).

What I did

  • Added dependency checks in SONiC config CLI to prevent deletion of interfaces, VRFs, and VLANs that are in use by DHCPv4 relay configurations.
  • Added/updated unit tests.

How I did it

  • Implemented a new function check_dhcpv4_relay_dependencies to check if an interface or VRF is referenced in the DHCPV4_RELAY table.
  • Called this function before allowing deletion of portchannels, loopbacks, VRFs, and VLANs.
  • Modified the VLAN deletion logic to block removal if the VLAN is present in the DHCPV4_RELAY table.
  • Extended the test suite to verify that deletion is blocked when dependencies exist and allowed after cleanup.

How to verify it

  • Run the updated unit tests: they now include cases where deletion of interfaces, VRFs, or VLANs in use by DHCPv4 relay is attempted and should fail.
  • Manually test by configuring DHCPv4 relay on an interface/VRF/VLAN, then attempt to delete it using the CLI; the command should fail with an appropriate error message.
  • After removing the DHCPv4 relay configuration, deletion should succeed.

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Changes for SONiC DHCPv4 Relay feature
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

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.

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 4004 in repo sonic-net/sonic-utilities

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Blueve
Blueve previously approved these changes Oct 29, 2025
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Blueve Blueve merged commit 3035299 into sonic-net:master Nov 5, 2025
7 checks passed
gordon-nexthop pushed a commit to nexthop-ai/sonic-utilities that referenced this pull request Nov 25, 2025
Currently SONiC uses the 'isc-dhcp-relay' package to allow DHCP relay functionality on IPv4 networks.
With this PR we are adding sonic dhcp relay agent for IPv4 as described in this HLD(sonic-net/SONiC#1938).

What I did
Added dependency checks in SONiC config CLI to prevent deletion of interfaces, VRFs, and VLANs that are in use by DHCPv4 relay configurations.
Added/updated unit tests.
How I did it
Implemented a new function check_dhcpv4_relay_dependencies to check if an interface or VRF is referenced in the DHCPV4_RELAY table.
Called this function before allowing deletion of portchannels, loopbacks, VRFs, and VLANs.
Modified the VLAN deletion logic to block removal if the VLAN is present in the DHCPV4_RELAY table.
Extended the test suite to verify that deletion is blocked when dependencies exist and allowed after cleanup.

How to verify it
Run the updated unit tests: they now include cases where deletion of interfaces, VRFs, or VLANs in use by DHCPv4 relay is attempted and should fail.
Manually test by configuring DHCPv4 relay on an interface/VRF/VLAN, then attempt to delete it using the CLI; the command should fail with an appropriate error message.
After removing the DHCPv4 relay configuration, deletion should succeed.
YairRaviv pushed a commit to YairRaviv/sonic-utilities that referenced this pull request Jan 12, 2026
Currently SONiC uses the 'isc-dhcp-relay' package to allow DHCP relay functionality on IPv4 networks.
With this PR we are adding sonic dhcp relay agent for IPv4 as described in this HLD(sonic-net/SONiC#1938).

What I did
Added dependency checks in SONiC config CLI to prevent deletion of interfaces, VRFs, and VLANs that are in use by DHCPv4 relay configurations.
Added/updated unit tests.
How I did it
Implemented a new function check_dhcpv4_relay_dependencies to check if an interface or VRF is referenced in the DHCPV4_RELAY table.
Called this function before allowing deletion of portchannels, loopbacks, VRFs, and VLANs.
Modified the VLAN deletion logic to block removal if the VLAN is present in the DHCPV4_RELAY table.
Extended the test suite to verify that deletion is blocked when dependencies exist and allowed after cleanup.

How to verify it
Run the updated unit tests: they now include cases where deletion of interfaces, VRFs, or VLANs in use by DHCPv4 relay is attempted and should fail.
Manually test by configuring DHCPv4 relay on an interface/VRF/VLAN, then attempt to delete it using the CLI; the command should fail with an appropriate error message.
After removing the DHCPv4 relay configuration, deletion should succeed.
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.

4 participants