From 8a2b243c083f700e68877f46245c1ac22e64fdbd Mon Sep 17 00:00:00 2001 From: Rajkamal CV Date: Tue, 2 Jun 2026 17:16:49 +0530 Subject: [PATCH 1/3] LTE-2904: Set ipv4_br-home_ipaddr sysevent --- .../init/c_registration/15_ssh_server.c | 3 + source/scripts/init/service.d/service_sshd.sh | 95 +++++++++++++++---- 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/source/scripts/init/c_registration/15_ssh_server.c b/source/scripts/init/c_registration/15_ssh_server.c index 6143ee73..dba2bd5a 100644 --- a/source/scripts/init/c_registration/15_ssh_server.c +++ b/source/scripts/init/c_registration/15_ssh_server.c @@ -50,6 +50,9 @@ const char* SERVICE_CUSTOM_EVENTS[] = { #endif #if defined(_ARRIS_XB6_PRODUCT_REQ_) "wan-status|/etc/utopia/service.d/service_sshd.sh", +#endif +#if defined(_WNXL11BWL_PRODUCT_REQ_) + "ipv4_br-home_ipaddr|/etc/utopia/service.d/service_sshd.sh", #endif NULL }; diff --git a/source/scripts/init/service.d/service_sshd.sh b/source/scripts/init/service.d/service_sshd.sh index a2ba75cc..b9360e58 100755 --- a/source/scripts/init/service.d/service_sshd.sh +++ b/source/scripts/init/service.d/service_sshd.sh @@ -134,6 +134,30 @@ get_listen_params() { fi } +# wait_for_iface_ip +# Blocks up to 300 seconds (150 x 2s) waiting for an IPv4 address on the +# given interface. Prints the IP to stdout on success; logs an error and +# returns 1 on timeout. +wait_for_iface_ip() { + local IFACE="$1" + local SLEEP_INTERVAL=2 + local RETRIES=0 + local MAX_RETRIES=150 + local WAITED_IP + while [ $RETRIES -lt $MAX_RETRIES ]; do + WAITED_IP=`ip -4 addr show dev "$IFACE" scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` + if [ -n "$WAITED_IP" ]; then + echo_t "[utopia] $IFACE got IP $WAITED_IP after $((RETRIES * SLEEP_INTERVAL)) seconds" >&2 + echo "$WAITED_IP" + return 0 + fi + RETRIES=$((RETRIES + 1)) + sleep $SLEEP_INTERVAL + done + echo_t "[utopia] ERROR: Timed out waiting for IP on $IFACE after $((MAX_RETRIES * SLEEP_INTERVAL)) seconds" >&2 + return 1 +} + do_start() { #DIR_NAME=/tmp/home/admin #if [ ! -d $DIR_NAME ] ; then @@ -195,31 +219,42 @@ do_start() { commandString="$commandString -p [$CM_IPV6]:22" fi fi - elif [ "$BOX_TYPE" = "SCER11BEL" -a "$LANIPV6Support" = "true" ]; then - # In IPv6 only case (MAP-T), and if IPv6 GUA on LAN enabled case, use brlan0 interface to get v6 global address. - CM_IPV6=`ip -6 addr show dev brlan0 scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` - if [ ! -z "$CM_IPV6" ]; then - commandString="$commandString -p [$CM_IPV6]:22" - fi - - # Check IPv4 address. - CM_IPV4=`ip -4 addr show dev $CMINTERFACE scope global | awk '/inet/{print $2}' | cut -d '/' -f1` - if [ ! -z "$CM_IPV4" ]; then - commandString="$commandString -p [$CM_IPV4]:22" - fi elif [ "$BOX_TYPE" = "WNXL11BWL" ]; then - CM_IP=`ip -4 addr show dev $CMINTERFACE scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` - if [ ! -z $CM_IP ]; then - commandString="$commandString -p [$CM_IP]:22" - fi + commandString="" CM_IPv6=`ip -6 addr show dev wwan0 scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` - if [ ! -z $CM_IPv6 ]; then + if [ ! -z "$CM_IPv6" ]; then commandString="$commandString -p [$CM_IPv6]:22" fi CM_IPv4=`ip -4 addr show dev wwan0 scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` - if [ ! -z $CM_IPv4 ]; then + if [ ! -z "$CM_IPv4" ]; then commandString="$commandString -p [$CM_IPv4]:22" fi + if [ "$CMINTERFACE" != "wwan0" ]; then + BRHOME_IP=`sysevent get ipv4_br-home_ipaddr` + echo_t "BRHOME_IP = $BRHOME_IP" + CM_IP=`ip -4 addr show dev "$CMINTERFACE" scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` + if [ ! -z "$CM_IP" ]; then + commandString="$commandString -p [$CM_IP]:22" + else + DEVICE_MODE=`deviceinfo.sh -mode` + if [ "$DEVICE_MODE" = "Extender" ]; then + MESH_WAN_STATUS=`sysevent get mesh_wan_linkstatus` + if [ "$MESH_WAN_STATUS" = "up" ]; then + echo_t "[utopia] $CMINTERFACE has no IP (Extender mode, mesh WAN up), waiting up to 300s" + CM_IP=`wait_for_iface_ip "$CMINTERFACE"` + if [ -n "$CM_IP" ]; then + commandString="$commandString -p [$CM_IP]:22" + else + echo_t "[utopia] ERROR: $CMINTERFACE did not get an IP after 300s, dropbear will start without it" + fi + else + echo_t "[utopia] $CMINTERFACE has no IP and mesh_wan_linkstatus is not up, skipping wait" + fi + else + echo_t "[utopia] $CMINTERFACE has no IP and device is not in Extender mode, skipping wait" + fi + fi + fi else CM_IP="" if ([ "$BOX_TYPE" = "rpi" ] || [ "$BOX_TYPE" = "bpi" ]) ;then @@ -270,8 +305,6 @@ do_start() { if ([ "$MANUFACTURE" = "Technicolor" ] || [ "$MODEL_NUM" = "SG417DBCT" ] || [ "$BOX_TYPE" = "WNXL11BWL" ]) ; then echo_t "dropbear -E -s -K 60 -b /etc/sshbanner.txt ${commandString} -r ${DROPBEAR_PARAMS_1} -r ${DROPBEAR_PARAMS_2} -a -P ${PID_FILE}" dropbear -E -s -b /etc/sshbanner.txt $commandString -r $DROPBEAR_PARAMS_1 -r $DROPBEAR_PARAMS_2 -a -P $PID_FILE -K 60 $USE_DEVKEYS 2>>$CONSOLEFILE - elif [ "$BOX_TYPE" = "SCER11BEL" -a "$LANIPV6Support" = "true" ]; then - dropbear -E -s -b /etc/sshbanner.txt $commandString -r $DROPBEAR_PARAMS_1 -r $DROPBEAR_PARAMS_2 -a -P $PID_FILE -K 60 $USE_DEVKEYS 2>>$CONSOLEFILE else dropbear -E -s -b /etc/sshbanner.txt -a -r $DROPBEAR_PARAMS_1 -r $DROPBEAR_PARAMS_2 -p [$CM_IP]:22 -P $PID_FILE $USE_DEVKEYS 2>>$CONSOLEFILE fi @@ -452,9 +485,29 @@ case "$1" in service_stop service_start ;; + mesh_wan_linkstatus) + if [ "$BOX_TYPE" = "WNXL11BWL" ] && [ "$2" = "up" ]; then + DEVICE_MODE=`deviceinfo.sh -mode` + if [ "$DEVICE_MODE" = "Extender" ]; then + echo_t "commented out intentionall" + #service_stop + #service_start + fi + fi + ;; + ipv4_br-home_ipaddr) + if [ "$BOX_TYPE" = "WNXL11BWL" ]; then + echo_t "ipv4_br-home_ipaddr is set with $2" + DEVICE_MODE=`deviceinfo.sh -mode` + if [ "$DEVICE_MODE" = "Extender" ]; then + service_stop + service_start + fi + fi + ;; *) - echo "Usage: $SELF_NAME [${SERVICE_NAME}-start|${SERVICE_NAME}-stop|${SERVICE_NAME}-restart|ssh_server_restart|lan-status|wan-status]" >&2 + echo "Usage: $SELF_NAME [${SERVICE_NAME}-start|${SERVICE_NAME}-stop|${SERVICE_NAME}-restart|wan-status|bridge-status|current_wan_ifname|mesh_wan_linkstatus ]" >&2 exit 3 ;; esac From ad32128f298e0abcb778c6960c93c0ad9f690e6e Mon Sep 17 00:00:00 2001 From: Rajkamal CV Date: Mon, 8 Jun 2026 13:02:08 +0530 Subject: [PATCH 2/3] LTE-2904: Set ipv4_br-home_dhcp_ipaddr sysevent --- .../init/c_registration/15_ssh_server.c | 2 +- source/scripts/init/service.d/service_sshd.sh | 40 +++++++------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/source/scripts/init/c_registration/15_ssh_server.c b/source/scripts/init/c_registration/15_ssh_server.c index dba2bd5a..430db48a 100644 --- a/source/scripts/init/c_registration/15_ssh_server.c +++ b/source/scripts/init/c_registration/15_ssh_server.c @@ -52,7 +52,7 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "wan-status|/etc/utopia/service.d/service_sshd.sh", #endif #if defined(_WNXL11BWL_PRODUCT_REQ_) - "ipv4_br-home_ipaddr|/etc/utopia/service.d/service_sshd.sh", + "ipv4_br-home_dhcp_ipaddr|/etc/utopia/service.d/service_sshd.sh", #endif NULL }; diff --git a/source/scripts/init/service.d/service_sshd.sh b/source/scripts/init/service.d/service_sshd.sh index b9360e58..f97f84fa 100755 --- a/source/scripts/init/service.d/service_sshd.sh +++ b/source/scripts/init/service.d/service_sshd.sh @@ -229,31 +229,21 @@ do_start() { if [ ! -z "$CM_IPv4" ]; then commandString="$commandString -p [$CM_IPv4]:22" fi - if [ "$CMINTERFACE" != "wwan0" ]; then - BRHOME_IP=`sysevent get ipv4_br-home_ipaddr` - echo_t "BRHOME_IP = $BRHOME_IP" - CM_IP=`ip -4 addr show dev "$CMINTERFACE" scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` - if [ ! -z "$CM_IP" ]; then + if [ "$CMINTERFACE" = "br-home" ]; then + CM_IP=`sysevent get ipv4_br-home_dhcp_ipaddr` + echo_t "[utopia] ipv4_br-home_dhcp_ipaddr = $CM_IP" + if [ -n "$CM_IP" ] && [ "$CM_IP" != "0.0.0.0" ]; then commandString="$commandString -p [$CM_IP]:22" else - DEVICE_MODE=`deviceinfo.sh -mode` - if [ "$DEVICE_MODE" = "Extender" ]; then - MESH_WAN_STATUS=`sysevent get mesh_wan_linkstatus` - if [ "$MESH_WAN_STATUS" = "up" ]; then - echo_t "[utopia] $CMINTERFACE has no IP (Extender mode, mesh WAN up), waiting up to 300s" - CM_IP=`wait_for_iface_ip "$CMINTERFACE"` - if [ -n "$CM_IP" ]; then - commandString="$commandString -p [$CM_IP]:22" - else - echo_t "[utopia] ERROR: $CMINTERFACE did not get an IP after 300s, dropbear will start without it" - fi - else - echo_t "[utopia] $CMINTERFACE has no IP and mesh_wan_linkstatus is not up, skipping wait" - fi - else - echo_t "[utopia] $CMINTERFACE has no IP and device is not in Extender mode, skipping wait" - fi - fi + echo_t "[utopia] ipv4_br-home_dhcp_ipaddr not set or invalid ($CM_IP), skipping $CMINTERFACE listen address" + fi + else + CM_IP=`ip -4 addr show dev "$CMINTERFACE" scope global | awk '/inet/{print $2}' | cut -d '/' -f1 | head -n1` + if [ -n "$CM_IP" ]; then + commandString="$commandString -p [$CM_IP]:22" + else + echo_t "[utopia] $CMINTERFACE has no IPv4 address, skipping listen address" + fi fi else CM_IP="" @@ -495,9 +485,9 @@ case "$1" in fi fi ;; - ipv4_br-home_ipaddr) + ipv4_br-home_dhcp_ipaddr) if [ "$BOX_TYPE" = "WNXL11BWL" ]; then - echo_t "ipv4_br-home_ipaddr is set with $2" + echo_t "ipv4_br-home_dhcp_ipaddr is set with $2" DEVICE_MODE=`deviceinfo.sh -mode` if [ "$DEVICE_MODE" = "Extender" ]; then service_stop From e861c6fc0813dddb6ad692b8f6e6489f56f77af9 Mon Sep 17 00:00:00 2001 From: rajkamal-cv <72071311+rajkamal-cv@users.noreply.github.com> Date: Wed, 10 Jun 2026 14:20:58 +0530 Subject: [PATCH 3/3] Update 15_ssh_server.c --- source/scripts/init/c_registration/15_ssh_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/scripts/init/c_registration/15_ssh_server.c b/source/scripts/init/c_registration/15_ssh_server.c index 430db48a..c3a693b3 100644 --- a/source/scripts/init/c_registration/15_ssh_server.c +++ b/source/scripts/init/c_registration/15_ssh_server.c @@ -52,7 +52,7 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "wan-status|/etc/utopia/service.d/service_sshd.sh", #endif #if defined(_WNXL11BWL_PRODUCT_REQ_) - "ipv4_br-home_dhcp_ipaddr|/etc/utopia/service.d/service_sshd.sh", + "ipv4_br-home_dhcp_ipaddr|/etc/utopia/service.d/service_sshd.sh|NULL|"TUPLE_FLAG_EVENT, #endif NULL };