diff options
author | Dimitri Staessens <dimitri.staessens@ugent.be> | 2018-12-07 19:26:27 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2018-12-08 10:08:07 +0100 |
commit | 933aa5ab479732d84b3331ef4638dd9be07695b2 (patch) | |
tree | 9f6b374e7c15470eca446f16b9e7e546cc8c6727 /src/ipcpd/eth/eth.c | |
parent | 158db8f8f89c03b9c62cf8259bad6f5e7d4f57c0 (diff) | |
download | ouroboros-933aa5ab479732d84b3331ef4638dd9be07695b2.tar.gz ouroboros-933aa5ab479732d84b3331ef4638dd9be07695b2.zip |
ipcpd: Wait for buffer when writing to Eth device
This will cause the Ethernet IPCP to wait for a free buffer when using
raw sockets to avoid packet drops when the network is congested.
Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/ipcpd/eth/eth.c')
-rw-r--r-- | src/ipcpd/eth/eth.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c index 3a749cf7..f9691626 100644 --- a/src/ipcpd/eth/eth.c +++ b/src/ipcpd/eth/eth.c @@ -380,6 +380,11 @@ static int eth_ipcp_send_frame(const uint8_t * dst_addr, uint8_t cf = 0x03; #endif struct eth_frame * e_frame; +#ifdef HAVE_RAW_SOCKETS + fd_set fds; + + FD_ZERO(&fds); +#endif assert(frame); @@ -424,13 +429,20 @@ static int eth_ipcp_send_frame(const uint8_t * dst_addr, } #elif defined(HAVE_RAW_SOCKETS) + FD_SET(eth_data.s_fd, &fds); + if (select(eth_data.s_fd + 1, NULL, &fds, NULL, NULL) < 0) { + log_dbg("Select() failed: %s.", strerror(errno)); + return -1; + } + assert(FD_ISSET(eth_data.s_fd, &fds)); + if (sendto(eth_data.s_fd, frame, frame_len, 0, (struct sockaddr *) ð_data.device, sizeof(eth_data.device)) <= 0) { - log_dbg("Failed to send message."); + log_dbg("Failed to send message: %s.", strerror(errno)); return -1; } #endif /* HAVE_NETMAP */ |