From nobody Fri May 3 19:47:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539329009772950.9969952743536; Fri, 12 Oct 2018 00:23:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36A303002946; Fri, 12 Oct 2018 07:23:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D010C5D6B3; Fri, 12 Oct 2018 07:23:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C71434CA94; Fri, 12 Oct 2018 07:23:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9C7NKk8025468 for ; Fri, 12 Oct 2018 03:23:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7DD875DD6D; Fri, 12 Oct 2018 07:23:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76F7F5DA61 for ; Fri, 12 Oct 2018 07:23:17 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 967FF3006035 for ; Fri, 12 Oct 2018 07:23:15 +0000 (UTC) Received: from [10.94.3.220] (helo=dim-vz7.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gArmy-0005ll-49 for libvir-list@redhat.com; Fri, 12 Oct 2018 10:23:12 +0300 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 Oct 2018 10:23:07 +0300 Message-Id: <1539328987-818414-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Sender passed SPF test, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 12 Oct 2018 07:23:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 12 Oct 2018 07:23:16 +0000 (UTC) for IP:'185.231.240.75' DOMAIN:'relay.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 185.231.240.75 relay.sw.ru 185.231.240.75 relay.sw.ru X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] nwfilter: fix learning address thread shutdown X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 12 Oct 2018 07:23:28 +0000 (UTC) X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If learning thread is configured to learn on all ethernet frames (which is hardcoded) then chances are big that there is packet on every iteration of inspecting frames loop. As result we will hang on shutdown because we don't check threadsTerminate if there is packet. Let's just check termination conditions on every iteration. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: John Ferlan --- src/nwfilter/nwfilter_learnipaddr.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 008c24b..e6cb996 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -483,6 +483,12 @@ learnIPAddressThread(void *arg) while (req->status =3D=3D 0 && vmaddr =3D=3D 0) { int n =3D poll(fds, ARRAY_CARDINALITY(fds), PKT_TIMEOUT_MS); =20 + if (threadsTerminate || req->terminate) { + req->status =3D ECANCELED; + showError =3D false; + break; + } + if (n < 0) { if (errno =3D=3D EAGAIN || errno =3D=3D EINTR) continue; @@ -492,15 +498,8 @@ learnIPAddressThread(void *arg) break; } =20 - if (n =3D=3D 0) { - if (threadsTerminate || req->terminate) { - VIR_DEBUG("Terminate request seen, cancelling pcap"); - req->status =3D ECANCELED; - showError =3D false; - break; - } + if (n =3D=3D 0) continue; - } =20 if (fds[0].revents & (POLLHUP | POLLERR)) { VIR_DEBUG("Error from FD probably dev deleted"); @@ -512,13 +511,6 @@ learnIPAddressThread(void *arg) packet =3D pcap_next(handle, &header); =20 if (!packet) { - /* Already handled with poll, but lets be sure */ - if (threadsTerminate || req->terminate) { - req->status =3D ECANCELED; - showError =3D false; - break; - } - /* Again, already handled above, but lets be sure */ if (virNetDevValidateConfig(req->binding->portdevname, NULL, r= eq->ifindex) <=3D 0) { virResetLastError(); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list