NetBSD Problem Report #55273

From www@netbsd.org  Mon May 18 18:03:34 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C848D1A9217
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 18 May 2020 18:03:34 +0000 (UTC)
Message-Id: <20200518180334.0887A1A921E@mollari.NetBSD.org>
Date: Mon, 18 May 2020 18:03:34 +0000 (UTC)
From: rspmn@arcor.de
Reply-To: rspmn@arcor.de
To: gnats-bugs@NetBSD.org
Subject: urndis(4) error "could not find data bulk in/out" without CDC union descriptor
X-Send-Pr-Version: www-1.0

>Number:         55273
>Category:       kern
>Synopsis:       urndis(4) error "could not find data bulk in/out" without CDC union descriptor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    skrll
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 18 18:05:00 +0000 2020
>Last-Modified:  Tue Aug 29 21:00:01 +0000 2023
>Originator:     Reinhard Speyerer
>Release:        NetBSD 9.0
>Organization:
>Environment:
NetBSD netbsd 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
urndis(4) returns
"autoconfiguration error: urndis0: could not find data bulk in/out"
when the corresponing CDC union descriptor is missing which seems
to be quite common for many current devices.

Obtain the corresponding information from the interface association
as it is already done in the umb(4) driver instead of adding each new
device without a CDC union descriptor to the urndis_devs table in the driver.
>How-To-Repeat:
Connect a device with a RNDIS interface which does not have a CDC union
descriptor  (e.g. Alcatel Onetouch L850V) to a USB port and check dmesg(1)
output:

[   119.859971] urndis0 at uhub4 port 6 configuration 1 interface 0
[   119.859971] urndis0: Alcatel (0x1bbb) MobileBroadBand (0x195), rev 2.01/2.28, addr 2
[   119.859971] autoconfiguration error: urndis0: could not find data bulk in
[   119.859971] autoconfiguration error: urndis0: could not find data bulk out
[   119.859971] umass0 at uhub4 port 6 configuration 1 interface 2
[   119.859971] umass0: Alcatel (0x1bbb) MobileBroadBand (0x195), rev 2.01/2.28, addr 2
[   119.859971] umass0: using SCSI over Bulk-Only
[   119.869972] scsibus0 at umass0: 2 targets, 1 lun per target
[   119.869972] sd0 at scsibus0 target 0 lun 0: <ONETOUCH, ESTORIL, 2.31> disk removable
[   119.869972] sd0: drive offline

>Fix:
Apply this patch

--- if_urndis.c.orig	2019-09-13 08:51:58.000000000 +0200
+++ if_urndis.c	2020-05-18 08:09:06.000000000 +0200
@@ -923,2 +923,3 @@
 	const usb_cdc_union_descriptor_t *ud;
+	const usb_interface_assoc_descriptor_t *ad;
 	const usb_cdc_header_descriptor_t *desc;
@@ -961,2 +962,9 @@

+		if (desc->bDescriptorType == UDESC_INTERFACE_ASSOC) {
+			ad = (const usb_interface_assoc_descriptor_t *)desc;
+			if (ad->bFirstInterface == if_ctl &&
+			    ad->bInterfaceCount > 1)
+				if_data = if_ctl + 1;
+			continue;
+		}
 		if (desc->bDescriptorType != UDESC_CS_INTERFACE) {

to the NetBSD 9.0 sources and rebuild the kernel. After reboot and
switching to the USB composition with the RNDIS interface:

[    88.189468] urndis0 at uhub4 port 6 configuration 1 interface 0
[    88.189468] urndis0: Alcatel (0x1bbb) MobileBroadBand (0x195), rev 2.01/2.28, addr 2
[    88.209470] urndis0: Ethernet address a6:27:cc:ab:d9:ae
[    88.209470] umass0 at uhub4 port 6 configuration 1 interface 2
[    88.209470] umass0: Alcatel (0x1bbb) MobileBroadBand (0x195), rev 2.01/2.28, addr 2
[    88.209470] umass0: using SCSI over Bulk-Only
[    88.209470] scsibus0 at umass0: 2 targets, 1 lun per target
[    88.209470] sd0 at scsibus0 target 0 lun 0: <ONETOUCH, ESTORIL, 2.31> disk removable
[    88.209470] sd0: drive offline

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->skrll
Responsible-Changed-By: skrll@NetBSD.org
Responsible-Changed-When: Mon, 18 May 2020 19:22:16 +0000
Responsible-Changed-Why:
take


From: Reinhard Speyerer <rspmn@arcor.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/55273
Date: Tue, 29 Aug 2023 22:54:45 +0200

 Here is a if_urndis.c 1.48 patch which avoids potential regressions by
 only using the data interface from the Interface Association Descriptor
 if no CDC Union Descriptor is found:

 --- if_urndis.c.orig	2023-07-30 19:45:17.000000000 +0200
 +++ if_urndis.c	2023-08-29 22:12:10.000000000 +0200
 @@ -903,4 +903,5 @@
  	const usb_cdc_header_descriptor_t *desc;
 +	const usb_interface_assoc_descriptor_t *ad;
  	usbd_desc_iter_t		 iter;
 -	int				 if_ctl, if_data;
 +	int				 if_ctl, if_data, if_data_ia;
  	int				 i, j, altcnt;
 @@ -936,6 +937,19 @@
  	if_data = -1;
 +	if_data_ia = -1;

 +	/*
 +	 * Use a matching Interface Association Descriptor
 +	 * as a fallback if no CDC Union Descriptor is found.
 +	 */
  	usb_desc_iter_init(un->un_udev, &iter);
  	while ((desc = (const void *)usb_desc_iter_next(&iter)) != NULL) {
 -
 +		if (desc->bDescriptorType == UDESC_INTERFACE_ASSOC) {
 +			if (desc->bLength < sizeof(*ad))
 +				continue;
 +			ad = (const usb_interface_assoc_descriptor_t *)desc;
 +			if (ad->bFirstInterface == if_ctl &&
 +			    ad->bInterfaceCount > 1)
 +				if_data_ia = if_ctl + 1;
 +			continue;
 +		}
  		if (desc->bDescriptorType != UDESC_CS_INTERFACE) {
 @@ -952,2 +966,4 @@
  	}
 +	if (if_data == -1 && if_data_ia != -1)
 +		if_data = if_data_ia;

 netbsd# eject cd1
 netbsd# dmesg | tail -14
 [  5627.204988] sd0: detached
 [  5627.204988] cd1: detached
 [  5627.204988] scsibus0: detached
 [  5627.204988] umass0: detached
 [  5627.204988] umass0: at uhub3 port 2 (addr 2) disconnected
 [  5628.885014] urndis0 at uhub3 port 2 configuration 1 interface 0
 [  5628.885014] urndis0: Alcatel (0x1bbb) MobileBroadBand (0x195), rev 2.01/2.28, addr 2
 [  5628.895015] urndis0: Ethernet address 42:2e:27:5e:7f:30
 [  5628.895015] umass0 at uhub3 port 2 configuration 1 interface 2
 [  5628.895015] umass0: Alcatel (0x1bbb) MobileBroadBand (0x195), rev 2.01/2.28, addr 2
 [  5628.895015] umass0: using SCSI over Bulk-Only
 [  5628.895015] scsibus0 at umass0: 2 targets, 1 lun per target
 [  5628.905017] sd0 at scsibus0 target 0 lun 0: <ONETOUCH, ESTORIL, 2.31> disk removable
 [  5628.905017] sd0: drive offline
 netbsd# ifconfig urndis0 192.168.1.2 up
 netbsd# ping -c 3 192.168.1.1
 PING 192.168.1.1 (192.168.1.1): 56 data bytes
 64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=4.629637 ms
 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.956267 ms
 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.951238 ms

 ----192.168.1.1 PING Statistics----
 3 packets transmitted, 3 packets received, 0.0% packet loss
 round-trip min/avg/max/stddev = 0.951238/2.179047/4.629637/2.122274 ms

 Regards,
 Reinhard

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.