Bug 99015 - usbredirtestclient does not work with 64bit ids
Summary: usbredirtestclient does not work with 64bit ids
Status: RESOLVED FIXED
Alias: None
Product: Spice
Classification: Unclassified
Component: usbredir (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Hans de Goede
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-07 09:36 UTC by Fabian Vogt
Modified: 2017-02-14 16:04 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Fabian Vogt 2016-12-07 09:36:21 UTC
I wrote a program that uses usbredirparser to connect to a usbredirhost.
However, when the 64bits_id capability is set, usbredirhost behaves unexpectedly. Although it recognizes the presence of the 64bits_ids cap, control packets get rejected because of length mismatches.
Everything works fine with 32bit ids.

Analyzing the TCP traffic shows that the packets are correct, so something goes wrong on the receiving side.

This can be reproduced with usbredirtestclient as well, which just hangs before  reaching the command prompt.
Comment 1 Hans de Goede 2016-12-07 09:46:03 UTC
Hi,

First of all please make sure you've a recent usbredir, this sounds a lot like a bug fixed by this commit:
https://cgit.freedesktop.org/spice/usbredir/commit/?id=931a41c1c92410639a0e76e6fdd07482f06e4578

Other then that all I can say is that it should work, and it does work for qemu as the usbredir client and spice-gtk as usbredir host, so if it does not work for you with a recent usbredir, I would advice you to double check your code.

Regards,

Hans
Comment 2 Fabian Vogt 2016-12-07 10:03:30 UTC
Thanks for the quick reply!

(In reply to Hans de Goede from comment #1)
> Hi,
> 
> First of all please make sure you've a recent usbredir, this sounds a lot
> like a bug fixed by this commit:
> https://cgit.freedesktop.org/spice/usbredir/commit/
> ?id=931a41c1c92410639a0e76e6fdd07482f06e4578

I'm using 0.7 here but I also tried 0.7.1 now, same issue:

usbredirparser: error invalid packet type 0 length: 0

if I just remove the 64bits cap, it works fine.

My program only sends a single packet after after init,
in the device_connect callback:

    usb_redir_control_packet_header header {
        .endpoint = 0x80,
        .request = 0x06, /* GET_DESCRIPTOR */
        .requesttype = 0x80,
        .status = usb_redir_success,
        .value = 0x100, /* DEVICE */
        .index = 0,
        .length = 18
    };

    usbredirparser_send_control_packet(priv.parser.get(), EP0_QUERY_ID, &header, NULL, 0);

> 
> Other then that all I can say is that it should work, and it does work for
> qemu as the usbredir client and spice-gtk as usbredir host, so if it does
> not work for you with a recent usbredir, I would advice you to double check
> your code.

It does work fine with QEMU, but as everything else I tested it with does not,
I'm fairly confident that this is a bug as even with usbredirtestclient it
does not behave as expected with the capability.
I had a look at testclient's code and it does not use anything which would
break with 64 bit ids.

> 
> Regards,
> 
> Hans
Comment 3 Hans de Goede 2017-02-14 11:26:52 UTC
Hi,

Sorry for being slow in getting back to you on this. So this was indeed a bug in the usbredirtestclient code, which I've just fixed:

https://cgit.freedesktop.org/spice/usbredir/commit/?id=6136599a9eb7f87dbbec8be17a6a41fb8487c3da

I assume this fix will also explain what you're likely doing wrong in your own code (which likely is the same thing).

Regards,

Hans
Comment 4 Fabian Vogt 2017-02-14 15:13:13 UTC
(In reply to Hans de Goede from comment #3)
> Hi,
> 
> Sorry for being slow in getting back to you on this. So this was indeed a
> bug in the usbredirtestclient code, which I've just fixed:
> 
> https://cgit.freedesktop.org/spice/usbredir/commit/
> ?id=6136599a9eb7f87dbbec8be17a6a41fb8487c3da

Thanks!

> I assume this fix will also explain what you're likely doing wrong in your
> own code (which likely is the same thing).

Looks like it indeed, it'll complain again if it's still broken :P

The documentation needs fixing though, currently it says (usbredirparser.h):

> /* Note this function should not be used before the hello_func callback has
>    been called (as it checks the usb_redir_cap_connect_device_version cap).
> */
> void usbredirparser_send_device_connect(struct usbredirparser *parser,
>     struct usb_redir_device_connect_header *device_connect);

Which implies that all other functions can be invoked before the hello
packet has been processed.

> 
> Regards,
> 
> Hans
Comment 5 Hans de Goede 2017-02-14 16:04:08 UTC
(In reply to Fabian Vogt from comment #4)
> The documentation needs fixing though, currently it says (usbredirparser.h):
> 
> > /* Note this function should not be used before the hello_func callback has
> >    been called (as it checks the usb_redir_cap_connect_device_version cap).
> > */
> > void usbredirparser_send_device_connect(struct usbredirparser *parser,
> >     struct usb_redir_device_connect_header *device_connect);
> 
> Which implies that all other functions can be invoked before the hello
> packet has been processed.

Yeah that comment is probably from before I added the 64 bit id support, patches welcome.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.