tap: Don't risk truncating frames on full buffer in tap_pasta_input()
tap_pasta_input() keeps reading frames from the tap device until the buffer is full. However, this has an ugly edge case, when we get close to buffer full, we will provide just the remaining space as a read() buffer. If this is shorter than the next frame to read, the tap device will truncate the frame and discard the remainder. Adjust the code to make sure we always have room for a maximum size frame. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
d2a1dc744b
commit
a33ecafbd9
1 changed files with 2 additions and 2 deletions
4
tap.c
4
tap.c
|
@ -1076,8 +1076,8 @@ static void tap_pasta_input(struct ctx *c, const struct timespec *now)
|
|||
|
||||
tap_flush_pools();
|
||||
|
||||
for (n = 0; n < (ssize_t)TAP_BUF_BYTES; n += len) {
|
||||
len = read(c->fd_tap, pkt_buf + n, TAP_BUF_BYTES - n);
|
||||
for (n = 0; n <= (ssize_t)TAP_BUF_BYTES - ETH_MAX_MTU; n += len) {
|
||||
len = read(c->fd_tap, pkt_buf + n, ETH_MAX_MTU);
|
||||
|
||||
if (len == 0) {
|
||||
die("EOF on tap device, exiting");
|
||||
|
|
Loading…
Reference in a new issue