From d2bd7480d1306eecf97118487109de0ba5bff1ad Mon Sep 17 00:00:00 2001 From: Tanya Singh Date: Tue, 28 Jun 2022 17:11:52 +0800 Subject: [PATCH 21/43] netifd: Support DHCP option 138 and store values in /tmp/capwap/dhcp_opt.txt Signed-off-by: Tanya Singh --- .../netifd/files/lib/netifd/dhcp.script | 22 +++++++++++++++++++ .../netifd/files/lib/netifd/proto/dhcp.sh | 1 + .../busybox/patches/531-dhcp_opt_capwap.patch | 18 +++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 package/utils/busybox/patches/531-dhcp_opt_capwap.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..29de85f221 100755 --- a/package/network/config/netifd/files/lib/netifd/dhcp.script +++ b/package/network/config/netifd/files/lib/netifd/dhcp.script @@ -4,6 +4,24 @@ . /lib/functions.sh . /lib/netifd/netifd-proto.sh +WORKING_PATH=/tmp/capwap +DHCP_OPT_FILE=${WORKING_PATH}/dhcp_opt.txt +DHCP_OPT_FILE_TMP=${WORKING_PATH}/dhcp_opt_tmp.txt + +set_capwap_ip() +{ + local ip + if [ ! -d "${WORKING_PATH}" ]; then + mkdir -p ${WORKING_PATH} + fi + for ip in ${capwap}; do + echo -n ${ip} >> ${DHCP_OPT_FILE_TMP} + done + if ! cmp -s "${DHCP_OPT_FILE}" "${DHCP_OPT_FILE_TMP}"; then + mv ${DHCP_OPT_FILE_TMP} ${DHCP_OPT_FILE} + fi +} + set_classless_routes() { local max=128 while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do @@ -111,6 +129,10 @@ case "$1" in ;; esac +if [ -n "${capwap}" ]; then + set_capwap_ip +fi + # user rules [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user "$@" for f in /etc/udhcpc.user.d/*; do diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh index 636b4654ff..18a9aaf2a3 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -61,6 +61,7 @@ proto_dhcp_setup() { [ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0" # Request classless route option (see RFC 3442) by default [ "$classlessroute" = "0" ] || append dhcpopts "-O 121" + append dhcpopts "-O 138" proto_export "INTERFACE=$config" proto_run_command "$config" udhcpc \ diff --git a/package/utils/busybox/patches/531-dhcp_opt_capwap.patch b/package/utils/busybox/patches/531-dhcp_opt_capwap.patch new file mode 100644 index 0000000000..6c60159555 --- /dev/null +++ b/package/utils/busybox/patches/531-dhcp_opt_capwap.patch @@ -0,0 +1,18 @@ +--- a/networking/udhcp/common.c 2022-06-28 09:32:48.853072914 +0800 ++++ b/networking/udhcp/common.c 2022-06-28 09:39:28.000000000 +0800 +@@ -54,6 +54,7 @@ + { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */ + //TODO: not a string, but a set of LASCII strings: + // { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */ ++ { OPTION_IP | OPTION_LIST , 0x8A }, /* DHCP_CAPWAP */ + { OPTION_STRING , 0x64 }, /* DHCP_PCODE */ + { OPTION_STRING , 0x65 }, /* DHCP_TCODE */ + #if ENABLE_FEATURE_UDHCP_RFC3397 +@@ -123,6 +124,7 @@ + "tftp" "\0" /* DHCP_TFTP_SERVER_NAME*/ + "bootfile" "\0" /* DHCP_BOOT_FILE */ + // "userclass" "\0" /* DHCP_USER_CLASS */ ++ "capwap" "\0" /* DHCP_CAPWAP */ + "tzstr" "\0" /* DHCP_PCODE */ + "tzdbstr" "\0" /* DHCP_TCODE */ + #if ENABLE_FEATURE_UDHCP_RFC3397 -- 2.34.1