NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/55273



The following reply was made to PR kern/55273; it has been noted by GNATS.

From: Reinhard Speyerer <rspmn%arcor.de@localhost>
To: gnats-bugs%netbsd.org@localhost
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
 



Home | Main Index | Thread Index | Old Index