Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5f3860c
add sonic dhcpv4 relay agent
AnantKishorSharma Apr 30, 2025
c8b9802
new src path for dhcp6relay
AnantKishorSharma Apr 30, 2025
ad53ec9
DHCPv4 Relay Yang Model changes are part of PR #22338
AnantKishorSharma May 2, 2025
79c6843
DHCPv4 Relay Yang Model changes are part of PR #22338
AnantKishorSharma May 2, 2025
5a81367
DHCPv4 Relay Yang Model changes are part of PR #22338
AnantKishorSharma May 2, 2025
6b95785
add sonic dhcpv4 relay agent
AnantKishorSharma Apr 30, 2025
149577c
new src path for dhcp6relay
AnantKishorSharma Apr 30, 2025
209ef65
DHCPv4 Relay Yang Model changes are part of PR #22338
AnantKishorSharma May 2, 2025
2869413
DHCPv4 Relay Yang Model changes are part of PR #22338
AnantKishorSharma May 2, 2025
5a088dc
DHCPv4 Relay Yang Model changes are part of PR #22338
AnantKishorSharma May 2, 2025
2828bf2
Addressing MSFT comments on HLD
cshivashgit May 20, 2025
e614ff3
CLI bug fixes, Added has_sonic_dhcpv4_relay feature flag in yang
cshivashgit Jun 24, 2025
7777780
Revert CLI changes, Moved to new PR
cshivashgit Jul 7, 2025
8dae52f
Merge branch 'sonic-net:master' into sonic-dhcp4relay
AnantKishorSharma Jul 8, 2025
9890314
merge master
AnantKishorSharma Jul 8, 2025
6ce3424
removed the unintended changes from the feature branch
AnantKishorSharma Jul 8, 2025
5dfcc3a
Merge branch 'master' into sonic-dhcp4relay
ashutosh-agrawal Aug 13, 2025
e8de260
Merge branch 'master' into sonic-dhcp4relay
ashutosh-agrawal Sep 30, 2025
1d62e3b
Update rules/dhcp4relay.dep
AnantKishorSharma Oct 25, 2025
3dbb3d2
Update src/sonic-yang-models/yang-models/sonic-feature.yang
AnantKishorSharma Oct 25, 2025
bda4a61
Update dockers/docker-dhcp-relay/dhcpv4-sonic-relay.agents.j2
AnantKishorSharma Oct 25, 2025
963140d
Merge branch 'sonic-net:master' into sonic-dhcp4relay
ashutosh-agrawal Oct 27, 2025
8f7066f
fixed sonic-config-engine ut
ashutosh-agrawal Oct 30, 2025
f92b577
Merge pull request #1 from AnantKishorSharma/ashu/cfg-engine-ut-fix
ashutosh-agrawal Oct 30, 2025
de2737f
Moved has has_sonic_dhcpv4_relay from FEATURE table to DEVICE_METADAT…
ashutosh-agrawal Oct 31, 2025
9fffc4b
Merge branch 'sonic-net:master' into sonic-dhcp4relay
ashutosh-agrawal Nov 6, 2025
f050952
Merge branch 'sonic-net:master' into sonic-dhcp4relay
ashutosh-agrawal Nov 27, 2025
bf23252
Fixed supervisor-proc-exit-listener path to point to the Rust impleme…
ashutosh-agrawal Nov 27, 2025
d5830af
Merge branch 'master' into sonic-dhcp4relay
StormLiangMS Nov 28, 2025
0449c7c
Merge branch 'master' into sonic-dhcp4relay
ashutosh-agrawal Nov 30, 2025
f485426
Merge branch 'master' into sonic-dhcp4relay
AnantKishorSharma Dec 3, 2025
c1d765b
Merge branch 'master' into sonic-dhcp4relay
AnantKishorSharma Dec 3, 2025
cd6cbd4
Merge branch 'master' into sonic-dhcp4relay
ashutosh-agrawal Dec 4, 2025
e056dc0
Merge branch 'master' into sonic-dhcp4relay
ashutosh-agrawal Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dockers/docker-dhcp-relay/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ RUN apt-get update

RUN apt-get install -y libjsoncpp-dev \
python3-dev \
build-essential
build-essential \
libpcap-dev

RUN pip3 install psutil

Expand All @@ -40,7 +41,7 @@ RUN apt-get remove -y build-essential \

COPY ["docker_init.sh", "start.sh", "/usr/bin/"]
COPY ["docker-dhcp-relay.supervisord.conf.j2", "port-name-alias-map.txt.j2", "wait_for_intf.sh.j2", "/usr/share/sonic/templates/"]
COPY ["dhcp-relay.programs.j2", "dhcpv4-relay.agents.j2", "dhcpv6-relay.agents.j2", "dhcp-relay.monitors.j2", "/usr/share/sonic/templates/"]
COPY ["dhcp-relay.programs.j2", "dhcpv4-relay.agents.j2", "dhcpv4-sonic-relay.agents.j2", "dhcpv6-relay.agents.j2", "dhcp-relay.monitors.j2", "/usr/share/sonic/templates/"]
COPY ["critical_processes", "/etc/supervisor"]
COPY ["cli", "/cli/"]

Expand Down
4 changes: 4 additions & 0 deletions dockers/docker-dhcp-relay/dhcp-relay.monitors.j2
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ stdout_syslog=true
stderr_logfile=NONE
stderr_syslog=true
dependent_startup=true
{% if 'has_sonic_dhcpv4_relay' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['has_sonic_dhcpv4_relay'] == 'True' %}
dependent_startup_wait_for=dhcp4relay:running
{% else %}
dependent_startup_wait_for=isc-dhcpv4-relay-{{ vlan_name }}:running
{% endif %}

{% endfor %}
22 changes: 22 additions & 0 deletions dockers/docker-dhcp-relay/dhcp-relay.programs.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[group:dhcp-relay]
programs=dhcprelayd
{%- if 'has_sonic_dhcpv4_relay' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['has_sonic_dhcpv4_relay'] == 'True' %}
{%- set relay_for_ipv6 = { 'flag': False } %}
{%- set add_preceding_comma = { 'flag': True } %}
{% for vlan_name in VLAN_INTERFACE %}
Expand All @@ -12,4 +13,25 @@ programs=dhcprelayd
{% if add_preceding_comma.flag %},{% endif %}
{% set _dummy = add_preceding_comma.update({'flag': True}) %}
dhcp6relay
{%- endif %}
{# Create a program entry for sonic dhcpv4 relay agent #}
{%- set add_preceding_comma = { 'flag': True } %}
{# Append sonic DHCPv4 agent #}
{% if add_preceding_comma.flag %},{% endif %}
{% set _dummy = add_preceding_comma.update({'flag': True}) %}
dhcp4relay
{% else %}
{%- set relay_for_ipv6 = { 'flag': False } %}
{%- set add_preceding_comma = { 'flag': True } %}
{% for vlan_name in VLAN_INTERFACE %}
{% if DHCP_RELAY and vlan_name in DHCP_RELAY and DHCP_RELAY[vlan_name]['dhcpv6_servers']|length > 0 %}
{% set _dummy = relay_for_ipv6.update({'flag': True}) %}
{%- endif %}
{% endfor %}
{# Append DHCPv6 agents #}
{% if relay_for_ipv6.flag %}
{% if add_preceding_comma.flag %},{% endif %}
{% set _dummy = add_preceding_comma.update({'flag': True}) %}
dhcp6relay
{% endif %}
{% endif %}
15 changes: 15 additions & 0 deletions dockers/docker-dhcp-relay/dhcpv4-sonic-relay.agents.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{# Append DHCPv4 sonic agent #}
[program:dhcp4relay]
command=/usr/sbin/dhcp4relay{% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %} -u Loopback0{% endif %}

priority=3
autostart=false
autorestart=false
stdout_logfile=NONE
stdout_syslog=true
stderr_logfile=NONE
stderr_syslog=true
dependent_startup=true
dependent_startup_wait_for=start:exited


14 changes: 14 additions & 0 deletions dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ dependent_startup_wait_for=rsyslogd:running
{# Count how many VLANs require a DHCP relay agent... #}
{% set ipv4_num_relays = { 'count': 0 } %}
{% set ipv6_num_relays = { 'count': 0 } %}
{% if 'has_sonic_dhcpv4_relay' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['has_sonic_dhcpv4_relay'] == 'True' %}
{% set _dummy = ipv4_num_relays.update({'count': ipv4_num_relays.count + 1}) %}
{% endif %}
{% for vlan_name in VLAN_INTERFACE %}
{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %}
{% set _dummy = ipv4_num_relays.update({'count': ipv4_num_relays.count + 1}) %}
Expand All @@ -63,6 +66,12 @@ dependent_startup_wait_for=rsyslogd:running
{# Create a program entry for each DHCP relay agent instance #}
{% set relay_for_ipv4 = { 'flag': False } %}
{% set relay_for_ipv6 = { 'flag': False } %}
{# Decide the dhcpv4 relay agent based on the feature config #}
{% if 'has_sonic_dhcpv4_relay' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['has_sonic_dhcpv4_relay'] == 'True' %}
{% include 'dhcpv4-sonic-relay.agents.j2' %}
{% include 'dhcpv6-relay.agents.j2' %}
{% include 'dhcp-relay.monitors.j2' %}
{% else %}
{% set added_vlan = []%}
{% for (vlan_name, prefix) in VLAN_INTERFACE|pfx_filter %}
{%- if prefix | ipv4 and vlan_name not in added_vlan %}
Expand All @@ -75,6 +84,11 @@ dependent_startup_wait_for=rsyslogd:running
{% include 'dhcp-relay.monitors.j2' %}
{% endif %}
{% endif %}
{% else %}
{% if 'has_sonic_dhcpv4_relay' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['has_sonic_dhcpv4_relay'] == 'True' %}
{% include 'dhcpv4-sonic-relay.agents.j2' %}
{% endif %}
{% endif %}
[program:dhcprelayd]
command=/usr/local/bin/dhcprelayd
priority=3
Expand Down
11 changes: 11 additions & 0 deletions rules/dhcp4relay.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

SPATH := $($(SONIC_DHCP4RELAY)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/dhcp4relay.mk rules/dhcp4relay.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files --recurse-submodules))

$(SONIC_DHCP4RELAY)_CACHE_MODE := GIT_CONTENT_SHA
$(SONIC_DHCP4RELAY)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(SONIC_DHCP4RELAY)_DEP_FILES := $(DEP_FILES)
$(SONIC_DHCP4RELAY)_SMDEP_FILES := $(SMDEP_FILES)
$(SONIC_DHCP4RELAY)_SMDEP_PATHS := $(SPATH)
12 changes: 12 additions & 0 deletions rules/dhcp4relay.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SONiC DHCPV4 RELAY Package

SONIC_DHCP4RELAY_VERSION = 1.0.0-0
SONIC_DHCP4RELAY_PKG_NAME = dhcp4relay

SONIC_DHCP4RELAY = sonic-$(SONIC_DHCP4RELAY_PKG_NAME)_$(SONIC_DHCP4RELAY_VERSION)_$(CONFIGURED_ARCH).deb
$(SONIC_DHCP4RELAY)_DEPENDS = $(LIBSWSSCOMMON) $(LIBSWSSCOMMON_DEV)
$(SONIC_DHCP4RELAY)_SRC_PATH = $(SRC_PATH)/dhcprelay/dhcp4relay
SONIC_DPKG_DEBS += $(SONIC_DHCP4RELAY)

SONIC_DHCP4RELAY_DBG = sonic-$(SONIC_DHCP4RELAY_PKG_NAME)-dbgsym_$(SONIC_DHCP4RELAY_VERSION)_$(CONFIGURED_ARCH).deb
$(eval $(call add_derived_package,$(SONIC_DHCP4RELAY),$(SONIC_DHCP4RELAY_DBG)))
2 changes: 1 addition & 1 deletion rules/docker-dhcp-relay.dep
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

DPATH := $($(DOCKER_DHCP_RELAY)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-dhcp-relay.mk rules/docker-dhcp-relay.dep
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-dhcp-relay.mk rules/docker-dhcp-relay.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

Expand Down
4 changes: 2 additions & 2 deletions rules/docker-dhcp-relay.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ DOCKER_DHCP_RELAY_DBG = $(DOCKER_DHCP_RELAY_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_RELAY_STEM)

$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCPRELAY) $(LIBSWSSCOMMON)
$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCP4RELAY) $(SONIC_DHCPRELAY) $(LIBSWSSCOMMON)

$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS)
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) $(SONIC_DHCPRELAY_DBG) $(SONIC_DHCPMON_DBG)
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) $(SONIC_DHCP4RELAY_DBG) $(SONIC_DHCPRELAY_DBG) $(SONIC_DHCPMON_DBG)

$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"VLAN_INTERFACE": {
"Vlan1000|fc02:2000::2/24": {}
},
"FEATURE": {
"dhcp_server": {
"state": "disabled"
},
"dhcp_relay": {
"auto_restart": "disabled",
"check_up_status": "False",
"delayed": "False",
"has_global_scope": "True",
"has_per_asic_scope": "False",
"high_mem_alert": "disabled",
"set_owner": "local",
"state": "enabled",
"support_syslog_rate_limit": "True"
}

},
"DEVICE_METADATA": {
"localhost": {
"has_sonic_dhcpv4_relay": "False"
}
}
}
26 changes: 26 additions & 0 deletions src/sonic-config-engine/tests/dhcp-sonic-relay-enabled-sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"VLAN_INTERFACE": {
"Vlan1000|fc02:2000::2/24": {}
},
"FEATURE": {
"dhcp_server": {
"state": "disabled"
},
"dhcp_relay": {
"auto_restart": "disabled",
"check_up_status": "False",
"delayed": "False",
"has_global_scope": "True",
"has_per_asic_scope": "False",
"high_mem_alert": "disabled",
"set_owner": "local",
"state": "enabled",
"support_syslog_rate_limit": "True"
}
},
"DEVICE_METADATA": {
"localhost": {
"has_sonic_dhcpv4_relay": "True"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python3 -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE
buffer_size=1024

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener-rs --container-name dhcp_relay
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
autostart=true
autorestart=unexpected
buffer_size=1024

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=false
stdout_logfile=NONE
stdout_syslog=true
stderr_logfile=NONE
stderr_syslog=true
dependent_startup=true

[program:start]
command=/usr/bin/start.sh
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=NONE
stdout_syslog=true
stderr_logfile=NONE
stderr_syslog=true
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[group:dhcp-relay]
programs=dhcprelayd,dhcp4relay

[program:dhcp4relay]
command=/usr/sbin/dhcp4relay
priority=3
autostart=false
autorestart=false
stdout_logfile=NONE
stdout_syslog=true
stderr_logfile=NONE
stderr_syslog=true
dependent_startup=true
dependent_startup_wait_for=start:exited

[group:dhcpmon]
programs=

[program:dhcprelayd]
command=/usr/local/bin/dhcprelayd
priority=3
autostart=false
autorestart=false
stdout_logfile=NONE
stdout_syslog=true
stderr_logfile=NONE
stderr_syslog=true
dependent_startup=true
dependent_startup_wait_for=start:exited
Loading
Loading