From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R9Di0JuI; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 214F45A0623 for ; Thu, 14 Nov 2024 16:39:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731598745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HYAYLMyKetzJx17I5yiJXp6nSJyd74KVoHpnUCM2gRQ=; b=R9Di0JuI+0D0lUJ9aW2El/m86lZTOw/0GquGu6JQEHhJf1fEEiuYcrg8EdQRxKpCBPAk3t cGPDgNVcI/9mAWDR4yCoG8FJse3O91saocDJrFA6A32SHpsRbWnYs0hS4UkiGKBAYz8Yig RSlqebH9l8vacVZRBpWRIm5qfT28K5c= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-fdtCxMkmNwaChqhVjwAPAA-1; Thu, 14 Nov 2024 10:39:04 -0500 X-MC-Unique: fdtCxMkmNwaChqhVjwAPAA-1 X-Mimecast-MFC-AGG-ID: fdtCxMkmNwaChqhVjwAPAA Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d563a1af4so422850f8f.2 for ; Thu, 14 Nov 2024 07:39:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731598742; x=1732203542; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HYAYLMyKetzJx17I5yiJXp6nSJyd74KVoHpnUCM2gRQ=; b=dd2bBPrjEyEvYG09kpxXSetZvkCikF9Vsts2CNvNde3WpQ87/b2Ie2Aam9it83Qsse uqPmfcJmuCmnJznT4D6kvXXB4C7MqFEFgAuJ5pqv4m0z+43N72007se80DI90sznlWtz ayALkw3KubCcWbN93qjMq4xhlHSp95E132DsXsFza55+820HLJTAAslLEbz9RHsgEPpE Hhgwqyt4QxXKu1sC4r3JysnJFGUbzMeZvarkkjuRYsRT9SohVW2GTPef8fkir1+EuOxP oVWuykQTc6OO8qBD6fhO4L/MNLCyeZ1hTYcNs4rcsgW0CmOZczrN3L3kOB4IG1OKhSib Y6Uw== X-Gm-Message-State: AOJu0Yy99geeY/xqRHGj0IEm3ErlCS7NGZrFEaCCGrp7yWg670lEtFJD kseeT+C631m6indvbrPyVuAD/4FeW70ZjU7pju6BpBrN8ZfyTk6uS2NGbM6QgczCD2ce4VwbZRS VH/4xi0UwgMz3gMH/ICNtjfAytFinvi4Xx2kEXosrfpxNz7w9pDOAjZVc3tM08Xkj1zUrCDPlEZ QZst1XixGTYND0d4+FxuXdhbO8ZZchzIkk X-Received: by 2002:a5d:64ae:0:b0:37d:45ad:8394 with SMTP id ffacd0b85a97d-38218502e37mr1935164f8f.15.1731598742215; Thu, 14 Nov 2024 07:39:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdkgfwlYG9KhopGtuom15u+kRHXtKaa/qCRBY/uMxtlWBQ5/Kb4AN6E0zZJyJ5rG5/hdakGQ== X-Received: by 2002:a5d:64ae:0:b0:37d:45ad:8394 with SMTP id ffacd0b85a97d-38218502e37mr1935145f8f.15.1731598741815; Thu, 14 Nov 2024 07:39:01 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ae154cesm1775289f8f.68.2024.11.14.07.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 07:39:00 -0800 (PST) Date: Thu, 14 Nov 2024 16:38:59 +0100 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v8 7/8] vhost-user: add vhost-user Message-ID: <20241114163859.7eeafa38@elisabeth> In-Reply-To: References: <20241010122903.1188992-1-lvivier@redhat.com> <20241010122903.1188992-8-lvivier@redhat.com> <20241017021034.437f3757@elisabeth> <880fe7a3-4925-49a0-8253-e130f976039e@redhat.com> <20241114152312.7c5ac1cd@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QMLrF4ZNgvWHYXYu3G0vrcfaVW6KQ98cuWsax6DV99k_1731598743 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: Z65QTGZILDKO33JRRZLBF67ARG7JYTN4 X-Message-ID-Hash: Z65QTGZILDKO33JRRZLBF67ARG7JYTN4 X-MailFrom: sbrivio@redhat.com 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: passt-dev@passt.top 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: On Thu, 14 Nov 2024 16:16:48 +0100 Laurent Vivier wrote: > On 14/11/2024 15:23, Stefano Brivio wrote: > > On Thu, 14 Nov 2024 11:20:09 +0100 > > Laurent Vivier wrote: > > > >> On 17/10/2024 02:10, Stefano Brivio wrote: > >>>> + if (frame_size == 0) > >>>> + first = &iov_vu[i + 1]; > >>>> + > >>>> + if (iov_vu[i + 1].iov_len > (size_t)len) > >>>> + iov_vu[i + 1].iov_len = len; > >>>> + > >>>> + len -= iov_vu[i + 1].iov_len; > >>>> + iov_used++; > >>>> + > >>>> + frame_size += iov_vu[i + 1].iov_len; > >>>> + num_buffers++; > >>>> + > >>>> + if (frame_size >= mss || len == 0 || > >>>> + i + 1 == iov_cnt || !vu_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) { > >>>> + if (i + 1 == iov_cnt) > >>>> + check = NULL; > >>>> + > >>>> + /* restore first iovec base: point to vnet header */ > >>>> + vu_set_vnethdr(vdev, first, num_buffers, l2_hdrlen); > >>>> + > >>>> + tcp_vu_prepare(c, conn, first, frame_size, &check); > >>>> + if (*c->pcap) { > >>>> + tcp_vu_update_check(tapside, first, num_buffers); > >>>> + pcap_iov(first, num_buffers, > >>>> + sizeof(struct virtio_net_hdr_mrg_rxbuf)); > >>>> + } > >>>> + > >>>> + conn->seq_to_tap += frame_size; > >>> We always increase this, even if, later... > >>> > >>>> + > >>>> + frame_size = 0; > >>>> + num_buffers = 0; > >>>> + } > >>>> + } > >>>> + > >>>> + /* release unused buffers */ > >>>> + vu_queue_rewind(vq, iov_cnt - iov_used); > >>>> + > >>>> + /* send packets */ > >>>> + vu_flush(vdev, vq, elem, iov_used); > >>> we fail to send packets, that is, even if vu_queue_fill_by_index() > >>> returns early because (!vq->vring.avail). > >> > >> vring.avail is a pointer to a structure. vring.avail is NULL if there is something wrong > >> during the initialization. It's imported code, I think it's only a sanity check. > >> So in theory vu_flush() cannot fail. > > > > Oh, I see now. I actually think it's preferable to crash in that > > (theoretically impossible) case, without even an ASSERT() (we would > > dereference a NULL pointer, eventually, even if not here). > > So what you propose is to remove the "if (!vq->vring.avail) return;"? Yes, all of them, actually. It also avoids confusion I think. -- Stefano