drivers/net/tun.c: Packet buffer size should include the configured GUARD_SIZE. And, given how the buffers are allocated, the allocation size must be an even number of 16-bit values to preserve alignment.

This commit is contained in:
Gregory Nutt 2019-02-24 09:52:18 -06:00
parent 4d3dd73e57
commit 3502425221
1 changed files with 8 additions and 2 deletions

View File

@ -102,6 +102,12 @@
# define CONFIG_TUN_NINTERFACES 1
#endif
/* Make sure that packet buffers include in configured guard size and are an
* even multiple of 16-bits in length.
*/
#define NET_TUN_PKTSIZE ((CONFIG_NET_TUN_PKTSIZE + CONFIG_NET_GUARDSIZE + 1) & ~1)
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per
* second
*/
@ -149,8 +155,8 @@ struct tun_device_s
* 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];
uint8_t read_buf[NET_TUN_PKTSIZE];
uint8_t write_buf[NET_TUN_PKTSIZE];
/* This holds the information visible to the NuttX network */