mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 11:01:19 +00:00
Use K&R style for curly braces in src/nwfilter/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
f84e17997b
commit
58d467116b
@ -2,7 +2,7 @@
|
|||||||
* nwfilter_driver.c: core driver for network filter APIs
|
* nwfilter_driver.c: core driver for network filter APIs
|
||||||
* (based on storage_driver.c)
|
* (based on storage_driver.c)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2011 Red Hat, Inc.
|
* Copyright (C) 2006-2011, 2014 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
|
||||||
* Copyright (C) 2010 Stefan Berger
|
* Copyright (C) 2010 Stefan Berger
|
||||||
@ -325,7 +325,8 @@ virNWFilterDriverIsWatchingFirewallD(void)
|
|||||||
* Shutdown the nwfilter driver, it will stop all active nwfilters
|
* Shutdown the nwfilter driver, it will stop all active nwfilters
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
nwfilterStateCleanup(void) {
|
nwfilterStateCleanup(void)
|
||||||
|
{
|
||||||
if (!driverState)
|
if (!driverState)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -356,7 +357,8 @@ nwfilterStateCleanup(void) {
|
|||||||
|
|
||||||
static virNWFilterPtr
|
static virNWFilterPtr
|
||||||
nwfilterLookupByUUID(virConnectPtr conn,
|
nwfilterLookupByUUID(virConnectPtr conn,
|
||||||
const unsigned char *uuid) {
|
const unsigned char *uuid)
|
||||||
|
{
|
||||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||||
virNWFilterObjPtr nwfilter;
|
virNWFilterObjPtr nwfilter;
|
||||||
virNWFilterPtr ret = NULL;
|
virNWFilterPtr ret = NULL;
|
||||||
@ -385,7 +387,8 @@ cleanup:
|
|||||||
|
|
||||||
static virNWFilterPtr
|
static virNWFilterPtr
|
||||||
nwfilterLookupByName(virConnectPtr conn,
|
nwfilterLookupByName(virConnectPtr conn,
|
||||||
const char *name) {
|
const char *name)
|
||||||
|
{
|
||||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||||
virNWFilterObjPtr nwfilter;
|
virNWFilterObjPtr nwfilter;
|
||||||
virNWFilterPtr ret = NULL;
|
virNWFilterPtr ret = NULL;
|
||||||
@ -428,14 +431,16 @@ nwfilterOpen(virConnectPtr conn,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nwfilterClose(virConnectPtr conn) {
|
nwfilterClose(virConnectPtr conn)
|
||||||
|
{
|
||||||
conn->nwfilterPrivateData = NULL;
|
conn->nwfilterPrivateData = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nwfilterConnectNumOfNWFilters(virConnectPtr conn) {
|
nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
||||||
|
{
|
||||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
@ -459,7 +464,8 @@ nwfilterConnectNumOfNWFilters(virConnectPtr conn) {
|
|||||||
static int
|
static int
|
||||||
nwfilterConnectListNWFilters(virConnectPtr conn,
|
nwfilterConnectListNWFilters(virConnectPtr conn,
|
||||||
char **const names,
|
char **const names,
|
||||||
int nnames) {
|
int nnames)
|
||||||
|
{
|
||||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||||
int got = 0;
|
int got = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -495,7 +501,8 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
|||||||
static int
|
static int
|
||||||
nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
||||||
virNWFilterPtr **filters,
|
virNWFilterPtr **filters,
|
||||||
unsigned int flags) {
|
unsigned int flags)
|
||||||
|
{
|
||||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||||
virNWFilterPtr *tmp_filters = NULL;
|
virNWFilterPtr *tmp_filters = NULL;
|
||||||
int nfilters = 0;
|
int nfilters = 0;
|
||||||
@ -594,7 +601,8 @@ cleanup:
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nwfilterUndefine(virNWFilterPtr obj) {
|
nwfilterUndefine(virNWFilterPtr obj)
|
||||||
|
{
|
||||||
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
|
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
|
||||||
virNWFilterObjPtr nwfilter;
|
virNWFilterObjPtr nwfilter;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -682,7 +690,8 @@ nwfilterInstantiateFilter(virConnectPtr conn,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nwfilterTeardownFilter(virDomainNetDefPtr net) {
|
nwfilterTeardownFilter(virDomainNetDefPtr net)
|
||||||
|
{
|
||||||
if ((net->ifname) && (net->filter))
|
if ((net->ifname) && (net->filter))
|
||||||
virNWFilterTeardownFilter(net);
|
virNWFilterTeardownFilter(net);
|
||||||
}
|
}
|
||||||
@ -717,7 +726,8 @@ static virDomainConfNWFilterDriver domainNWFilterDriver = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int nwfilterRegister(void) {
|
int nwfilterRegister(void)
|
||||||
|
{
|
||||||
if (virRegisterNWFilterDriver(&nwfilterDriver) < 0)
|
if (virRegisterNWFilterDriver(&nwfilterDriver) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (virRegisterStateDriver(&stateDriver) < 0)
|
if (virRegisterStateDriver(&stateDriver) < 0)
|
||||||
|
@ -3198,7 +3198,8 @@ ebiptablesInstCommand(virBufferPtr buf,
|
|||||||
* In case of this driver we need the ebtables tool available.
|
* In case of this driver we need the ebtables tool available.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ebiptablesCanApplyBasicRules(void) {
|
ebiptablesCanApplyBasicRules(void)
|
||||||
|
{
|
||||||
return ebtables_cmd_path != NULL;
|
return ebtables_cmd_path != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* nwfilter_learnipaddr.c: support for learning IP address used by a VM
|
* nwfilter_learnipaddr.c: support for learning IP address used by a VM
|
||||||
* on an interface
|
* on an interface
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011, 2013 Red Hat, Inc.
|
* Copyright (C) 2011, 2013, 2014 Red Hat, Inc.
|
||||||
* Copyright (C) 2010 IBM Corp.
|
* Copyright (C) 2010 IBM Corp.
|
||||||
* Copyright (C) 2010 Stefan Berger
|
* Copyright (C) 2010 Stefan Berger
|
||||||
*
|
*
|
||||||
@ -138,7 +138,8 @@ static bool threadsTerminate = false;
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virNWFilterLockIface(const char *ifname) {
|
virNWFilterLockIface(const char *ifname)
|
||||||
|
{
|
||||||
virNWFilterIfaceLockPtr ifaceLock;
|
virNWFilterIfaceLockPtr ifaceLock;
|
||||||
|
|
||||||
virMutexLock(&ifaceMapLock);
|
virMutexLock(&ifaceMapLock);
|
||||||
@ -188,13 +189,15 @@ virNWFilterLockIface(const char *ifname) {
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
freeIfaceLock(void *payload, const void *name ATTRIBUTE_UNUSED) {
|
freeIfaceLock(void *payload, const void *name ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
VIR_FREE(payload);
|
VIR_FREE(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virNWFilterUnlockIface(const char *ifname) {
|
virNWFilterUnlockIface(const char *ifname)
|
||||||
|
{
|
||||||
virNWFilterIfaceLockPtr ifaceLock;
|
virNWFilterIfaceLockPtr ifaceLock;
|
||||||
|
|
||||||
virMutexLock(&ifaceMapLock);
|
virMutexLock(&ifaceMapLock);
|
||||||
@ -214,7 +217,8 @@ virNWFilterUnlockIface(const char *ifname) {
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virNWFilterIPAddrLearnReqFree(virNWFilterIPAddrLearnReqPtr req) {
|
virNWFilterIPAddrLearnReqFree(virNWFilterIPAddrLearnReqPtr req)
|
||||||
|
{
|
||||||
if (!req)
|
if (!req)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -228,7 +232,8 @@ virNWFilterIPAddrLearnReqFree(virNWFilterIPAddrLearnReqPtr req) {
|
|||||||
#if HAVE_LIBPCAP
|
#if HAVE_LIBPCAP
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req) {
|
virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req)
|
||||||
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
IFINDEX2STR(ifindex_str, req->ifindex);
|
IFINDEX2STR(ifindex_str, req->ifindex);
|
||||||
|
|
||||||
@ -246,7 +251,8 @@ virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
virNWFilterTerminateLearnReq(const char *ifname) {
|
virNWFilterTerminateLearnReq(const char *ifname)
|
||||||
|
{
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
virNWFilterIPAddrLearnReqPtr req;
|
virNWFilterIPAddrLearnReqPtr req;
|
||||||
@ -281,7 +287,8 @@ virNWFilterTerminateLearnReq(const char *ifname) {
|
|||||||
|
|
||||||
|
|
||||||
virNWFilterIPAddrLearnReqPtr
|
virNWFilterIPAddrLearnReqPtr
|
||||||
virNWFilterLookupLearnReq(int ifindex) {
|
virNWFilterLookupLearnReq(int ifindex)
|
||||||
|
{
|
||||||
void *res;
|
void *res;
|
||||||
IFINDEX2STR(ifindex_str, ifindex);
|
IFINDEX2STR(ifindex_str, ifindex);
|
||||||
|
|
||||||
@ -296,7 +303,8 @@ virNWFilterLookupLearnReq(int ifindex) {
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED) {
|
freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
virNWFilterIPAddrLearnReqFree(payload);
|
virNWFilterIPAddrLearnReqFree(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +312,8 @@ freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED) {
|
|||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
|
|
||||||
static virNWFilterIPAddrLearnReqPtr
|
static virNWFilterIPAddrLearnReqPtr
|
||||||
virNWFilterDeregisterLearnReq(int ifindex) {
|
virNWFilterDeregisterLearnReq(int ifindex)
|
||||||
|
{
|
||||||
virNWFilterIPAddrLearnReqPtr res;
|
virNWFilterIPAddrLearnReqPtr res;
|
||||||
IFINDEX2STR(ifindex_str, ifindex);
|
IFINDEX2STR(ifindex_str, ifindex);
|
||||||
|
|
||||||
@ -324,7 +333,8 @@ virNWFilterDeregisterLearnReq(int ifindex) {
|
|||||||
static void
|
static void
|
||||||
procDHCPOpts(struct dhcp *dhcp, int dhcp_opts_len,
|
procDHCPOpts(struct dhcp *dhcp, int dhcp_opts_len,
|
||||||
uint32_t *vmaddr, uint32_t *bcastaddr,
|
uint32_t *vmaddr, uint32_t *bcastaddr,
|
||||||
enum howDetect *howDetected) {
|
enum howDetect *howDetected)
|
||||||
|
{
|
||||||
struct dhcp_option *dhcpopt = &dhcp->options[0];
|
struct dhcp_option *dhcpopt = &dhcp->options[0];
|
||||||
|
|
||||||
while (dhcp_opts_len >= 2) {
|
while (dhcp_opts_len >= 2) {
|
||||||
@ -683,7 +693,8 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
|
|||||||
const char *filtername,
|
const char *filtername,
|
||||||
virNWFilterHashTablePtr filterparams,
|
virNWFilterHashTablePtr filterparams,
|
||||||
virNWFilterDriverStatePtr driver,
|
virNWFilterDriverStatePtr driver,
|
||||||
enum howDetect howDetect) {
|
enum howDetect howDetect)
|
||||||
|
{
|
||||||
int rc;
|
int rc;
|
||||||
virNWFilterIPAddrLearnReqPtr req = NULL;
|
virNWFilterIPAddrLearnReqPtr req = NULL;
|
||||||
virNWFilterHashTablePtr ht = NULL;
|
virNWFilterHashTablePtr ht = NULL;
|
||||||
@ -788,7 +799,8 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
|
|||||||
* Initialization of this layer
|
* Initialization of this layer
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virNWFilterLearnInit(void) {
|
virNWFilterLearnInit(void)
|
||||||
|
{
|
||||||
|
|
||||||
if (pendingLearnReq)
|
if (pendingLearnReq)
|
||||||
return 0;
|
return 0;
|
||||||
@ -822,7 +834,8 @@ virNWFilterLearnInit(void) {
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virNWFilterLearnThreadsTerminate(bool allowNewThreads) {
|
virNWFilterLearnThreadsTerminate(bool allowNewThreads)
|
||||||
|
{
|
||||||
threadsTerminate = true;
|
threadsTerminate = true;
|
||||||
|
|
||||||
while (virHashSize(pendingLearnReq) != 0)
|
while (virHashSize(pendingLearnReq) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user