From f0e7e4e0c5233c473db844d3b1a294f544c2451c Mon Sep 17 00:00:00 2001 From: Devesh Pathak <250206677+devesh-nexthop@users.noreply.github.com> Date: Wed, 1 Apr 2026 05:25:03 +0000 Subject: [PATCH 1/2] Add routed port support to dhcp_relay Signed-off-by: Devesh Pathak <250206677+devesh-nexthop@users.noreply.github.com> --- .../DHCPv4-relay-agent-High-Level-Design.md | 186 ++++++++++++++---- doc/DHCPv6_Relay/DHCPv6_Relay_HLD.md | 70 +++++-- .../DHCPv6-relay-agent-High-Level-Design.md | 27 ++- 3 files changed, 219 insertions(+), 64 deletions(-) diff --git a/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md b/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md index 5da635858a5..a9318eb657f 100644 --- a/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md +++ b/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md @@ -25,6 +25,7 @@ - [5.1.3 Interop with Port-Based DHCP Server](#513-interop-with-port-based-dhcp-server) - [5.1.4 DHCP Monitor](#514-dhcp-monitor) - [5.1.5 Dual-Tor Support](#515-dual-tor-support) + - [5.1.6 Routed Port Support](#516-physical-port-support) - [6. Detailed Design](#6-detailed-design) - [6.1 DHCPv4 Config Manager](#61-dhcpv4-config-manager) - [6.2 Relay Main](#62-relay-main) @@ -55,10 +56,11 @@ | Rev | Date | Author | Change Description | |:---:|:-----------:|:---------------------:|:--------------------------------:| | 1.0 | 02/28/2025 | Ashutosh Agrawal | Initial Version | +| 2.0 | 03/25/2026 | Devesh Pathak | Added routed port support and circuit-id configuration | ### 2. Scope -This document describes high level design details of SONiC's new DHCPv4 relay agent. +This document describes high level design details of SONiC's new DHCPv4 relay agent. The relay agent supports both VLAN interfaces and routed ports. ### 3. Definitions @@ -102,7 +104,9 @@ A DHCP relay agent is an essential component in networks where clients and DHCP - **R0:** Support basic DHCP Relay Functionality described in the previous section. -- **R1:** Support clients in multiple VLANs from the same process. +- **R1:** Support clients in multiple VLANs and routed ports from the same process. + +- **R1a:** Support DHCP relay on routed ports, in addition to VLAN interfaces. - **R2:** Support client and servers in both default and non-default VRFs. @@ -144,7 +148,8 @@ A DHCP relay agent is an essential component in networks where clients and DHCP - Number of VRFs - 1024 - Number of VLANs - 4096 - - Number of DHCP Servers per VLAN - 32 + - Number of Routed Ports - 1024 + - Number of DHCP Servers per interface (VLAN or routed port) - 32 - **R14:** This proposed DHCP relay agent will need to support all the functionality that has been added over the years in the community through various patches. The complete backward compatibitlity with ISC DHCP is an aspirational goal. @@ -170,22 +175,33 @@ In a dual-TOR (Top-of-Rack) architecture, it's possible for DHCP request packets By enabling the link-selection option, the DHCP relay will use the interface specified by the source-interface option to populate the giaddr field in the packet. When the loopback interface is set as the source-interface, the DHCP request packet sent from the client will have the loopback IP of the originating TOR in the giaddr field. If the DHCP response arrives at the peer TOR, which is in standby mode, it will simply route the packet to the originating ToR. Once the originating TOR receives the response, it can forward the packet to the client through its active interface, as it normally would. +##### 5.1.6 Routed Port Support +The DHCPv4 relay agent now supports routed ports in addition to VLAN interfaces. This enhancement allows DHCP relay functionality on L3 interfaces configured in the INTERFACE table without requiring VLAN encapsulation. Key aspects of routed port support include: + +- **Socket Management**: L3 sockets with SO_BINDTODEVICE are used for routed ports, bound to specific interfaces +- **Interface Mapping**: For VLANs, member ports map to the VLAN (e.g., Ethernet0 → Vlan100). For routed ports, the port maps to itself (e.g., Ethernet4 → Ethernet4) +- **Circuit ID Formats**: Multiple configurable formats support both VLAN and routed port scenarios +- **Configuration Tables**: Both VLAN_INTERFACE and INTERFACE tables are monitored for relay configuration + ### 6. Detailed Design -DHCPv4 relay process will run in the dhcp_relay container along with DHCPv6 processes and DhcpMon. A single instance of the process will handle DHCPv4 relay functionality of all the VLANs that are configured. This process will listen to Redis for all the necessary configuration updates and will not require restarting of the container. The design is split into 3 sub-modules and the following diagram provides an overview of how they interact with each other: +DHCPv4 relay process will run in the dhcp_relay container along with DHCPv6 processes and DhcpMon. A single instance of the process will handle DHCPv4 relay functionality of all the VLANs and routed ports that are configured. This process will listen to Redis for all the necessary configuration updates and will not require restarting of the container. The design is split into 3 sub-modules and the following diagram provides an overview of how they interact with each other:
module DHCP
container DHCP {
- list VLAN_LIST {
+ list INTERFACE_LIST {
key name;
leaf name {
- type string;
+ type string; // VLAN interface or routed port
}
leaf dhcpv6_servers {
type inet6:ip-address;
@@ -196,7 +199,17 @@ Option 79 should be enabled by default and can be disabled through command line.
# Option for Dual ToR
-Relayed DHCPv6 packet from ToR may have the response routed to the peer ToR that has the link as standby. Since the originating client is not active on this ToR, the peer ToR won't be able to relay the response. Peer ToR will not receive the packets as the originating client is not active on this ToR. Instead of using Vlan SVI IP address, relay agent source address needs to be set to listen on the loopback address. When DHCP server responses are received by relay agent on the peer ToR, DHCP relay agent would then forward the packet to the peer ToR using its loopback IP interface.
+Relayed DHCPv6 packet from ToR may have the response routed to the peer ToR that has the link as standby. Since the originating client is not active on this ToR, the peer ToR won't be able to relay the response. Peer ToR will not receive the packets as the originating client is not active on this ToR. Instead of using the interface IP address (VLAN SVI or routed port), relay agent source address needs to be set to listen on the loopback address. When DHCP server responses are received by relay agent on the peer ToR, DHCP relay agent would then forward the packet to the peer ToR using its loopback IP interface.
+
+# Routed Port Support
+
+The DHCPv6 relay agent supports routed ports in addition to VLAN interfaces. This enhancement allows DHCPv6 relay functionality on L3 interfaces configured in the INTERFACE table without requiring VLAN encapsulation. Key aspects of routed port support include:
+
+- **Interface Types**: Both VLAN interfaces and routed ports (physical Ethernet interfaces with L3 configuration) can act as downstream interfaces for DHCPv6 relay
+- **Configuration Tables**: Both VLAN_INTERFACE and INTERFACE tables are monitored for relay configuration
+- **Socket Management**: L3 sockets are used for routed ports, bound to specific interfaces similar to VLAN interfaces
+- **Link-address Field**: For routed ports, the relay agent uses the global IPv6 address configured on the routed interface as the link-address in Relay-Forward messages
+- **Client Identification**: Option 79 (client link-layer address) works identically for both VLAN and routed port scenarios
# Feature table
@@ -216,7 +229,7 @@ Control Plane Policing manager is currently configured to only trap DHCPv6 packe
# Source IP
-VLAN SVI IP
+Interface IP (VLAN SVI or routed port)
Configurable option to use loopback address for dual ToR
From 08b13ea76ab73a8687095fe474089f86fe721c28 Mon Sep 17 00:00:00 2001
From: devesh-nexthop <250206677+devesh-nexthop@users.noreply.github.com>
Date: Mon, 4 May 2026 22:55:38 -0700
Subject: [PATCH 2/2] Revise DHCPv4 relay agent design documentation
Updated scalability requirements and enhanced routed port support in the DHCPv4 relay agent documentation. Adjusted circuit ID and chassis ID handling, and refined CLI output examples.
---
.../DHCPv4-relay-agent-High-Level-Design.md | 42 ++++++-------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md b/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md
index a9318eb657f..13c9c037862 100644
--- a/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md
+++ b/doc/DHCPv4_relay/DHCPv4-relay-agent-High-Level-Design.md
@@ -148,7 +148,7 @@ A DHCP relay agent is an essential component in networks where clients and DHCP
- Number of VRFs - 1024
- Number of VLANs - 4096
- - Number of Routed Ports - 1024
+ - Number of Routed Ports - 4096
- Number of DHCP Servers per interface (VLAN or routed port) - 32
- **R14:** This proposed DHCP relay agent will need to support all the functionality that has been added over the years in the community through various patches. The complete backward compatibitlity with ISC DHCP is an aspirational goal.
@@ -178,7 +178,7 @@ By enabling the link-selection option, the DHCP relay will use the interface spe
##### 5.1.6 Routed Port Support
The DHCPv4 relay agent now supports routed ports in addition to VLAN interfaces. This enhancement allows DHCP relay functionality on L3 interfaces configured in the INTERFACE table without requiring VLAN encapsulation. Key aspects of routed port support include:
-- **Socket Management**: L3 sockets with SO_BINDTODEVICE are used for routed ports, bound to specific interfaces
+- **Socket Management**: L3 sockets are used for routed ports, bound to specific interfaces
- **Interface Mapping**: For VLANs, member ports map to the VLAN (e.g., Ethernet0 → Vlan100). For routed ports, the port maps to itself (e.g., Ethernet4 → Ethernet4)
- **Circuit ID Formats**: Multiple configurable formats support both VLAN and routed port scenarios
- **Configuration Tables**: Both VLAN_INTERFACE and INTERFACE tables are monitored for relay configuration
@@ -195,7 +195,7 @@ The Config Manager thread is responsible for subscribing to the Redis database t
- **DHCPV4_RELAY Table**: For relay configuration on VLAN and physical port interfaces
- **VLAN_INTERFACE Table:** For VLAN interface configurations
- **INTERFACE Table:** For routed port configurations
-- **PORT Table:** For routed port attributes including circuit_id, circuit_id_format, and max_hop_count
+- **PORT Table:** For routed port attributes including circuit_id, and circuit_id_format
- **INTF Table:** For mapping source interfaces to IP addresses when the source-interface parameter is enabled in the relay configuration.
- **VRF Table:** For creating sockets to send packets to Server.
- **FEATURE Table:** To check if port based `dhcp_server` feature is enabled.
@@ -216,7 +216,7 @@ Depending on the configurations, Relay Main establishes sockets to receive and t
- **Sending Packets to the Server:** For transmitting packets to the server, Relay Main opens and binds a socket for the server VRF. If no server VRF is specified in the DHCPV4_RELAY table, the client and server are assumed to be in the same VRF and client-side interface table's (VLAN_INTERFACE or INTERFACE) VRF field is used to bind the socket.
-- **Sending Packets to the Client:** A socket is opened on the client-side interface (VLAN or routed port) to forward DHCPv4 packets to the client. For VLANs, this socket is used to broadcast DHCP Offer and Ack packets. For routed ports, L3 sockets with SO_BINDTODEVICE are used, bound to the specific interface.
+- **Sending Packets to the Client:** A socket is opened on the client-side interface (VLAN or routed port) to forward DHCPv4 packets to the client. For VLANs, this socket is used to broadcast DHCP Offer and Ack packets. For routed ports, L3 sockets are used, bound to the specific interface.
When the DHCPv4 relay feature is enabled, the Control Plane Policing (CoPP) manager will configure appropriate trap rules, ensuring that DHCPv4 packets are trapped and rate-limited by the Network Processing Unit (NPU). Once these packets reach the kernel, the DHCP relay main process captures them through the previously described socket mechanisms.
@@ -237,7 +237,7 @@ The processing steps are as follows:
- **interface_ip**: `interface_ip`
- **custom**: User-defined string from `circuit_id` field
- If `chassis_id` is configured in DEVICE_METADATA table, it is used instead of `hostname`. If neither is present, `sonic` is used as default.
+ If `hostname` is not present in the Device Metadata table, `sonic` is used as hostname instead.
| Subopt | Len | Circuit ID |
@@ -501,8 +501,7 @@ A new table, named DHCPV4_RELAY, will be introduced in the config-db to define D
"vrf_selection": "enable",
"server_id_override": "enable",
"agent_relay_mode": "forward_untouched",
- "circuit_id_format": "default",
- "chassis_id": "my-chassis-01"
+ "circuit_id_format": "default"
}
}
}
@@ -515,8 +514,7 @@ A new table, named DHCPV4_RELAY, will be introduced in the config-db to define D
"Ethernet4": {
"dhcpv4_servers": ["10.0.0.1", "10.0.0.2"],
"circuit_id_format": "custom",
- "circuit_id": "CustomCircuitID",
- "max_hop_count": "10"
+ "circuit_id": "CustomCircuitID"
}
},
"INTERFACE": {
@@ -525,19 +523,6 @@ A new table, named DHCPV4_RELAY, will be introduced in the config-db to define D
}
```
-**Example 3: DEVICE_METADATA with chassis_id**
-```
-{
- "DEVICE_METADATA": {
- "localhost": {
- "hostname": "sonic-switch",
- "mac": "00:11:22:33:44:55",
- "chassis_id": "chassis-rack1-switch2"
- }
- }
-}
-```
-
#### 8.2 Counter-DB
A new DHCPV4_RELAY_COUNTER table will be added in the Counter DB.
@@ -606,7 +591,6 @@ sudo config dhcp_relay ipv4 helper del Ethernet4 10.0.0.1
--circuit-id-format Format for Circuit ID sub-option
--circuit-id Custom Circuit ID value (used with custom format)
- --chassis-id Chassis ID to use in Circuit ID
--dhcpv4-servers Server IPv4 address list
-h, -?, --help Show this message and exit.
```
@@ -696,12 +680,12 @@ root@sonic:/home/cisco# show dhcp_relay ipv4 helper
```
root@sonic:/home/cisco# show dhcp_relay ipv4 helper
-NAME SERVER VRF SOURCE INTERFACE LINK SELECTION VRF SELECTION SERVER ID OVERRIDE AGENT RELAY MODE MAX HOP COUNT CIRCUIT ID FORMAT CHASSIS ID DHCPV4 SERVERS
---------- ------------ ------------------ ---------------- --------------- -------------------- ------------------- --------------- ----------------- ------------------- ----------------
-Vlan12 Vrf01 Loopback0 enable enable enable forward_and_replace 4 default chassis-rack1-sw2 192.168.12.1
- 192.168.12.2
-Ethernet4 - - disable disable disable forward_untouched 10 custom - 10.0.0.1
- 10.0.0.2
+NAME SERVER VRF SOURCE INTERFACE LINK SELECTION VRF SELECTION SERVER ID OVERRIDE AGENT RELAY MODE MAX HOP COUNT CIRCUIT ID FORMAT DHCPV4 SERVERS
+--------- ------------ ------------------ ---------------- --------------- -------------------- ------------------- --------------- ----------------- ----------------
+Vlan12 Vrf01 Loopback0 enable enable enable forward_and_replace 4 default 192.168.12.1
+ 192.168.12.2
+Ethernet4 - - disable disable disable forward_untouched 10 custom 10.0.0.1
+ 10.0.0.2
```
##### 9.2.3 New Show CLI to report per-interface counters