提交 593ba43f 编写于 作者: D Daniel P. Berrangé

nwfilter: introduce virNWFilterBinding to decouple from virDomainNet

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.
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 1c425d73
......@@ -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,57 @@ virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr 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 (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0)
goto error;
ret->mac = src->mac;
if (VIR_STRDUP(ret->filter, src->filter) < 0)
goto error;
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
goto error;
if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) < 0)
goto error;
return ret;
error:
virNWFilterBindingFree(ret);
return NULL;
}
......@@ -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;
};
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;
};
typedef enum {
STEP_APPLY_NEW,
......@@ -650,6 +663,11 @@ virNWFilterRuleIsProtocolIPv6(virNWFilterRuleDefPtr rule);
bool
virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule);
void
virNWFilterBindingFree(virNWFilterBindingPtr binding);
virNWFilterBindingPtr
virNWFilterBindingCopy(virNWFilterBindingPtr src);
VIR_ENUM_DECL(virNWFilterRuleAction);
VIR_ENUM_DECL(virNWFilterRuleDirection);
VIR_ENUM_DECL(virNWFilterRuleProtocol);
......
......@@ -780,6 +780,8 @@ virDomainNumatuneSpecifiedMaxNode;
# conf/nwfilter_conf.h
virNWFilterBindingCopy;
virNWFilterBindingFree;
virNWFilterCallbackDriversLock;
virNWFilterCallbackDriversUnlock;
virNWFilterChainSuffixTypeToString;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册