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.129.124]) by passt.top (Postfix) with ESMTP id B76205A026B for ; Thu, 17 Nov 2022 19:49:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668710987; 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=mqliq38A8jclZIAUQ/IwI3kzAq72lcmTyE7q+Y7gb8Y=; b=Nppil/I3XLI+tUpmOAMxInb3zDmXWS0LJxBd5wg7BxQoutj+BhIfOYYxdt/1vOAyLeh8uP NaRDyQJA7URAPR5PnN2Lb8JHE1Sk03PoNKmiCLgMKmYp1w1/PbSU8TyQfVTTfo/blH04JE pKtOoVa9ZdbEElx2H/Sr3J4RhvcXVhM= 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-91-Ll7x3rZzO_eYM_rIIOEgsw-1; Thu, 17 Nov 2022 13:49:45 -0500 X-MC-Unique: Ll7x3rZzO_eYM_rIIOEgsw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E29A1C087A5 for ; Thu, 17 Nov 2022 18:49:45 +0000 (UTC) Received: from pick.home.annexia.org (unknown [10.39.193.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A87840C6EC3; Thu, 17 Nov 2022 18:49:44 +0000 (UTC) From: "Richard W.M. Jones" To: sbrivio@redhat.com Subject: [PATCH passt v2 4/7] passt, tap: Process data on the socket before HUP/ERR events Date: Thu, 17 Nov 2022 18:49:35 +0000 Message-Id: <20221117184938.2270462-5-rjones@redhat.com> In-Reply-To: <20221117184938.2270462-1-rjones@redhat.com> References: <20221117184938.2270462-1-rjones@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: QZUKMWPG3DRDXUDFPBBHL2O2QIHENKDR X-Message-ID-Hash: QZUKMWPG3DRDXUDFPBBHL2O2QIHENKDR X-MailFrom: rjones@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: In the case where the client writes a packet and then closes the socket, because we receive EPOLLIN|EPOLLRDHUP together we have a choice of whether to close the socket immediately, or read the packet and then close the socket. Choose the latter. This should improve fuzzing coverage and arguably is a better choice even for regular use since dropping packets on close is bad. See-also: https://archives.passt.top/passt-dev/20221117171805.3746f53a@elisabeth/ Signed-off-by: Richard W.M. Jones --- tap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tap.c b/tap.c index 9998127..d97af6a 100644 --- a/tap.c +++ b/tap.c @@ -1106,13 +1106,13 @@ void tap_handler(struct ctx *c, int fd, uint32_t events, return; } - if (events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR)) - goto reinit; - if ((c->mode == MODE_PASST && tap_handler_passt(c, now)) || (c->mode == MODE_PASTA && tap_handler_pasta(c, now))) goto reinit; + if (events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR)) + goto reinit; + return; reinit: if (c->one_off) { -- 2.37.0.rc2