The virNWFilterIPAddrLearnReq type should only be used by the IP address learning code, so can live in the implementation file instead of header file. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/nwfilter/nwfilter_gentech_driver.c | 8 ++++---- src/nwfilter/nwfilter_learnipaddr.c | 23 ++++++++++++++++++++--- src/nwfilter/nwfilter_learnipaddr.h | 19 +------------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 0735426734..91794dd3ad 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -655,7 +655,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid, filter->name, vars, driver); goto err_exit; } else if (STRCASEEQ(learning, "any")) { - if (virNWFilterLookupLearnReq(ifindex) == NULL) { + if (!virNWFilterHasLearnReq(ifindex)) { rc = virNWFilterLearnIPAddress(techdriver, ifname, ifindex, @@ -680,7 +680,7 @@ virNWFilterDoInstantiate(const unsigned char *vmuuid, } else if (virHashSize(missing_vars) > 1) { goto err_unresolvable_vars; } else if (!forceWithPendingReq && - virNWFilterLookupLearnReq(ifindex) != NULL) { + virNWFilterHasLearnReq(ifindex)) { goto err_exit; } @@ -976,7 +976,7 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDef *net) /* don't tear anything while the address is being learned */ if (virNetDevGetIndex(net->ifname, &ifindex) < 0) virResetLastError(); - else if (virNWFilterLookupLearnReq(ifindex) != NULL) + else if (virNWFilterHasLearnReq(ifindex)) return 0; return techdriver->tearNewRules(net->ifname); @@ -1002,7 +1002,7 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net) /* don't tear anything while the address is being learned */ if (virNetDevGetIndex(net->ifname, &ifindex) < 0) virResetLastError(); - else if (virNWFilterLookupLearnReq(ifindex) != NULL) + else if (virNWFilterHasLearnReq(ifindex)) return 0; return techdriver->tearOldRules(net->ifname); diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 2401857ddb..cc3bfd971c 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -133,6 +133,23 @@ struct _virNWFilterIfaceLock { int refctr; }; +typedef struct _virNWFilterIPAddrLearnReq virNWFilterIPAddrLearnReq; +typedef virNWFilterIPAddrLearnReq *virNWFilterIPAddrLearnReqPtr; +struct _virNWFilterIPAddrLearnReq { + virNWFilterTechDriverPtr techdriver; + char ifname[IF_NAMESIZE]; + int ifindex; + char linkdev[IF_NAMESIZE]; + virMacAddr macaddr; + char *filtername; + virHashTablePtr filterparams; + virNWFilterDriverStatePtr driver; + enum howDetect howDetect; + + int status; + volatile bool terminate; +}; + static bool threadsTerminate; @@ -279,8 +296,8 @@ virNWFilterTerminateLearnReq(const char *ifname) } -virNWFilterIPAddrLearnReqPtr -virNWFilterLookupLearnReq(int ifindex) +bool +virNWFilterHasLearnReq(int ifindex) { void *res; IFINDEX2STR(ifindex_str, ifindex); @@ -291,7 +308,7 @@ virNWFilterLookupLearnReq(int ifindex) virMutexUnlock(&pendingLearnReqLock); - return res; + return res != NULL; } diff --git a/src/nwfilter/nwfilter_learnipaddr.h b/src/nwfilter/nwfilter_learnipaddr.h index dc4c0d110f..06fea5bff8 100644 --- a/src/nwfilter/nwfilter_learnipaddr.h +++ b/src/nwfilter/nwfilter_learnipaddr.h @@ -35,23 +35,6 @@ enum howDetect { DETECT_STATIC = 2, }; -typedef struct _virNWFilterIPAddrLearnReq virNWFilterIPAddrLearnReq; -typedef virNWFilterIPAddrLearnReq *virNWFilterIPAddrLearnReqPtr; -struct _virNWFilterIPAddrLearnReq { - virNWFilterTechDriverPtr techdriver; - char ifname[IF_NAMESIZE]; - int ifindex; - char linkdev[IF_NAMESIZE]; - virMacAddr macaddr; - char *filtername; - virHashTablePtr filterparams; - virNWFilterDriverStatePtr driver; - enum howDetect howDetect; - - int status; - volatile bool terminate; -}; - int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, const char *ifname, int ifindex, @@ -62,7 +45,7 @@ int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, virNWFilterDriverStatePtr driver, enum howDetect howDetect); -virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex); +bool virNWFilterHasLearnReq(int ifindex); int virNWFilterTerminateLearnReq(const char *ifname); int virNWFilterLockIface(const char *ifname) ATTRIBUTE_RETURN_CHECK; -- 2.14.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list