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=Zm5+fKT4; 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 6A92B5A0623 for ; Thu, 14 Nov 2024 15:23:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731594199; 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=p4kJvfkENqfLZM1KKW9Maov1sQNwaAyq5MefATJkcpw=; b=Zm5+fKT4S/fJQkyfpcrm27zW7Q8wP5Dhv4REvRx5VXmIlrNtLxVYYfYZV4oYXJp+PZzrKs qwBSILLnKTLoTL9r9k3oh/VADbWM7sJxYDCzIc3pPY9fHYvFxdY6A9+4+ZV33n6ubw6Q5W jYlxqvkaJQO/OG3BZJrPlCdiDs0XYcY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-LY0Cml3aOWuA8RZ8TN3nPA-1; Thu, 14 Nov 2024 09:23:18 -0500 X-MC-Unique: LY0Cml3aOWuA8RZ8TN3nPA-1 X-Mimecast-MFC-AGG-ID: LY0Cml3aOWuA8RZ8TN3nPA Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4314c6ca114so5302795e9.1 for ; Thu, 14 Nov 2024 06:23:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731594195; x=1732198995; 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=p4kJvfkENqfLZM1KKW9Maov1sQNwaAyq5MefATJkcpw=; b=FkKfpuflsxPD3nFJkYdqwvSBmzj+wDjWGZLp+AXZiN+OnHMoO5wnawnFT6LgKjn5ga M53WZIUo3nqxKEbltKfa4R0RMGSXG2DrYZQ1Fs0Qhm3egVOVPf9LjG1alaMJ8A4RUqMN L2IOhZ4/7dqZqqt+levapB0rkPuFuuOIl/Hn37cooTX/55mrcyImTsYDYZMWRflyZ0od qWTbqPc2JDBwZ6pbjjk/04N0e4vFJXzFeJPoYAe3kiS6qVVyTA36ajc4HIMOljCpJyD/ 2sgkX6nuT+el4FoeMNJhk36gANtS76xPSnFmzGBpS06ADIJkuVrnVhwpxhn8CxvWQuCq gxsQ== X-Gm-Message-State: AOJu0YzqM5t4KIzQRkQw2ZpccUpBnQr6HZmsdmceVvvKoOlroo8mDln2 /jav6N3XFwo33HitxYZnpBpWbRTGCqJwNfBt+kbwC1M8TxLQtamIt7WZj1mk3VZj4DmunkXXp+6 4ugy6w9pmhPevFkRpigW5m8hlwvr2K2ZccPj7qzsoVuv9qruNgWbn7ykT3I7Psm68U6f20+HkFh VLP0kKVIfCw/ounTiwo7NN6n+DuynuI7vV X-Received: by 2002:a05:600c:3c97:b0:431:4f5e:1f61 with SMTP id 5b1f17b1804b1-432d4ab1840mr66737305e9.14.1731594194634; Thu, 14 Nov 2024 06:23:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuGD8ag6GAR92KEOitcOyMfzXpPEblAvyXBVObNsW1v2cT7fYZF/RKfsLXY5JdDhctFCJ0bg== X-Received: by 2002:a05:600c:3c97:b0:431:4f5e:1f61 with SMTP id 5b1f17b1804b1-432d4ab1840mr66736885e9.14.1731594194187; Thu, 14 Nov 2024 06:23:14 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da28ce85sm25143435e9.33.2024.11.14.06.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 06:23:13 -0800 (PST) Date: Thu, 14 Nov 2024 15:23:12 +0100 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v8 7/8] vhost-user: add vhost-user Message-ID: <20241114152312.7c5ac1cd@elisabeth> In-Reply-To: <880fe7a3-4925-49a0-8253-e130f976039e@redhat.com> References: <20241010122903.1188992-1-lvivier@redhat.com> <20241010122903.1188992-8-lvivier@redhat.com> <20241017021034.437f3757@elisabeth> <880fe7a3-4925-49a0-8253-e130f976039e@redhat.com> 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: yTWkOapy4wWNbS-skZKOUV7JuhtmEE0RGPLiHgbo-Tw_1731594196 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DQIONVXUHWC2ZNZ6KEL2D7IL2CVKUTIY X-Message-ID-Hash: DQIONVXUHWC2ZNZ6KEL2D7IL2CVKUTIY 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 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). -- Stefano