Skip to content

Commit

Permalink
Headers caching bugfix.
Browse files Browse the repository at this point in the history
My speculation of skipping IN TRANSFER CMD_SUBMIT packets was
wrong. Now all CMD_SUBMIT packet directions are being cached and
if a cache entry is overwritten (cache too small, ...), the cache
retrival returns original packet header direction value.
  • Loading branch information
spog authored and cezanne committed Feb 13, 2021
1 parent 3156daa commit 2c87ee4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions userspace/lib/usbip_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,9 @@ static inline UINT32 hdrs_cache_direction(struct usbip_header* usbip_hdr)
return hdrs_cache[idx].direction;
}
/*
* If not in cache, return IN direction, because we skip caching
* IN transfers!
* If not in cache, return what is in the header!
*/
return USBIP_DIR_IN;
return usbip_hdr->base.direction;
}

static int
Expand All @@ -321,9 +320,9 @@ get_xfer_len(BOOL is_req, struct usbip_header *hdr)
if (is_req) {
if (hdr->base.command == USBIP_CMD_UNLINK)
return 0;
hdrs_cache_insert(hdr);
if (hdr->base.direction)
return 0;
hdrs_cache_insert(hdr);
return hdr->u.cmd_submit.transfer_buffer_length;
}
else {
Expand Down

0 comments on commit 2c87ee4

Please sign in to comment.