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 541285A0276 for ; Fri, 8 Mar 2024 07:53:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1709880807; bh=YiYoFZWDxjW7cDlZLzlSC0BtSAKNAWvAAU66Ce8xbHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sex8L2hkbu9VjPg6ej7ESr8Iv3AD/CK/wqMbPvtU1bCNYoXOusBYWh3iEK8/rNvFJ A3b95a0QJMrt7hZJ+IPhCtuUhbQtrn797bc8jH5hDiOCE3DQcyGzwV7alc0b4cRAkD yzcketWPJmz4Wyq2HNeTnmnyXqH+bizGdbEbTY7sPGUxOtpGuS9h1rYCcLk/lNvLk2 +dQvSrv5OlMSWUQTMVyc5thYvVXD8PNTJJvw7kgggsdXJ63IgOwphV7hMmuIxZI15M osxgOrcCZcPv1RDXyMDFXXRMy1Rc5uibcisbi/31WK9QrQBhR/SLuazqJfGI9xxM6l uBgWIAa/v9+9g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TrcMC5QQyz4wxv; Fri, 8 Mar 2024 17:53:27 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 4/4] tap: Rename tap_iov_{base,len} Date: Fri, 8 Mar 2024 17:53:25 +1100 Message-ID: <20240308065325.2181322-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240308065325.2181322-1-david@gibson.dropbear.id.au> References: <20240308065325.2181322-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: HSDETQJW5ROFHZNLNYJ2VCZIN2OLR5PX X-Message-ID-Hash: HSDETQJW5ROFHZNLNYJ2VCZIN2OLR5PX 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: Laurent Vivier , David Gibson X-Mailman-Version: 3.3.8 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: These two functions are typically used to calculate values to go into the iov_base and iov_len fields of a struct iovec. They don't have to be used for that, though. Rename them in terms of what they actually do: calculate the base address and total length of the complete frame, including both L2 and tap specific headers. Signed-off-by: David Gibson --- tap.h | 14 +++++++------- tcp.c | 12 ++++++------ udp.c | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tap.h b/tap.h index aa3b1af2..2adc4e2b 100644 --- a/tap.h +++ b/tap.h @@ -27,30 +27,30 @@ static inline size_t tap_hdr_len_(const struct ctx *c) } /** - * tap_iov_base() - Find start of tap frame + * tap_frame_base() - Find start of tap frame * @c: Execution context - * @taph: Pointer to L2 header buffer + * @taph: Pointer to L2 and tap specific header buffer * * Returns: pointer to the start of tap frame - suitable for an * iov_base to be passed to tap_send_frames()) */ -static inline void *tap_iov_base(const struct ctx *c, struct tap_hdr *taph) +static inline void *tap_frame_base(const struct ctx *c, struct tap_hdr *taph) { return (char *)(taph + 1) - tap_hdr_len_(c); } /** - * tap_iov_len() - Finalize tap frame and return total length + * tap_frame_len() - Finalize tap frame and return total length * @c: Execution context * @taph: Tap header to finalize - * @plen: L2 payload length (excludes L2 and tap specific headers) + * @plen: L3 packet length (excludes L2 and tap specific headers) * * Returns: length of the tap frame including L2 and tap specific * headers - suitable for an iov_len to be passed to * tap_send_frames() */ -static inline size_t tap_iov_len(const struct ctx *c, struct tap_hdr *taph, - size_t plen) +static inline size_t tap_frame_len(const struct ctx *c, struct tap_hdr *taph, + size_t plen) { if (c->mode == MODE_PASST) taph->vnet_len = htonl(plen + sizeof(taph->eh)); diff --git a/tcp.c b/tcp.c index 9d90108b..a1860d10 100644 --- a/tcp.c +++ b/tcp.c @@ -1014,10 +1014,10 @@ static void tcp_sock4_iov_init(const struct ctx *c) } for (i = 0, iov = tcp4_l2_iov; i < TCP_FRAMES_MEM; i++, iov++) - iov->iov_base = tap_iov_base(c, &tcp4_l2_buf[i].taph); + iov->iov_base = tap_frame_base(c, &tcp4_l2_buf[i].taph); for (i = 0, iov = tcp4_l2_flags_iov; i < TCP_FRAMES_MEM; i++, iov++) - iov->iov_base = tap_iov_base(c, &tcp4_l2_flags_buf[i].taph); + iov->iov_base = tap_frame_base(c, &tcp4_l2_flags_buf[i].taph); } /** @@ -1045,10 +1045,10 @@ static void tcp_sock6_iov_init(const struct ctx *c) } for (i = 0, iov = tcp6_l2_iov; i < TCP_FRAMES_MEM; i++, iov++) - iov->iov_base = tap_iov_base(c, &tcp6_l2_buf[i].taph); + iov->iov_base = tap_frame_base(c, &tcp6_l2_buf[i].taph); for (i = 0, iov = tcp6_l2_flags_iov; i < TCP_FRAMES_MEM; i++, iov++) - iov->iov_base = tap_iov_base(c, &tcp6_l2_flags_buf[i].taph); + iov->iov_base = tap_frame_base(c, &tcp6_l2_flags_buf[i].taph); } /** @@ -1454,14 +1454,14 @@ static size_t tcp_l2_buf_fill_headers(const struct ctx *c, ip_len = tcp_fill_headers4(c, conn, &b->iph, &b->th, plen, check, seq); - tlen = tap_iov_len(c, &b->taph, ip_len); + tlen = tap_frame_len(c, &b->taph, ip_len); } else { struct tcp6_l2_buf_t *b = (struct tcp6_l2_buf_t *)p; ip_len = tcp_fill_headers6(c, conn, &b->ip6h, &b->th, plen, seq); - tlen = tap_iov_len(c, &b->taph, ip_len); + tlen = tap_frame_len(c, &b->taph, ip_len); } return tlen; diff --git a/udp.c b/udp.c index cba595c9..0a7f3b78 100644 --- a/udp.c +++ b/udp.c @@ -318,7 +318,7 @@ static void udp_sock4_iov_init_one(const struct ctx *c, size_t i) mh->msg_iov = siov; mh->msg_iovlen = 1; - tiov->iov_base = tap_iov_base(c, &buf->taph); + tiov->iov_base = tap_frame_base(c, &buf->taph); } /** @@ -346,7 +346,7 @@ static void udp_sock6_iov_init_one(const struct ctx *c, size_t i) mh->msg_iov = siov; mh->msg_iovlen = 1; - tiov->iov_base = tap_iov_base(c, &buf->taph); + tiov->iov_base = tap_frame_base(c, &buf->taph); } /** @@ -606,7 +606,7 @@ static size_t udp_update_hdr4(const struct ctx *c, struct udp4_l2_buf_t *b, b->uh.dest = htons(dstport); b->uh.len = htons(datalen + sizeof(b->uh)); - return tap_iov_len(c, &b->taph, ip_len); + return tap_frame_len(c, &b->taph, ip_len); } /** @@ -673,7 +673,7 @@ static size_t udp_update_hdr6(const struct ctx *c, struct udp6_l2_buf_t *b, b->uh.len = b->ip6h.payload_len; csum_udp6(&b->uh, src, dst, b->data, datalen); - return tap_iov_len(c, &b->taph, payload_len + sizeof(b->ip6h)); + return tap_frame_len(c, &b->taph, payload_len + sizeof(b->ip6h)); } /** -- 2.44.0