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=cSGc9gZV; 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 2B8B25A0262 for ; Tue, 03 Sep 2024 21:25:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725391546; 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=VqfLlezqBfi3urUYa0/aV8LQcKuYKhSuowvDNDKD/pw=; b=cSGc9gZVq8NvcwnBRve3Ax1GYsHKU6bo3iilE2n9OPeWNM3M34pPgqn4HIPeaHju9zTL+J yh0Y+BHirD6qH6wWl8ruQ8wqFiur+7zJVNIFrJl6aU4UCcyF1/wgd5TEc7UctfU7sIvh3f 3ZZGwjezbXekLu0bem/Pm8xKTPBtIxs= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-304-29Ey2k2ZM0W7pho1UhA8EQ-1; Tue, 03 Sep 2024 15:25:45 -0400 X-MC-Unique: 29Ey2k2ZM0W7pho1UhA8EQ-1 Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2058ba8562fso25869685ad.3 for ; Tue, 03 Sep 2024 12:25:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725391543; x=1725996343; 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=VqfLlezqBfi3urUYa0/aV8LQcKuYKhSuowvDNDKD/pw=; b=OCYZIcHT/3U6BcS0My/6qnBET9enNhAJ+snOd3t/nDmTc4FrIF3XFd8wgcEMkd1vBe 8+Eso3QhItRYv/Bjpa89bsV0jkgTxwyxPr7lxfPVVT0/JR3D6IWjA+DXTAH23l+v38VP YfdvhpquMNoD3mC7gtefFNjsoHXZV2dPyqXiqD6TJk7ogo+6sNbl/oU153YMr3W2hxoo C2kIQFNeix3zFVtW8qwpZLNC2fstAD0ltRSzaJ6LqKXY7Nmp/s5TTIuTjVJvkVTC3wrp GYUJypla4O/d+zhIQvHju4LlgmF+RRE6rgdNKu0Q9FZbEkxVsM+kek92F0zAp0+0KNdN AZHQ== X-Gm-Message-State: AOJu0YwxGRMWrT2qT0S2nCKPsiJwq+GqobMqGWw+rH0NQaXenekdCSM5 NgPUmSAReXkm1we5dIVd9n2n7whSilT25d734Kze2ze1qp1LpvLwMJEH0flQHQdAdGYnqpt6JTZ qABLAA3IBH4gkYcpmgZJv8/MZNf5WPqoiHmjAZXvzOpyzIZqludPfjqs7SA== X-Received: by 2002:a17:903:2348:b0:203:a030:d0a1 with SMTP id d9443c01a7336-20546b5529fmr118956915ad.58.1725391543083; Tue, 03 Sep 2024 12:25:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+CVzFLZmfH6SIxX+kaz1HloENS77G/rP5NCqJ1qAlLQrs+BZNjBkTFaxC/m6ww5EmklurnQ== X-Received: by 2002:a17:903:2348:b0:203:a030:d0a1 with SMTP id d9443c01a7336-20546b5529fmr118956725ad.58.1725391542689; Tue, 03 Sep 2024 12:25:42 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea65fe6sm1840385ad.257.2024.09.03.12.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 12:25:42 -0700 (PDT) Date: Tue, 3 Sep 2024 21:25:39 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/6] tap: Improve handling of EINTR in tap_passt_input() Message-ID: <20240903212539.1cb1adb3@elisabeth> In-Reply-To: <20240903120235.1688429-3-david@gibson.dropbear.id.au> References: <20240903120235.1688429-1-david@gibson.dropbear.id.au> <20240903120235.1688429-3-david@gibson.dropbear.id.au> 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-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 5TB4DNGHXH7EDXZ5F4TZVNXETWBRBXKR X-Message-ID-Hash: 5TB4DNGHXH7EDXZ5F4TZVNXETWBRBXKR 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 Tue, 3 Sep 2024 22:02:31 +1000 David Gibson wrote: > When tap_passt_input() gets an error from recv() it (correctly) does not > print any error message for EINTR, EAGAIN or EWOULDBLOCK. However in all > three cases it returns from the function. That makes sense for EAGAIN and > EWOULDBLOCK, since we then want to wait for the next EPOLLIN event before > trying again. For EINTR, however, it makes more sense to retry immediately > - as it stands we're likely to get a renewer EPOLLIN event immediately in > that case, since we're using level triggered signalling. > > So, handle EINTR separately by immediately retrying until we succeed or > get a different type of error. I don't see an actual improvement: we don't know why we would get EINTR (because of signals) so repeating the recv() right away isn't necessarily a better choice. I'd say whatever way we have of carrying on on EINTR is fine. If this patch helps with brevity for the next ones, it makes sense, but otherwise I don't see a real advantage. Well, it's more consistent with the way we handle EINTR on other calls, but that's about it. > > Signed-off-by: David Gibson > --- > tap.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/tap.c b/tap.c > index 14c88871..9ee59faa 100644 > --- a/tap.c > +++ b/tap.c > @@ -1003,10 +1003,13 @@ static void tap_passt_input(struct ctx *c, const struct timespec *now) > memmove(pkt_buf, partial_frame, partial_len); > } > > - n = recv(c->fd_tap, pkt_buf + partial_len, TAP_BUF_BYTES - partial_len, > - MSG_DONTWAIT); > + do { > + n = recv(c->fd_tap, pkt_buf + partial_len, > + TAP_BUF_BYTES - partial_len, MSG_DONTWAIT); > + } while ((n < 0) && errno == EINTR); > + > if (n < 0) { > - if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) { > + if (errno != EAGAIN && errno != EWOULDBLOCK) { > err_perror("Receive error on guest connection, reset"); > tap_sock_reset(c); > } -- Stefano