Module Name:    src
Committed By:   skrll
Date:           Sun Oct  1 06:55:27 UTC 2023

Modified Files:
        src/sys/dev/usb: if_urndis.c

Log Message:
Apply the new diff from

kern/55273 urndis(4) error "could not find data bulk in/out" without CDC union 
descriptor

Fallback to the interface association descriptor if  no CDC Union Descriptor is
found.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/usb/if_urndis.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urndis.c
diff -u src/sys/dev/usb/if_urndis.c:1.48 src/sys/dev/usb/if_urndis.c:1.49
--- src/sys/dev/usb/if_urndis.c:1.48	Sat Feb 11 22:42:49 2023
+++ src/sys/dev/usb/if_urndis.c	Sun Oct  1 06:55:27 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urndis.c,v 1.48 2023/02/11 22:42:49 nia Exp $ */
+/*	$NetBSD: if_urndis.c,v 1.49 2023/10/01 06:55:27 skrll Exp $ */
 /*	$OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.48 2023/02/11 22:42:49 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.49 2023/10/01 06:55:27 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -901,8 +901,9 @@ urndis_attach(device_t parent, device_t 
 	struct usbd_interface		*iface_ctl;
 	const usb_cdc_union_descriptor_t *ud;
 	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;
 	void				*buf;
 	size_t				 bufsz;
@@ -934,10 +935,23 @@ urndis_attach(device_t parent, device_t 
 	if_ctl = id->bInterfaceNumber;
 	sc->sc_ifaceno_ctl = if_ctl;
 	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) {
 			continue;
 		}
@@ -950,6 +964,8 @@ urndis_attach(device_t parent, device_t 
 			break;
 		}
 	}
+	if (if_data == -1 && if_data_ia != -1)
+		if_data = if_data_ia;
 
 	if (if_data == -1) {
 		DPRINTF(("urndis_attach: no union interface\n"));

Reply via email to