Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

Commit

Permalink
Fix TUN/TAP operation with Linux kernel 3.19.
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrop72 committed Apr 9, 2015
1 parent 1cdcaf8 commit 92a2fc8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tuntap/BTap.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ static void fd_handler (BTap *o, int events)

// try reading into the buffer
int bytes = read(o->fd, o->output_packet, o->frame_mtu);
if (bytes < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
if (bytes <= 0) {
// Treat zero return value the same as EAGAIN.
// See: https://bugzilla.kernel.org/show_bug.cgi?id=96381
if (bytes == 0 || errno == EAGAIN || errno == EWOULDBLOCK) {
// retry later
break;
}
Expand Down Expand Up @@ -161,8 +163,9 @@ void output_handler_recv (BTap *o, uint8_t *data)

// attempt read
int bytes = read(o->fd, data, o->frame_mtu);
if (bytes < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
if (bytes <= 0) {
if (bytes == 0 || errno == EAGAIN || errno == EWOULDBLOCK) {
// See note about zero return in fd_handler.
// retry later in fd_handler
// remember packet
o->output_packet = data;
Expand Down

0 comments on commit 92a2fc8

Please sign in to comment.