From 1253b16485e37fa03aeb0409f1098ab929c82d1f Mon Sep 17 00:00:00 2001 From: Nanma Purushotam Date: Wed, 12 Feb 2025 17:23:55 -0800 Subject: [PATCH 1/2] Fixed dhcp Option 60 encoding --- files/dhcp/dhclient.conf.j2 | 3 +++ files/image_config/interfaces/interfaces-config.sh | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/files/dhcp/dhclient.conf.j2 b/files/dhcp/dhclient.conf.j2 index 2a6f6fa84fb..9a9ba52491a 100644 --- a/files/dhcp/dhclient.conf.j2 +++ b/files/dhcp/dhclient.conf.j2 @@ -28,6 +28,7 @@ option provisioning-script-url code 239 = text; option dhcp6.user-class code 15 = text; option dhcp6.provisioning-script-url code 239 = text; option dhcp6.boot-file-url code 59 = text; +option vendor-class code 60 = text; send host-name = gethostname(); request subnet-mask, broadcast-address, time-offset, routers, @@ -43,3 +44,5 @@ send dhcp6.user-class "SONiC-ZTP"; send dhcp-client-identifier "SONiC##{{ ZTP['mode']['product-name'] }}##{{ ZTP['mode']['serial-no'] }}"; retry 60; {% endif %} + +send vendor-class "{{VENDOR_NAME}}:{{PRODUCT_NAME}}"; \ No newline at end of file diff --git a/files/image_config/interfaces/interfaces-config.sh b/files/image_config/interfaces/interfaces-config.sh index 669d12849f1..c8fd6059922 100755 --- a/files/image_config/interfaces/interfaces-config.sh +++ b/files/image_config/interfaces/interfaces-config.sh @@ -63,14 +63,15 @@ else echo "{ \"ZTP_DHCP_DISABLED\" : \"true\" }" > /tmp/ztp_input.json fi +VENDOR_NAME=$(decode-syseeprom -v | tr -dc '[[:print:]]') +PRODUCT_NAME=$(decode-syseeprom -p | tr -dc '[[:print:]]') # Create /e/n/i file for existing and active interfaces, dhcp6 sytcl.conf and dhclient.conf -CFGGEN_PARAMS=" \ +sonic-cfggen -a "{\"VENDOR_NAME\": \"${VENDOR_NAME}\", \ + \"PRODUCT_NAME\":\"{$PRODUCT_NAME}\"}" \ -d -j /tmp/ztp_input.json \ -t /usr/share/sonic/templates/interfaces.j2,/etc/network/interfaces \ -t /usr/share/sonic/templates/90-dhcp6-systcl.conf.j2,/etc/sysctl.d/90-dhcp6-systcl.conf \ - -t /usr/share/sonic/templates/dhclient.conf.j2,/etc/dhcp/dhclient.conf \ -" -sonic-cfggen $CFGGEN_PARAMS + -t /usr/share/sonic/templates/dhclient.conf.j2,/etc/dhcp/dhclient.conf [[ -f /var/run/dhclient.eth0.pid ]] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid [[ -f /var/run/dhclient6.eth0.pid ]] && kill `cat /var/run/dhclient6.eth0.pid` && rm -f /var/run/dhclient6.eth0.pid From 3f382c96b3bb92166f6124badc951b3da6e08660 Mon Sep 17 00:00:00 2001 From: Nanma Purushotam Date: Tue, 1 Jul 2025 10:40:45 -0700 Subject: [PATCH 2/2] Added change to ensure first character in byte stream indicates its a null terminated string --- files/dhcp/dhclient.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/dhcp/dhclient.conf.j2 b/files/dhcp/dhclient.conf.j2 index 9a9ba52491a..07c61ea23b7 100644 --- a/files/dhcp/dhclient.conf.j2 +++ b/files/dhcp/dhclient.conf.j2 @@ -41,7 +41,7 @@ request subnet-mask, broadcast-address, time-offset, routers, {% if ZTP is defined and ZTP_DHCP_DISABLED is not defined %} send user-class "SONiC-ZTP"; send dhcp6.user-class "SONiC-ZTP"; -send dhcp-client-identifier "SONiC##{{ ZTP['mode']['product-name'] }}##{{ ZTP['mode']['serial-no'] }}"; +send dhcp-client-identifier "\x00SONiC##{{ ZTP['mode']['product-name'] }}##{{ ZTP['mode']['serial-no'] }}"; retry 60; {% endif %}