Re: [PATCH] usb: gadget: u_ether: Fix host MAC address case

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

 



On Tue, Apr 25, 2023 at 02:58:53PM +0200, Konrad Gräfe wrote:
> 
> As the CDC-ECM specification states the host MAC address must be sent to
> the host as an uppercase hexadecimal string:
>     The Unicode character is chosen from the set of values 30h through
>     39h and 41h through 46h (0-9 and A-F).
> 
> However, snprintf(.., "%pm", ..) generates a lowercase MAC address
> string. While most host drivers are tolerant to this, UsbNcm.sys on
> Windows 10 is not. Instead it uses a different MAC address with all
> bytes set to zero including and after the first byte containing a
> lowercase letter. On Windows 11 Microsoft fixed it, but apparently they
> did not backport the fix.
> 
> This change fixes the issue by upper-casing the MAC to comply with the
> specification.
> 
> Signed-off-by: Konrad Gräfe <k.graefe@xxxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/u_ether.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> 

> diff --git drivers/usb/gadget/function/u_ether.c drivers/usb/gadget/function/u_ether.c
> index 6956ad8ba8dd..49d29b04ef93 100644
> --- drivers/usb/gadget/function/u_ether.c
> +++ drivers/usb/gadget/function/u_ether.c
> @@ -958,6 +958,7 @@ EXPORT_SYMBOL_GPL(gether_get_host_addr);
>  int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len)
>  {
>  	struct eth_dev *dev;
> +	int i, slen;
>  
>  	if (len < 13)
>  		return -EINVAL;
> @@ -965,7 +966,14 @@ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len)
>  	dev = netdev_priv(net);
>  	snprintf(host_addr, len, "%pm", dev->host_mac);
>  
> -	return strlen(host_addr);
> +
> +	slen = strlen(host_addr);
> +
> +	for(i = 0; i < slen; i++) {
> +		host_addr[i] = toupper(host_addr[i]);
> +	}
> +
> +	return slen;
>  }
>  EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc);
>  
> 



Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch contains warnings and/or errors noticed by the
  scripts/checkpatch.pl tool.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux