From nobody Mon Sep 16 20:20:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682911277; cv=none; d=zohomail.com; s=zohoarc; b=Ep6MYeVpAfbCl5TvlF55/VibtKsVbUyCH2N37uRdCQWwOghgsLEq7/waLU+tFhdbOTy5GM0SEFwPVyoWwR0CT6GOUicSg0rjBaQ197M83J//XcCmpSL+r5R4hxa+eR4n2HxBHZTBns51ABF+6rE1cPZLeWY+5hnSNee/81gMuV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682911277; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tEENFPWsO25/EGTDbHMhpXcxzOEwcyE6Jwz9WP85wqc=; b=AChXRuyEUbqGMciuC3leZ2MnhmD8LFeTeVnFb1u4WES14XsRMbefkUdD40aDcS6qbUqQ2QGfXdnmJ3uVAloeO4z4GRDl6NT65Y4ANljCzsdzBfCA2jGrruCJEuEd/0VQUSpsgpUHzYbKM8qL0DO37b44eF9Xxy0s7n3tP0uGL7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1682911277623806.9992706437815; Sun, 30 Apr 2023 20:21:17 -0700 (PDT) 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-203-jMNoR76XPvq3fA-MNTFj0w-1; Sun, 30 Apr 2023 23:20:12 -0400 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 F40981C02D43; Mon, 1 May 2023 03:20:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C68951E3; Mon, 1 May 2023 03:20:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2DA151946A6A; Mon, 1 May 2023 03:20:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9E32F1946587 for ; Mon, 1 May 2023 03:19:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 28D21477F7F; Mon, 1 May 2023 03:19:44 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.8.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F95040BB04 for ; Mon, 1 May 2023 03:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682911276; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tEENFPWsO25/EGTDbHMhpXcxzOEwcyE6Jwz9WP85wqc=; b=PyNPrj7WxUbYpWWw36S5FRnnJhL+h95mK45kpI4XAVYMw2Dz8qDt/3hP2xye0YwuMig2Ut Hqco7438zqwNHPYz6mxszV0IxPO63ZwlBFGcoRd6OuwMHaY1niqMRK2iP5UOgCerNN5ip7 HpxlQ0kvYW7bRFkqI1Vm4Q4OuU/wZyo= X-MC-Unique: jMNoR76XPvq3fA-MNTFj0w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 01/28] util: add -w/--concurrent when applying the rule rather than when building it Date: Sun, 30 Apr 2023 23:19:16 -0400 Message-Id: <20230501031943.288145-2-laine@redhat.com> In-Reply-To: <20230501031943.288145-1-laine@redhat.com> References: <20230501031943.288145-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682911278284100009 Content-Type: text/plain; charset="utf-8"; x-default="true" We will already need a separate function for virFirewallApplyRule for iptables vs. nftables, but the only reason for needing a separate function for virFirewallAddRule* is that iptables/ebtables need to have an extra arg added for locking (to prevent multiple iptables commands from running at the same time). We can just as well add in the -w/--concurrent during virFirewallApplyRule, so move the arg-add to ApplyRule to keep AddRule simple. Signed-off-by: Laine Stump Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virfirewall.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 30e73f603e..e8e74621c8 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -213,20 +213,6 @@ virFirewallAddRuleFullV(virFirewall *firewall, rule->queryOpaque =3D opaque; rule->ignoreErrors =3D ignoreErrors; =20 - switch (rule->layer) { - case VIR_FIREWALL_LAYER_ETHERNET: - ADD_ARG(rule, "--concurrent"); - break; - case VIR_FIREWALL_LAYER_IPV4: - ADD_ARG(rule, "-w"); - break; - case VIR_FIREWALL_LAYER_IPV6: - ADD_ARG(rule, "-w"); - break; - case VIR_FIREWALL_LAYER_LAST: - break; - } - while ((str =3D va_arg(args, char *)) !=3D NULL) ADD_ARG(rule, str); =20 @@ -499,6 +485,19 @@ virFirewallApplyRuleDirect(virFirewallRule *rule, =20 cmd =3D virCommandNewArgList(bin, NULL); =20 + /* lock to assure nobody else is messing with the tables while we are = */ + switch (rule->layer) { + case VIR_FIREWALL_LAYER_ETHERNET: + virCommandAddArg(cmd, "--concurrent"); + break; + case VIR_FIREWALL_LAYER_IPV4: + case VIR_FIREWALL_LAYER_IPV6: + virCommandAddArg(cmd, "-w"); + break; + case VIR_FIREWALL_LAYER_LAST: + break; + } + for (i =3D 0; i < rule->argsLen; i++) virCommandAddArg(cmd, rule->args[i]); =20 --=20 2.39.2