From nobody Wed May 14 01:03:57 2025 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 1526406231000166.00240941013544; Tue, 15 May 2018 10:43:51 -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 E1DCF31179BE; Tue, 15 May 2018 17:43:48 +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 221445D6B4; Tue, 15 May 2018 17:43:48 +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 1AFA3180B5AA; Tue, 15 May 2018 17:43:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4FHhhsq004209 for ; Tue, 15 May 2018 13:43:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D3FB1002973; Tue, 15 May 2018 17:43:43 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08A9F10A7E3B; Tue, 15 May 2018 17:43:42 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 15 May 2018 18:43:20 +0100 Message-Id: <20180515174337.11287-5-berrange@redhat.com> In-Reply-To: <20180515174337.11287-1-berrange@redhat.com> References: <20180515174337.11287-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 04/21] conf: move virNWFilterBindingDefPtr into its own files 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.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.47]); Tue, 15 May 2018 17:43:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 There's no code sharing between virNWFilterDef and virNWFilterBindingDefPtr types, so it is clearer if they live in separate source files and headers. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/conf/Makefile.inc.am | 2 + src/conf/nwfilter_conf.c | 54 --------------------- src/conf/nwfilter_conf.h | 17 ------- src/conf/virnwfilterbindingdef.c | 83 ++++++++++++++++++++++++++++++++ src/conf/virnwfilterbindingdef.h | 47 ++++++++++++++++++ src/libvirt_private.syms | 7 ++- 6 files changed, 137 insertions(+), 73 deletions(-) create mode 100644 src/conf/virnwfilterbindingdef.c create mode 100644 src/conf/virnwfilterbindingdef.h diff --git a/src/conf/Makefile.inc.am b/src/conf/Makefile.inc.am index 6d7b0f076b..f5fb323233 100644 --- a/src/conf/Makefile.inc.am +++ b/src/conf/Makefile.inc.am @@ -85,6 +85,8 @@ NWFILTER_CONF_SOURCES =3D \ conf/nwfilter_conf.h \ conf/virnwfilterobj.c \ conf/virnwfilterobj.h \ + conf/virnwfilterbindingdef.c \ + conf/virnwfilterbindingdef.h \ $(NULL) =20 STORAGE_CONF_SOURCES =3D \ diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 6422f6b8ea..de26a6d034 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -3265,57 +3265,3 @@ virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDef= Ptr rule) return true; return false; } - - -void -virNWFilterBindingDefFree(virNWFilterBindingDefPtr def) -{ - if (!def) - return; - - VIR_FREE(def->ownername); - VIR_FREE(def->portdevname); - VIR_FREE(def->linkdevname); - VIR_FREE(def->filter); - virHashFree(def->filterparams); - - VIR_FREE(def); -} - - -virNWFilterBindingDefPtr -virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src) -{ - virNWFilterBindingDefPtr ret; - - if (VIR_ALLOC(ret) < 0) - return NULL; - - if (VIR_STRDUP(ret->ownername, src->ownername) < 0) - goto error; - - memcpy(ret->owneruuid, src->owneruuid, sizeof(ret->owneruuid)); - - if (VIR_STRDUP(ret->portdevname, src->portdevname) < 0) - goto error; - - if (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0) - goto error; - - ret->mac =3D src->mac; - - if (VIR_STRDUP(ret->filter, src->filter) < 0) - goto error; - - if (!(ret->filterparams =3D virNWFilterHashTableCreate(0))) - goto error; - - if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) <= 0) - goto error; - - return ret; - - error: - virNWFilterBindingDefFree(ret); - return NULL; -} diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index c72171f2f2..08fc07c55c 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -545,19 +545,6 @@ struct _virNWFilterDef { virNWFilterEntryPtr *filterEntries; }; =20 -typedef struct _virNWFilterBindingDef virNWFilterBindingDef; -typedef virNWFilterBindingDef *virNWFilterBindingDefPtr; - -struct _virNWFilterBindingDef { - char *ownername; - unsigned char owneruuid[VIR_UUID_BUFLEN]; - char *portdevname; - char *linkdevname; - virMacAddr mac; - char *filter; - virHashTablePtr filterparams; -}; - =20 typedef enum { STEP_APPLY_NEW, @@ -663,10 +650,6 @@ virNWFilterRuleIsProtocolIPv6(virNWFilterRuleDefPtr ru= le); bool virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule); =20 -void -virNWFilterBindingDefFree(virNWFilterBindingDefPtr binding); -virNWFilterBindingDefPtr -virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src); =20 VIR_ENUM_DECL(virNWFilterRuleAction); VIR_ENUM_DECL(virNWFilterRuleDirection); diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbinding= def.c new file mode 100644 index 0000000000..c7533d4063 --- /dev/null +++ b/src/conf/virnwfilterbindingdef.c @@ -0,0 +1,83 @@ +/* + * virnwfilterbindingdef.c: network filter binding XML processing + * + * Copyright (C) 2018 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "viralloc.h" +#include "virerror.h" +#include "virstring.h" +#include "nwfilter_params.h" +#include "virnwfilterbindingdef.h" + + +#define VIR_FROM_THIS VIR_FROM_NWFILTER + +void +virNWFilterBindingDefFree(virNWFilterBindingDefPtr def) +{ + if (!def) + return; + + VIR_FREE(def->ownername); + VIR_FREE(def->portdevname); + VIR_FREE(def->linkdevname); + VIR_FREE(def->filter); + virHashFree(def->filterparams); + + VIR_FREE(def); +} + + +virNWFilterBindingDefPtr +virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src) +{ + virNWFilterBindingDefPtr ret; + + if (VIR_ALLOC(ret) < 0) + return NULL; + + if (VIR_STRDUP(ret->ownername, src->ownername) < 0) + goto error; + + memcpy(ret->owneruuid, src->owneruuid, sizeof(ret->owneruuid)); + + if (VIR_STRDUP(ret->portdevname, src->portdevname) < 0) + goto error; + + if (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0) + goto error; + + ret->mac =3D src->mac; + + if (VIR_STRDUP(ret->filter, src->filter) < 0) + goto error; + + if (!(ret->filterparams =3D virNWFilterHashTableCreate(0))) + goto error; + + if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) <= 0) + goto error; + + return ret; + + error: + virNWFilterBindingDefFree(ret); + return NULL; +} diff --git a/src/conf/virnwfilterbindingdef.h b/src/conf/virnwfilterbinding= def.h new file mode 100644 index 0000000000..e3b18af151 --- /dev/null +++ b/src/conf/virnwfilterbindingdef.h @@ -0,0 +1,47 @@ +/* + * virnwfilterbindingdef.h: network filter binding XML processing + * + * Copyright (C) 2018 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ +#ifndef VIR_NWFILTER_BINDING_DEF_H +# define VIR_NWFILTER_BINDING_DEF_H + +# include "internal.h" +# include "virmacaddr.h" +# include "virhash.h" + +typedef struct _virNWFilterBindingDef virNWFilterBindingDef; +typedef virNWFilterBindingDef *virNWFilterBindingDefPtr; + +struct _virNWFilterBindingDef { + char *ownername; + unsigned char owneruuid[VIR_UUID_BUFLEN]; + char *portdevname; + char *linkdevname; + virMacAddr mac; + char *filter; + virHashTablePtr filterparams; +}; + + +void +virNWFilterBindingDefFree(virNWFilterBindingDefPtr binding); +virNWFilterBindingDefPtr +virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src); + +#endif /* VIR_NWFILTER_BINDING_DEF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 80062df3f7..fb754fbfea 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -781,8 +781,6 @@ virDomainNumatuneSpecifiedMaxNode; =20 =20 # conf/nwfilter_conf.h -virNWFilterBindingDefCopy; -virNWFilterBindingDefFree; virNWFilterCallbackDriversLock; virNWFilterCallbackDriversUnlock; virNWFilterChainSuffixTypeToString; @@ -1043,6 +1041,11 @@ virNodeDeviceObjListNumOfDevices; virNodeDeviceObjListRemove; =20 =20 +# conf/virnwfilterbindingdef.h +virNWFilterBindingDefCopy; +virNWFilterBindingDefFree; + + # conf/virnwfilterobj.h virNWFilterObjGetDef; virNWFilterObjGetNewDef; --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list