From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=Dzxoi524; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id E83EA5A004C for ; Mon, 04 Nov 2024 09:40:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730709607; bh=tMc4Y0ciQokhWRipSejTAy2z9cGjA9EGI+KOZYjpACs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dzxoi524/mJ8/+LlbKs8+oEkui0jd8gUg4yTxvpG2uWQET22nkZfWNtIjALdcG65N qYRhhDAcyWP0AtL0Hik+eoFY5tL+2SjBt9m2hTMMyR+IsWMFtfEPlsYaWKbt8T0xPx O2Ej2nMTEai5DG6X81N8BythzXp8Ma4Yn4dZeXzyPAUP0XyDFL31dW+Gz0qTj7mvVz KEWYdhQQiiUbyL+lodIsPsbDPa4hGgxaD8WEQoass4Fn+oroAh3nVwCDB/myNUqwTZ TbQUy9dVahCtkePCn5drbE5EV1alTCwKQOivInEWsfVgv/PTHzPLiKD92y85R9wNIL d88qvbHxac59Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XhlK34NJ4z4xFt; Mon, 4 Nov 2024 19:40:07 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v9 11/20] vhost-user: Consistent sense when encoding IP version as boolean Date: Mon, 4 Nov 2024 19:39:54 +1100 Message-ID: <20241104084004.3544294-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104084004.3544294-1-david@gibson.dropbear.id.au> References: <20241104084004.3544294-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: ZZKHDEOZ43HEEFNWYKRYD4KEFHWGGZCG X-Message-ID-Hash: ZZKHDEOZ43HEEFNWYKRYD4KEFHWGGZCG 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.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: Always use a 'v6' flag, rather than sometimes a 'v4' flag. Signed-off-by: David Gibson --- tcp_vu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tcp_vu.c b/tcp_vu.c index 2415118..b994817 100644 --- a/tcp_vu.c +++ b/tcp_vu.c @@ -204,14 +204,14 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags) /** tcp_vu_sock_recv() - Receive datastream from socket into vhost-user buffers * @c: Execution context * @conn: Connection pointer - * @v4: Set for IPv4 connections + * @v6: Set for IPv6 connections * @fillsize: Number of bytes we can receive * @dlen: Size of received data (output) * * Return: Number of iov entries used to store the data */ static ssize_t tcp_vu_sock_recv(const struct ctx *c, - struct tcp_tap_conn *conn, bool v4, + struct tcp_tap_conn *conn, bool v6, size_t fillsize, ssize_t *dlen) { struct vu_dev *vdev = c->vdev; @@ -225,7 +225,7 @@ static ssize_t tcp_vu_sock_recv(const struct ctx *c, *dlen = 0; - l2_hdrlen = tcp_vu_l2_hdrlen(!v4); + l2_hdrlen = tcp_vu_l2_hdrlen(v6); vu_init_elem(elem, &iov_vu[1], VIRTQUEUE_MAX_SIZE); @@ -357,8 +357,8 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn) uint16_t mss = MSS_GET(conn); size_t l2_hdrlen, fillsize; int i, iov_cnt, iov_used; - int v4 = CONN_V4(conn); uint32_t already_sent = 0; + int v6 = CONN_V6(conn); const uint16_t *check; struct iovec *first; int frame_size; @@ -401,7 +401,7 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn) /* collect the buffers from vhost-user and fill them with the * data from the socket */ - iov_cnt = tcp_vu_sock_recv(c, conn, v4, fillsize, &len); + iov_cnt = tcp_vu_sock_recv(c, conn, v6, fillsize, &len); if (iov_cnt <= 0) return iov_cnt; @@ -418,7 +418,7 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn) tcp_update_seqack_wnd(c, conn, 0, NULL); /* initialize headers */ - l2_hdrlen = tcp_vu_l2_hdrlen(!v4); + l2_hdrlen = tcp_vu_l2_hdrlen(v6); iov_used = 0; num_buffers = 0; check = NULL; -- 2.47.0