Skip to content

Commit

Permalink
OS-7073 viona buffer merging stumbles over perfectly sized frames
Browse files Browse the repository at this point in the history
Reviewed by: Ryan Zezeski <rpz@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>
  • Loading branch information
pfmooney committed Jul 16, 2018
1 parent 7055f84 commit 2511836
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions usr/src/uts/i86pc/io/viona/viona.c
Expand Up @@ -102,7 +102,7 @@
* |---* ring worker thread begins execution |
* | |
* +-------------------------------------------->+
* | | ^
* | | ^
* | |
* | * If ring shutdown is requested (by ioctl or impending
* | bhyve process death) while the worker thread is
Expand Down Expand Up @@ -1750,7 +1750,7 @@ viona_copy_mblk(const mblk_t *mp, size_t seek, caddr_t buf, size_t len,

/* Seek past already-consumed data */
while (seek > 0 && mp != NULL) {
size_t chunk = MBLKL(mp);
const size_t chunk = MBLKL(mp);

if (chunk > seek) {
off = seek;
Expand All @@ -1769,17 +1769,31 @@ viona_copy_mblk(const mblk_t *mp, size_t seek, caddr_t buf, size_t len,
buf += to_copy;
len -= to_copy;

/*
* If all the remaining data in the mblk_t was copied, move on
* to the next one in the chain. Any seek offset applied to
* the first mblk copy is zeroed out for subsequent operations.
*/
if (chunk == to_copy) {
mp = mp->b_cont;
off = 0;
}
#ifdef DEBUG
else {
/*
* The only valid reason for the copy to consume less
* than the entire contents of the mblk_t is because
* the output buffer has been filled.
*/
ASSERT0(len);
}
#endif

/* Go no further if the buffer has been filled */
if (len == 0) {
break;
}

/*
* Any offset into the initially chosen mblk_t buffer is
* consumed on the first copy operation.
*/
off = 0;
mp = mp->b_cont;
}
*end = (mp == NULL);
return (copied);
Expand Down

0 comments on commit 2511836

Please sign in to comment.