Compare commits

...

1 Commits

Author SHA1 Message Date
Tanya Singh
93f3712862 netifd: support DHCP options 138 and 224
Fixes: WIFI-14694
Signed-off-by: Tanya Singh <tanya_singh@accton.com>
2025-09-19 22:54:32 +08:00
2 changed files with 72 additions and 4 deletions

View File

@@ -5,8 +5,8 @@ import * as fs from 'fs';
let cmd = ARGV[0];
let ifname = getenv("interface");
let opt138 = getenv("opt138");
let opt224 = getenv("opt224");
let opt138 = fs.readfile('/tmp/dhcp-option-138');
let opt224 = fs.readfile('/tmp/dhcp-option-224');
if (cmd != 'bound' && cmd != 'renew')
exit(0);
@@ -23,14 +23,14 @@ let cloud = {
lease: true,
};
if (opt138) {
let dhcp = hexdec(opt138);
let dhcp = opt138;
dhcp = split(dhcp, ':');
cloud.dhcp_server = dhcp[0];
cloud.dhcp_port = dhcp[1] ?? 15002;
cloud.no_validation = true;
}
if (opt224) {
let dhcp = hexdec(opt224);
let dhcp = opt224;
dhcp = split(dhcp, ':');
cloud.dhcp_server = dhcp[0];
cloud.dhcp_port = dhcp[1] ?? 15002;

View File

@@ -0,0 +1,68 @@
From ba5c63cc0cbbacd952a5c2cfd873439bf5adc86a Mon Sep 17 00:00:00 2001
From: Tanya Singh <tanya_singh@accton.com>
Date: Thu, 18 Sep 2025 13:21:38 +0800
Subject: [PATCH] netifd: Support DHCP option 138 and DHCP option 224
---
.../netifd/files/lib/netifd/dhcp.script | 10 ++++++++++
.../patches/601-dhcp_opt138_opt224.patch | 20 +++++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 package/utils/busybox/patches/601-dhcp_opt138_opt224.patch
diff --git a/package/network/config/netifd/files/lib/netifd/dhcp.script b/package/network/config/netifd/files/lib/netifd/dhcp.script
index 6fcf139beb..9c4366f48b 100755
--- a/package/network/config/netifd/files/lib/netifd/dhcp.script
+++ b/package/network/config/netifd/files/lib/netifd/dhcp.script
@@ -4,6 +4,8 @@
. /lib/functions.sh
. /lib/netifd/netifd-proto.sh
+rm -rf /tmp/dhcp-option-*
+
set_classless_routes() {
local max=128
while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
@@ -111,6 +113,14 @@ case "$1" in
;;
esac
+if [ -n "${opt138}" ]; then
+ echo -n "${opt138}" > /tmp/dhcp-option-138
+fi
+
+if [ -n "${opt224}" ]; then
+ echo -n "${opt224}" > /tmp/dhcp-option-224
+fi
+
# user rules
[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user "$@"
for f in /etc/udhcpc.user.d/*; do
diff --git a/package/utils/busybox/patches/601-dhcp_opt138_opt224.patch b/package/utils/busybox/patches/601-dhcp_opt138_opt224.patch
new file mode 100644
index 0000000000..38e53be78c
--- /dev/null
+++ b/package/utils/busybox/patches/601-dhcp_opt138_opt224.patch
@@ -0,0 +1,20 @@
+--- a/networking/udhcp/common.c 2025-09-18 13:15:38.313248300 +0800
++++ b/networking/udhcp/common.c 2025-09-18 13:17:50.078418978 +0800
+@@ -55,6 +55,8 @@ const struct dhcp_optflag dhcp_optflags[
+ { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
+ //TODO: not a string, but a set of LASCII strings:
+ // { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
++ { OPTION_IP , 0x8A }, /* DHCP_OPT138 */
++ { OPTION_STRING , 0xE0 }, /* DHCP_OPT224 */
+ { OPTION_STRING , 0x64 }, /* DHCP_PCODE */
+ { OPTION_STRING , 0x65 }, /* DHCP_TCODE */
+ #if ENABLE_FEATURE_UDHCP_RFC3397
+@@ -124,6 +126,8 @@ const char dhcp_option_strings[] ALIGN1
+ "tftp" "\0" /* DHCP_TFTP_SERVER_NAME*/
+ "bootfile" "\0" /* DHCP_BOOT_FILE */
+ // "userclass" "\0" /* DHCP_USER_CLASS */
++ "opt138" "\0" /* DHCP_OPT138 */
++ "opt224" "\0" /* DHCP_OPT224 */
+ "tzstr" "\0" /* DHCP_PCODE */
+ "tzdbstr" "\0" /* DHCP_TCODE */
+ #if ENABLE_FEATURE_UDHCP_RFC3397
--
2.34.1