Skip to content

Commit

Permalink
Fix issue with data transfer thread unexpectedly stopping. Ref GNS3/g…
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Mar 27, 2020
1 parent 79d65bc commit 95cdb49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/hypervisor_iol_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void *iol_nio_listener(void *data)
drop_packet = FALSE;
bytes_received = nio_recv(nio, &pkt[IOL_HDR_SIZE], MAX_MTU);
if (bytes_received == -1) {
perror("recv");
if (errno == ECONNREFUSED || errno == ENETDOWN)
continue;
perror("recv");
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -126,9 +126,9 @@ void *iol_nio_listener(void *data)
memcpy(pkt, &(iol_nio->header), sizeof(iol_nio->header));
bytes_sent = sendto(iol_nio->iol_bridge_sock, pkt, bytes_received, 0, (struct sockaddr *)&iol_nio->iol_sockaddr, sizeof(iol_nio->iol_sockaddr));
if (bytes_sent == -1) {
perror("sendto");
if (errno == ECONNREFUSED || errno == ENETDOWN || errno == ENOENT)
continue;
perror("sendto");
exit(EXIT_FAILURE);
}
}
Expand All @@ -153,9 +153,9 @@ void *iol_bridge_listener(void *data)
drop_packet = FALSE;
bytes_received = read(bridge->iol_bridge_sock, pkt, IOL_HDR_SIZE + MAX_MTU);
if (bytes_received == -1) {
perror("recv");
if (errno == ECONNREFUSED || errno == ENETDOWN)
continue;
perror("recv");
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -205,12 +205,12 @@ void *iol_bridge_listener(void *data)
nio->packets_out++;
nio->bytes_out += bytes_sent;
if (bytes_sent == -1) {
perror("send");

/* EINVAL can be caused by sending to a blackhole route, this happens if a NIC link status changes */
if (errno == ECONNREFUSED || errno == ENETDOWN || errno == EINVAL)
continue;

perror("send");
exit(EXIT_FAILURE);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ static int bridge_nios(nio_t *rx_nio, nio_t *tx_nio, bridge_t *bridge)
drop_packet = FALSE;
bytes_received = nio_recv(rx_nio, &pkt, NIO_MAX_PKT_SIZE);
if (bytes_received == -1) {
perror("recv");
if (errno == ECONNREFUSED || errno == ENETDOWN)
continue;
perror("recv");
return -1;
}

Expand Down Expand Up @@ -106,7 +106,6 @@ static int bridge_nios(nio_t *rx_nio, nio_t *tx_nio, bridge_t *bridge)
/* send what we received to the transmitting NIO */
bytes_sent = nio_send(tx_nio, pkt, bytes_received);
if (bytes_sent == -1) {
perror("send");

/* EINVAL can be caused by sending to a blackhole route, this happens if a NIC link status changes */
if (errno == ECONNREFUSED || errno == ENETDOWN || errno == EINVAL)
Expand All @@ -117,12 +116,14 @@ static int bridge_nios(nio_t *rx_nio, nio_t *tx_nio, bridge_t *bridge)
if (tx_nio->type == NIO_TYPE_TAP && errno == EIO)
continue;

perror("send");
return -1;
}

tx_nio->packets_out++;
tx_nio->bytes_out += bytes_sent;
}

return 0;
}

Expand Down

0 comments on commit 95cdb49

Please sign in to comment.