From 0b85959efc97142388e4a67358bc9d0aef885abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= <mail@cgundogan.de> Date: Wed, 14 Dec 2016 14:17:14 +0100 Subject: [PATCH] Revert "netdev2_tap: return actual byte number on read request" This reverts commit 613bceeae3f24625940dec87f53060061d4f84ca. FIONREAD seems to be unsupported for tun/tap interfaces in Linux. --- cpu/native/include/cpu_conf.h | 5 +++++ cpu/native/netdev2_tap/netdev2_tap.c | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cpu/native/include/cpu_conf.h b/cpu/native/include/cpu_conf.h index 043a4e7df4..88c71d9c1e 100644 --- a/cpu/native/include/cpu_conf.h +++ b/cpu/native/include/cpu_conf.h @@ -55,6 +55,11 @@ extern "C" { */ #define NATIVE_ETH_PROTO 0x1234 +#if (defined(GNRC_PKTBUF_SIZE)) && (GNRC_PKTBUF_SIZE < 2048) +# undef GNRC_PKTBUF_SIZE +# define GNRC_PKTBUF_SIZE (2048) +#endif + #ifdef __cplusplus } #endif diff --git a/cpu/native/netdev2_tap/netdev2_tap.c b/cpu/native/netdev2_tap/netdev2_tap.c index 2c9e3a343b..c1fa605110 100644 --- a/cpu/native/netdev2_tap/netdev2_tap.c +++ b/cpu/native/netdev2_tap/netdev2_tap.c @@ -215,8 +215,6 @@ static int _recv(netdev2_t *netdev2, void *buf, size_t len, void *info) (void)info; if (!buf) { - int waiting_bytes; - if (len > 0) { /* no memory available in pktbuf, discarding the frame */ DEBUG("netdev2_tap: discarding the frame\n"); @@ -236,9 +234,9 @@ static int _recv(netdev2_t *netdev2, void *buf, size_t len, void *info) _continue_reading(dev); } - /* get number of waiting bytes at dev->tap_fd */ - real_ioctl(dev->tap_fd, FIONREAD, &waiting_bytes); - return waiting_bytes; + /* no way of figuring out packet size without racey buffering, + * so we return the maximum possible size */ + return ETHERNET_FRAME_LEN; } int nread = real_read(dev->tap_fd, buf, len); -- GitLab