mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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: Jiri Denemark <jdenemar@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
1c425d735d
commit
593ba43f1f
@ -2,7 +2,7 @@
|
|||||||
* nwfilter_conf.c: network filter XML processing
|
* nwfilter_conf.c: network filter XML processing
|
||||||
* (derived from storage_conf.c)
|
* (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) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2011 IBM Corporation
|
* Copyright (C) 2010-2011 IBM Corporation
|
||||||
@ -3265,3 +3265,57 @@ virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule)
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
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
|
* nwfilter_conf.h: network filter XML processing
|
||||||
* (derived from storage_conf.h)
|
* (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) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 IBM Corporation
|
* Copyright (C) 2010 IBM Corporation
|
||||||
@ -545,6 +545,19 @@ struct _virNWFilterDef {
|
|||||||
virNWFilterEntryPtr *filterEntries;
|
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 {
|
typedef enum {
|
||||||
STEP_APPLY_NEW,
|
STEP_APPLY_NEW,
|
||||||
@ -650,6 +663,11 @@ virNWFilterRuleIsProtocolIPv6(virNWFilterRuleDefPtr rule);
|
|||||||
bool
|
bool
|
||||||
virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule);
|
virNWFilterRuleIsProtocolEthernet(virNWFilterRuleDefPtr rule);
|
||||||
|
|
||||||
|
void
|
||||||
|
virNWFilterBindingFree(virNWFilterBindingPtr binding);
|
||||||
|
virNWFilterBindingPtr
|
||||||
|
virNWFilterBindingCopy(virNWFilterBindingPtr src);
|
||||||
|
|
||||||
VIR_ENUM_DECL(virNWFilterRuleAction);
|
VIR_ENUM_DECL(virNWFilterRuleAction);
|
||||||
VIR_ENUM_DECL(virNWFilterRuleDirection);
|
VIR_ENUM_DECL(virNWFilterRuleDirection);
|
||||||
VIR_ENUM_DECL(virNWFilterRuleProtocol);
|
VIR_ENUM_DECL(virNWFilterRuleProtocol);
|
||||||
|
@ -780,6 +780,8 @@ virDomainNumatuneSpecifiedMaxNode;
|
|||||||
|
|
||||||
|
|
||||||
# conf/nwfilter_conf.h
|
# conf/nwfilter_conf.h
|
||||||
|
virNWFilterBindingCopy;
|
||||||
|
virNWFilterBindingFree;
|
||||||
virNWFilterCallbackDriversLock;
|
virNWFilterCallbackDriversLock;
|
||||||
virNWFilterCallbackDriversUnlock;
|
virNWFilterCallbackDriversUnlock;
|
||||||
virNWFilterChainSuffixTypeToString;
|
virNWFilterChainSuffixTypeToString;
|
||||||
|
Loading…
Reference in New Issue
Block a user