Repository navigation
usbip: number endpoints per direction to keep addresses valid - #139
Conversation
|
@alexpevzner This PR makes usbip number endpoints separately for IN and OUT, like real devices, so printers with more than 15 endpoints get valid addresses and URBs reach the right interface. |
|
With this change, 2 different endpoints with the opposite direction may get the same endpoint number It breaks the logic around |
|
Looks that the entire logic around I'd start from the more comprehensive test coverage to make sure we will not break something there... |
|
Hi @alexpevzner on the replacement concern, As you suggested, I started with more test coverage.
The tests caught two existing bugs, which I fixed here too:
I also merged master and updated the #134 tests for the new numbering. All usbip tests pass with |
|
I've merged it and refactored a little bit after merge |
While testing the HP LaserJet MFP M426fdn model over USB/IP, I found that its last two interfaces (HP's "IPP Printer", 255/9/1) get invalid endpoint addresses:
0x90,0x11and0x92.The cause is that usbip numbers endpoints with one counter shared by IN and OUT. An endpoint number only has 4 bits (1–15), and this model has 18 endpoints (11 IN, 7 OUT), so the counter runs past 15. The real device is fine because USB numbers IN and OUT separately.
The host can only send a 4-bit endpoint number, so URBs meant for interface 6 arrive as ep 1/2 and land in HP SCAN's queues. Interface 5's IN endpoint can't be reached at all.
NewDevicedidn't catch it because it checked a different limit (32 total).What I changed:
NewDevicegives each endpoint a number once, with separate IN and OUT counters, and stores it on theEndpoint. The descriptor and the routing both use that number, so they can't disagree again.[16]*Endpointtables (IN and OUT) through a smalldev.endpoint(num, input)helper.NewDevicenow rejects more than 15 IN or 15 OUT endpoints, which is the real USB limit.I added
descriptor_test.go. It reads the configuration descriptor through the realServer.serve(), the way the kernel does on attach, then sends a URB to each advertised endpoint and checks that it lands on the right interface. It fails on master and passes with this change. I also updated the #133 tests to the new numbering. All usbip tests pass 3 runs in a row with-race.Heads-up: #134's test sends bulk OUT to ep 2, which becomes ep 1 with this change. I'll update whichever PR merges second.