Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/nwfilter/nwfilter_driver.c | 32 +++++++++++++++---------
src/nwfilter/nwfilter_ebiptables_driver.c | 3 ++-
src/nwfilter/nwfilter_learnipaddr.c | 41 ++++++++++++++++++++-----------
3 files changed, 50 insertions(+), 26 deletions(-)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 0876901..4fab1f2 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -2,7 +2,7 @@
* nwfilter_driver.c: core driver for network filter APIs
* (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) 2010 IBM Corporation
* Copyright (C) 2010 Stefan Berger
@@ -325,7 +325,8 @@ virNWFilterDriverIsWatchingFirewallD(void)
* Shutdown the nwfilter driver, it will stop all active nwfilters
*/
static int
-nwfilterStateCleanup(void) {
+nwfilterStateCleanup(void)
+{
if (!driverState)
return -1;
@@ -356,7 +357,8 @@ nwfilterStateCleanup(void) {
static virNWFilterPtr
nwfilterLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid) {
+ const unsigned char *uuid)
+{
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
virNWFilterObjPtr nwfilter;
virNWFilterPtr ret = NULL;
@@ -385,7 +387,8 @@ cleanup:
static virNWFilterPtr
nwfilterLookupByName(virConnectPtr conn,
- const char *name) {
+ const char *name)
+{
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
virNWFilterObjPtr nwfilter;
virNWFilterPtr ret = NULL;
@@ -428,14 +431,16 @@ nwfilterOpen(virConnectPtr conn,
static int
-nwfilterClose(virConnectPtr conn) {
+nwfilterClose(virConnectPtr conn)
+{
conn->nwfilterPrivateData = NULL;
return 0;
}
static int
-nwfilterConnectNumOfNWFilters(virConnectPtr conn) {
+nwfilterConnectNumOfNWFilters(virConnectPtr conn)
+{
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
size_t i;
int n;
@@ -459,7 +464,8 @@ nwfilterConnectNumOfNWFilters(virConnectPtr conn) {
static int
nwfilterConnectListNWFilters(virConnectPtr conn,
char **const names,
- int nnames) {
+ int nnames)
+{
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
int got = 0;
size_t i;
@@ -495,7 +501,8 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
static int
nwfilterConnectListAllNWFilters(virConnectPtr conn,
virNWFilterPtr **filters,
- unsigned int flags) {
+ unsigned int flags)
+{
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
virNWFilterPtr *tmp_filters = NULL;
int nfilters = 0;
@@ -594,7 +601,8 @@ cleanup:
static int
-nwfilterUndefine(virNWFilterPtr obj) {
+nwfilterUndefine(virNWFilterPtr obj)
+{
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
virNWFilterObjPtr nwfilter;
int ret = -1;
@@ -682,7 +690,8 @@ nwfilterInstantiateFilter(virConnectPtr conn,
static void
-nwfilterTeardownFilter(virDomainNetDefPtr net) {
+nwfilterTeardownFilter(virDomainNetDefPtr net)
+{
if ((net->ifname) && (net->filter))
virNWFilterTeardownFilter(net);
}
@@ -717,7 +726,8 @@ static virDomainConfNWFilterDriver domainNWFilterDriver = {
};
-int nwfilterRegister(void) {
+int nwfilterRegister(void)
+{
if (virRegisterNWFilterDriver(&nwfilterDriver) < 0)
return -1;
if (virRegisterStateDriver(&stateDriver) < 0)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c
b/src/nwfilter/nwfilter_ebiptables_driver.c
index 6909a9a..e535356 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -3198,7 +3198,8 @@ ebiptablesInstCommand(virBufferPtr buf,
* In case of this driver we need the ebtables tool available.
*/
static int
-ebiptablesCanApplyBasicRules(void) {
+ebiptablesCanApplyBasicRules(void)
+{
return ebtables_cmd_path != NULL;
}
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index e156a93..e01d4df 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -2,7 +2,7 @@
* nwfilter_learnipaddr.c: support for learning IP address used by a VM
* 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 Stefan Berger
*
@@ -138,7 +138,8 @@ static bool threadsTerminate = false;
int
-virNWFilterLockIface(const char *ifname) {
+virNWFilterLockIface(const char *ifname)
+{
virNWFilterIfaceLockPtr ifaceLock;
virMutexLock(&ifaceMapLock);
@@ -188,13 +189,15 @@ virNWFilterLockIface(const char *ifname) {
static void
-freeIfaceLock(void *payload, const void *name ATTRIBUTE_UNUSED) {
+freeIfaceLock(void *payload, const void *name ATTRIBUTE_UNUSED)
+{
VIR_FREE(payload);
}
void
-virNWFilterUnlockIface(const char *ifname) {
+virNWFilterUnlockIface(const char *ifname)
+{
virNWFilterIfaceLockPtr ifaceLock;
virMutexLock(&ifaceMapLock);
@@ -214,7 +217,8 @@ virNWFilterUnlockIface(const char *ifname) {
static void
-virNWFilterIPAddrLearnReqFree(virNWFilterIPAddrLearnReqPtr req) {
+virNWFilterIPAddrLearnReqFree(virNWFilterIPAddrLearnReqPtr req)
+{
if (!req)
return;
@@ -228,7 +232,8 @@ virNWFilterIPAddrLearnReqFree(virNWFilterIPAddrLearnReqPtr req) {
#if HAVE_LIBPCAP
static int
-virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req) {
+virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req)
+{
int res = -1;
IFINDEX2STR(ifindex_str, req->ifindex);
@@ -246,7 +251,8 @@ virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req) {
#endif
int
-virNWFilterTerminateLearnReq(const char *ifname) {
+virNWFilterTerminateLearnReq(const char *ifname)
+{
int rc = -1;
int ifindex;
virNWFilterIPAddrLearnReqPtr req;
@@ -281,7 +287,8 @@ virNWFilterTerminateLearnReq(const char *ifname) {
virNWFilterIPAddrLearnReqPtr
-virNWFilterLookupLearnReq(int ifindex) {
+virNWFilterLookupLearnReq(int ifindex)
+{
void *res;
IFINDEX2STR(ifindex_str, ifindex);
@@ -296,7 +303,8 @@ virNWFilterLookupLearnReq(int ifindex) {
static void
-freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED) {
+freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED)
+{
virNWFilterIPAddrLearnReqFree(payload);
}
@@ -304,7 +312,8 @@ freeLearnReqEntry(void *payload, const void *name ATTRIBUTE_UNUSED) {
#ifdef HAVE_LIBPCAP
static virNWFilterIPAddrLearnReqPtr
-virNWFilterDeregisterLearnReq(int ifindex) {
+virNWFilterDeregisterLearnReq(int ifindex)
+{
virNWFilterIPAddrLearnReqPtr res;
IFINDEX2STR(ifindex_str, ifindex);
@@ -324,7 +333,8 @@ virNWFilterDeregisterLearnReq(int ifindex) {
static void
procDHCPOpts(struct dhcp *dhcp, int dhcp_opts_len,
uint32_t *vmaddr, uint32_t *bcastaddr,
- enum howDetect *howDetected) {
+ enum howDetect *howDetected)
+{
struct dhcp_option *dhcpopt = &dhcp->options[0];
while (dhcp_opts_len >= 2) {
@@ -683,7 +693,8 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
const char *filtername,
virNWFilterHashTablePtr filterparams,
virNWFilterDriverStatePtr driver,
- enum howDetect howDetect) {
+ enum howDetect howDetect)
+{
int rc;
virNWFilterIPAddrLearnReqPtr req = NULL;
virNWFilterHashTablePtr ht = NULL;
@@ -788,7 +799,8 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver
ATTRIBUTE_UNUSED,
* Initialization of this layer
*/
int
-virNWFilterLearnInit(void) {
+virNWFilterLearnInit(void)
+{
if (pendingLearnReq)
return 0;
@@ -822,7 +834,8 @@ virNWFilterLearnInit(void) {
void
-virNWFilterLearnThreadsTerminate(bool allowNewThreads) {
+virNWFilterLearnThreadsTerminate(bool allowNewThreads)
+{
threadsTerminate = true;
while (virHashSize(pendingLearnReq) != 0)
--
1.9.0