From 5e23b1ef449bc191b7d0c6f0f7bdcfe28060596f Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 9 Sep 2021 15:08:31 +0200 Subject: tap: Fix calculation of number of tap scatter-gather IO messages Messages are typically smaller than ETH_MAX_MTU. Signed-off-by: Stefano Brivio --- passt.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'passt.h') diff --git a/passt.h b/passt.h index 7e80381..39bfb0f 100644 --- a/passt.h +++ b/passt.h @@ -45,9 +45,10 @@ union epoll_ref { uint64_t u64; }; -#define TAP_BUF_BYTES (ETH_MAX_MTU * 128) +#define TAP_BUF_BYTES ((ETH_MAX_MTU + sizeof(uint32_t)) * 128) #define TAP_BUF_FILL (TAP_BUF_BYTES - ETH_MAX_MTU - sizeof(uint32_t)) -#define TAP_MSGS (TAP_BUF_BYTES / sizeof(struct ethhdr) + 1) +#define TAP_MSGS \ + DIV_ROUND_UP(TAP_BUF_BYTES, ETH_ZLEN - 2 * ETH_ALEN + sizeof(uint32_t)) #define PKT_BUF_BYTES MAX(TAP_BUF_BYTES, 0) extern char pkt_buf [PKT_BUF_BYTES]; -- cgit v1.2.3