drivers/net/tun.c: Re-order all TUN/TAP driver state data. Not only was was with wasting memory due to alignement requirements, it was also causing network packet buffers to be improperly aligned causing problems because the network requires 16-bit packet buffer alignment for uint16_t accesses. This alignment problem was discovered by Alan Carvalho de Assis.

This commit is contained in:
Gregory Nutt 2019-02-24 09:43:30 -06:00
parent 11eb7ef4f8
commit 4d3dd73e57

View File

@ -129,9 +129,10 @@
struct tun_device_s
{
bool bifup; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
struct work_s work; /* For deferring poll work to the work queue */
bool bifup; /* true:ifup false:ifdown */
bool read_wait;
WDOG_ID txpoll; /* TX poll timer */
struct work_s work; /* For deferring poll work to the work queue */
FAR struct file *filep;
@ -139,15 +140,17 @@ struct tun_device_s
FAR struct pollfd *poll_fds;
#endif
bool read_wait;
uint8_t read_buf[CONFIG_NET_TUN_PKTSIZE];
size_t read_d_len;
uint8_t write_buf[CONFIG_NET_TUN_PKTSIZE];
size_t write_d_len;
sem_t waitsem;
sem_t read_wait_sem;
size_t read_d_len;
size_t write_d_len;
/* These packet buffer arrays required 16-bit alignment. That alignment
* is assured only by the preceding wide data types.
*/
uint8_t read_buf[CONFIG_NET_TUN_PKTSIZE];
uint8_t write_buf[CONFIG_NET_TUN_PKTSIZE];
/* This holds the information visible to the NuttX network */