From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id A36825A0279 for ; Fri, 9 Dec 2022 06:42:39 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4NT0KM40GMz4xvX; Fri, 9 Dec 2022 16:42:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1670564551; bh=Q8xQcInuO1msHO93nvmhtWkbMol8V0He+mKovymi5Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgNUZRw4rS7f4G6AcYysCRTdQUyXAYWQRjpdTQirKHhjh5fea5Ni7cOu+1aDEQxzv RuvfyPZPa6QK7Lznt26vj/W6cEMXNx5IMwJmocg5GE/c/f3nPbtpMZkYihHDELcOPH twWrT5YAAzRjVcRm803+kQ2zGKoej4G7HXoXgvO8= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 15/18] tap: Use different io vector bases depending on tap type Date: Fri, 9 Dec 2022 16:42:25 +1100 Message-Id: <20221209054228.4085990-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209054228.4085990-1-david@gibson.dropbear.id.au> References: <20221209054228.4085990-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LEQY6QGBVNSCV4JEANP2PLWS5EINE66F X-Message-ID-Hash: LEQY6QGBVNSCV4JEANP2PLWS5EINE66F X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Currently tap_send_frames() expects the frames it is given to include the vnet_len field, even in pasta mode which doesn't use it (although it need not be initialized in that case). To match, tap_iov_base() and tap_iov_len() construct the frame in that way. This will inconvenience future changes, so alter things to set the buffers to include just the frame needed by the tap backend type. Signed-off-by: David Gibson --- tap.c | 5 ++--- tap.h | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tap.c b/tap.c index d0dd72c..5ec6b70 100644 --- a/tap.c +++ b/tap.c @@ -317,8 +317,7 @@ static void tap_send_frames_pasta(struct ctx *c, size_t i; for (i = 0; i < n; i++) { - if (write(c->fd_tap, (char *)iov->iov_base + 4, - iov->iov_len - 4) < 0) { + if (write(c->fd_tap, (char *)iov->iov_base, iov->iov_len) < 0) { debug("tap write: %s", strerror(errno)); if (errno != EAGAIN && errno != EWOULDBLOCK) tap_handler(c, c->fd_tap, EPOLLERR, NULL); @@ -383,7 +382,7 @@ void tap_send_frames(struct ctx *c, const struct iovec *iov, size_t n) else tap_send_frames_pasta(c, iov, n); - pcap_multiple(iov, n, sizeof(uint32_t)); + pcap_multiple(iov, n, c->mode == MODE_PASST ? sizeof(uint32_t) : 0); } /** diff --git a/tap.h b/tap.h index 8fe460a..40cf480 100644 --- a/tap.h +++ b/tap.h @@ -20,8 +20,10 @@ struct tap_hdr { static inline size_t tap_hdr_len_(const struct ctx *c) { - (void)c; - return sizeof(struct tap_hdr); + if (c->mode == MODE_PASST) + return sizeof(struct tap_hdr); + else + return sizeof(struct ethhdr); } /** -- 2.38.1