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 383ED5A0277 for ; Fri, 6 Jan 2023 01:43:35 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Np4MM098qz4y1D; Fri, 6 Jan 2023 11:43:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1672965807; bh=/1J+fNXBKOwuqrng4RHb8T42Lv65BK/TPW0CHmjuxis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ea2tEUxEHI3Z71jf27YtW1IRrSbdi95VJydbpEy0DGCVoaFRc8XMrk9fASCk2KBww 2bBH3zPwwhTqznBONuZR5Ej9qDpSE+92sUhHara61o9MqaOp07CyB4OwfgQyE9U6yj s5T62glGS+jBNHFC3nvlbe1POv+PEmmgKaqj+wLE= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 15/18] tap: Use different io vector bases depending on tap type Date: Fri, 6 Jan 2023 11:43:19 +1100 Message-Id: <20230106004322.985665-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106004322.985665-1-david@gibson.dropbear.id.au> References: <20230106004322.985665-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: TYRD4AAN6FQHA5Q2ERJTCIKZDGK67UDF X-Message-ID-Hash: TYRD4AAN6FQHA5Q2ERJTCIKZDGK67UDF 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.39.0