From nobody Thu Nov 28 10:36:22 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524843377201764.2767498744379; Fri, 27 Apr 2018 08:36:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DFF04E90A; Fri, 27 Apr 2018 15:36:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0ADF216D2E; Fri, 27 Apr 2018 15:36:14 +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 0465418033EB; Fri, 27 Apr 2018 15:36:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3RFPKOm032268 for ; Fri, 27 Apr 2018 11:25:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9339A83B77; Fri, 27 Apr 2018 15:25:20 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A8E1AB3EF; Fri, 27 Apr 2018 15:25:20 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 27 Apr 2018 16:25:03 +0100 Message-Id: <20180427152513.28928-5-berrange@redhat.com> In-Reply-To: <20180427152513.28928-1-berrange@redhat.com> References: <20180427152513.28928-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/14] nwfilter: make virNWFilterIPAddrLearnReq type private 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 27 Apr 2018 15:36:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The virNWFilterIPAddrLearnReq type should only be used by the IP address learning code, so can live in the implementation file instead of header file. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Jiri Denemark --- src/nwfilter/nwfilter_gentech_driver.c | 8 ++++---- src/nwfilter/nwfilter_learnipaddr.c | 23 ++++++++++++++++++++--- src/nwfilter/nwfilter_learnipaddr.h | 19 +------------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 0735426734..91794dd3ad 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -655,7 +655,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid, filter->name, vars, driver); goto err_exit; } else if (STRCASEEQ(learning, "any")) { - if (virNWFilterLookupLearnReq(ifindex) =3D=3D NULL) { + if (!virNWFilterHasLearnReq(ifindex)) { rc =3D virNWFilterLearnIPAddress(techdriver, ifname, ifindex, @@ -680,7 +680,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid, } else if (virHashSize(missing_vars) > 1) { goto err_unresolvable_vars; } else if (!forceWithPendingReq && - virNWFilterLookupLearnReq(ifindex) !=3D NULL) { + virNWFilterHasLearnReq(ifindex)) { goto err_exit; } =20 @@ -976,7 +976,7 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDef *= net) /* don't tear anything while the address is being learned */ if (virNetDevGetIndex(net->ifname, &ifindex) < 0) virResetLastError(); - else if (virNWFilterLookupLearnReq(ifindex) !=3D NULL) + else if (virNWFilterHasLearnReq(ifindex)) return 0; =20 return techdriver->tearNewRules(net->ifname); @@ -1002,7 +1002,7 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net) /* don't tear anything while the address is being learned */ if (virNetDevGetIndex(net->ifname, &ifindex) < 0) virResetLastError(); - else if (virNWFilterLookupLearnReq(ifindex) !=3D NULL) + else if (virNWFilterHasLearnReq(ifindex)) return 0; =20 return techdriver->tearOldRules(net->ifname); diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 2401857ddb..cc3bfd971c 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -133,6 +133,23 @@ struct _virNWFilterIfaceLock { int refctr; }; =20 +typedef struct _virNWFilterIPAddrLearnReq virNWFilterIPAddrLearnReq; +typedef virNWFilterIPAddrLearnReq *virNWFilterIPAddrLearnReqPtr; +struct _virNWFilterIPAddrLearnReq { + virNWFilterTechDriverPtr techdriver; + char ifname[IF_NAMESIZE]; + int ifindex; + char linkdev[IF_NAMESIZE]; + virMacAddr macaddr; + char *filtername; + virHashTablePtr filterparams; + virNWFilterDriverStatePtr driver; + enum howDetect howDetect; + + int status; + volatile bool terminate; +}; + =20 static bool threadsTerminate; =20 @@ -279,8 +296,8 @@ virNWFilterTerminateLearnReq(const char *ifname) } =20 =20 -virNWFilterIPAddrLearnReqPtr -virNWFilterLookupLearnReq(int ifindex) +bool +virNWFilterHasLearnReq(int ifindex) { void *res; IFINDEX2STR(ifindex_str, ifindex); @@ -291,7 +308,7 @@ virNWFilterLookupLearnReq(int ifindex) =20 virMutexUnlock(&pendingLearnReqLock); =20 - return res; + return res !=3D NULL; } =20 =20 diff --git a/src/nwfilter/nwfilter_learnipaddr.h b/src/nwfilter/nwfilter_le= arnipaddr.h index dc4c0d110f..06fea5bff8 100644 --- a/src/nwfilter/nwfilter_learnipaddr.h +++ b/src/nwfilter/nwfilter_learnipaddr.h @@ -35,23 +35,6 @@ enum howDetect { DETECT_STATIC =3D 2, }; =20 -typedef struct _virNWFilterIPAddrLearnReq virNWFilterIPAddrLearnReq; -typedef virNWFilterIPAddrLearnReq *virNWFilterIPAddrLearnReqPtr; -struct _virNWFilterIPAddrLearnReq { - virNWFilterTechDriverPtr techdriver; - char ifname[IF_NAMESIZE]; - int ifindex; - char linkdev[IF_NAMESIZE]; - virMacAddr macaddr; - char *filtername; - virHashTablePtr filterparams; - virNWFilterDriverStatePtr driver; - enum howDetect howDetect; - - int status; - volatile bool terminate; -}; - int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, const char *ifname, int ifindex, @@ -62,7 +45,7 @@ int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr te= chdriver, virNWFilterDriverStatePtr driver, enum howDetect howDetect); =20 -virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex); +bool virNWFilterHasLearnReq(int ifindex); int virNWFilterTerminateLearnReq(const char *ifname); =20 int virNWFilterLockIface(const char *ifname) ATTRIBUTE_RETURN_CHECK; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list