From mboxrd@z Thu Jan 1 00:00:00 1970 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 8904B5A005E for ; Wed, 4 Jan 2023 18:45:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672854339; 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=hiCc96rLPpwatOih9FtoPobzgdudmOYVV+QPkFEXLyE=; b=bz0XNvtR9NGsA3EyPcrKqoHpqvWVvyM6cBB4ItW0u0PqPOq5Tve7UeesfJuy5sQdltrpBr cligYhq7YH38NAFzH/iqnI0R4O51lmIcbBQMnkn62EtSqysA23GybDqu5+/2AVlnF/E05j lhapFY2x/eP0iT4YaUaGxdxeensDIk4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-222-NEx1RX5UOI6KIxDYKWeBCQ-1; Wed, 04 Jan 2023 12:45:36 -0500 X-MC-Unique: NEx1RX5UOI6KIxDYKWeBCQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E3AD3C0E449; Wed, 4 Jan 2023 17:45:36 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-4.brq.redhat.com [10.40.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D992D51E5; Wed, 4 Jan 2023 17:45:35 +0000 (UTC) Date: Wed, 4 Jan 2023 18:45:33 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 18/18] tap: Improve handling of partial frame sends Message-ID: <20230104184533.0f9ea7b4@elisabeth> In-Reply-To: <20221209054228.4085990-19-david@gibson.dropbear.id.au> References: <20221209054228.4085990-1-david@gibson.dropbear.id.au> <20221209054228.4085990-19-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: B2B2R5BMTF5T2HF32LJSCKFB67BTXJFN X-Message-ID-Hash: B2B2R5BMTF5T2HF32LJSCKFB67BTXJFN 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.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: On Fri, 9 Dec 2022 16:42:28 +1100 David Gibson wrote: > In passt mode, when writing frames to the qemu socket, we might get a short > send. If we ignored this and carried on, the qemu socket would get out of > sync, because the bytes we actually sent wouldn't correspond to the length > header we already sent. tap_send_frames_passt() handles that by doing a > a blocking send to complete the message, but it has a few flaws: > * We only attempt to resend once: although it's unlikely in practice, > nothing prevents the blocking send() from also being short > * We print a debug error if send() returns non-zero.. but send() returns > the number of bytes sent, so we actually want it to return the length > of the remaining data. > > Correct those flaws and also be a bit more thorough about reporting > problems here. > > Signed-off-by: David Gibson > --- > tap.c | 51 ++++++++++++++++++++++++++++++++++++++------------- > 1 file changed, 38 insertions(+), 13 deletions(-) > > diff --git a/tap.c b/tap.c > index 5ec6b70..4fb27ca 100644 > --- a/tap.c > +++ b/tap.c > @@ -326,13 +326,39 @@ static void tap_send_frames_pasta(struct ctx *c, > } > } > > +/** > + * tap_send_remainder() - Send remainder of a partiall sent frame s/partiall/partially/ > + * @c: Execution context > + * @iov: Partially sent buffer > + * @offset: Number of bytes already sent from @iov > + * > + * #syscalls:passt sendto We should probably drop this, it's actually send(2) on armv6/armv7 and ppc64le, sendto(2) otherwise -- initially I sprinkled those annotations all over the place to show where specific calls were issued (and make it easier to drop them from the filter if calls disappeared) but I think it's not really practical for send(3). -- Stefano