From nobody Thu Nov 28 10:40:38 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 1524843102332706.8693487035687; Fri, 27 Apr 2018 08:31:42 -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 C29385F7AF; Fri, 27 Apr 2018 15:31:40 +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 8C67C16D2F; Fri, 27 Apr 2018 15:31:40 +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 EC03D180596F; Fri, 27 Apr 2018 15:31:39 +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 w3RFPMUT032290 for ; Fri, 27 Apr 2018 11:25:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD17DAB3EF; Fri, 27 Apr 2018 15:25:22 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42D8883B77; Fri, 27 Apr 2018 15:25:22 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 27 Apr 2018 16:25:06 +0100 Message-Id: <20180427152513.28928-8-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 07/14] nwfilter: introduce virNWFilterBinding to decouple from virDomainNet 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.39]); Fri, 27 Apr 2018 15:31:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The virDomainNet struct contains everything related to configuring a guest network device. Out of all of this info, only 5 fields are relevant to configuring network filters. It will be more convenient for future changes to the nwfilter driver if the relevant fields are kept in a dedicated struct. Thus the virNWFilterBinding struct is created to track this information. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Jiri Denemark --- src/conf/nwfilter_conf.c | 53 ++++++++++++++++++++++++++++++++++++++++++++= +++- src/conf/nwfilter_conf.h | 18 +++++++++++++++- src/libvirt_private.syms | 2 ++ 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 5d04f2a93c..3d2ae9d0f3 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2,7 +2,7 @@ * nwfilter_conf.c: network filter XML processing * (derived from storage_conf.c) * - * Copyright (C) 2006-2014 Red Hat, Inc. + * Copyright (C) 2006-2018 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * Copyright (C) 2010-2011 IBM Corporation @@ -3265,3 +3265,54 @@ virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDef= Ptr rule) return true; return false; } + +void virNWFilterBindingFree(virNWFilterBindingPtr binding) +{ + if (!binding) + return; + + VIR_FREE(binding->ownername); + VIR_FREE(binding->portdevname); + VIR_FREE(binding->linkdevname); + VIR_FREE(binding->filter); + virHashFree(binding->filterparams); + + VIR_FREE(binding); +} + +virNWFilterBindingPtr virNWFilterBindingCopy(virNWFilterBindingPtr src) +{ + virNWFilterBindingPtr 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 (src->linkdevname && + 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: + virNWFilterBindingFree(ret); + return NULL; +} diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index a31db6d3ff..8c5421ee62 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -2,7 +2,7 @@ * nwfilter_conf.h: network filter XML processing * (derived from storage_conf.h) * - * Copyright (C) 2006-2010, 2012-2014 Red Hat, Inc. + * Copyright (C) 2006-2010, 2012-2018 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * Copyright (C) 2010 IBM Corporation @@ -545,6 +545,19 @@ struct _virNWFilterDef { virNWFilterEntryPtr *filterEntries; }; =20 +typedef struct virNWFilterBinding virNWFilterBinding; +typedef virNWFilterBinding *virNWFilterBindingPtr; + +struct virNWFilterBinding { + char *ownername; + unsigned char owneruuid[VIR_UUID_BUFLEN]; + char *portdevname; + char *linkdevname; + virMacAddr mac; + char *filter; + virHashTablePtr filterparams; +}; + =20 typedef enum { STEP_APPLY_NEW, @@ -650,6 +663,9 @@ virNWFilterRuleIsProtocolIPv6(virNWFilterRuleDefPtr rul= e); bool virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule); =20 +void virNWFilterBindingFree(virNWFilterBindingPtr binding); +virNWFilterBindingPtr virNWFilterBindingCopy(virNWFilterBindingPtr src); + VIR_ENUM_DECL(virNWFilterRuleAction); VIR_ENUM_DECL(virNWFilterRuleDirection); VIR_ENUM_DECL(virNWFilterRuleProtocol); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bf17d17777..9fc0aa470d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -780,6 +780,8 @@ virDomainNumatuneSpecifiedMaxNode; =20 =20 # conf/nwfilter_conf.h +virNWFilterBindingCopy; +virNWFilterBindingFree; virNWFilterCallbackDriversLock; virNWFilterCallbackDriversUnlock; virNWFilterChainSuffixTypeToString; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list