[openwrt/openwrt] comgt: ncm: select first available network interface for device

LEDE Commits lede-commits at lists.infradead.org
Sat Apr 16 05:25:03 PDT 2022


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/b2940bb8b2878ce193f2edaee3e7d4c44f4a2065

commit b2940bb8b2878ce193f2edaee3e7d4c44f4a2065
Author: Lech Perczak <lech.perczak at gmail.com>
AuthorDate: Thu Mar 31 21:16:22 2022 +0200

    comgt: ncm: select first available network interface for device
    
    Some modems expose multiple network interfaces on the same USB device,
    causing the connection setup script to fail, because glob matching in
    the detection phase causes 'ls' to output more than one interface name
    plus their base directories in sysfs. Avoid that by listing the
    directories explicitly and then selecting first available interface.
    This is the case for some variants of ZTE MF286R built-in modem, which
    exposes both RNDIS and CDC-ECM network interfaces, causing the
    connection setup to fail.
    
    Signed-off-by: Lech Perczak <lech.perczak at gmail.com>
---
 package/network/utils/comgt/files/ncm.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/package/network/utils/comgt/files/ncm.sh b/package/network/utils/comgt/files/ncm.sh
index 38a4ba7a0b..c3a06165ef 100644
--- a/package/network/utils/comgt/files/ncm.sh
+++ b/package/network/utils/comgt/files/ncm.sh
@@ -26,7 +26,7 @@ proto_ncm_init_config() {
 proto_ncm_setup() {
 	local interface="$1"
 
-	local manufacturer initialize setmode connect finalize devname devpath
+	local manufacturer initialize setmode connect finalize devname devpath ifpath
 
 	local device ifname  apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS
 	json_get_vars device ifname apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS
@@ -59,13 +59,14 @@ proto_ncm_setup() {
 		case "$devname" in
 		'tty'*)
 			devpath="$(readlink -f /sys/class/tty/$devname/device)"
-			ifname="$( ls "$devpath"/../../*/net )"
+			ifpath="$devpath/../../*/net"
 			;;
 		*)
 			devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)"
-			ifname="$( ls "$devpath"/net )"
+			ifpath="$devpath/net"
 			;;
 		esac
+		ifname="$(ls $(ls -1 -d $ifpath | head -n 1))"
 	}
 
 	[ -n "$ifname" ] || {




More information about the lede-commits mailing list