提交 979a3a95 编写于 作者: D Daniel P. Berrange 提交者: Laine Stump

Don't pass virConnectPtr in nwfilter 'struct domUpdateCBStruct'

The nwfilter driver only needs a reference to its private
state object, not a full virConnectPtr. Update the domUpdateCBStruct
struct to have a 'void *opaque' field instead of a virConnectPtr.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
(cherry picked from commit ebca369e)
上级 a591883a
...@@ -2865,6 +2865,7 @@ virNWFilterCallbackDriversUnlock(void) ...@@ -2865,6 +2865,7 @@ virNWFilterCallbackDriversUnlock(void)
static virDomainObjListIterator virNWFilterDomainFWUpdateCB; static virDomainObjListIterator virNWFilterDomainFWUpdateCB;
static void *virNWFilterDomainFWUpdateOpaque;
/** /**
* virNWFilterInstFiltersOnAllVMs: * virNWFilterInstFiltersOnAllVMs:
...@@ -2876,7 +2877,7 @@ virNWFilterInstFiltersOnAllVMs(virConnectPtr conn) ...@@ -2876,7 +2877,7 @@ virNWFilterInstFiltersOnAllVMs(virConnectPtr conn)
{ {
int i; int i;
struct domUpdateCBStruct cb = { struct domUpdateCBStruct cb = {
.conn = conn, .opaque = virNWFilterDomainFWUpdateOpaque,
.step = STEP_APPLY_CURRENT, .step = STEP_APPLY_CURRENT,
.skipInterfaces = NULL, /* not needed */ .skipInterfaces = NULL, /* not needed */
}; };
...@@ -2895,7 +2896,7 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn) ...@@ -2895,7 +2896,7 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
int i; int i;
int ret = 0; int ret = 0;
struct domUpdateCBStruct cb = { struct domUpdateCBStruct cb = {
.conn = conn, .opaque = virNWFilterDomainFWUpdateOpaque,
.step = STEP_APPLY_NEW, .step = STEP_APPLY_NEW,
.skipInterfaces = virHashCreate(0, NULL), .skipInterfaces = virHashCreate(0, NULL),
}; };
...@@ -3496,9 +3497,14 @@ char *virNWFilterConfigFile(const char *dir, ...@@ -3496,9 +3497,14 @@ char *virNWFilterConfigFile(const char *dir,
} }
int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB) int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB,
void *opaque)
{ {
if (initialized)
return -1;
virNWFilterDomainFWUpdateCB = domUpdateCB; virNWFilterDomainFWUpdateCB = domUpdateCB;
virNWFilterDomainFWUpdateOpaque = opaque;
initialized = true; initialized = true;
...@@ -3517,6 +3523,8 @@ void virNWFilterConfLayerShutdown(void) ...@@ -3517,6 +3523,8 @@ void virNWFilterConfLayerShutdown(void)
virMutexDestroy(&updateMutex); virMutexDestroy(&updateMutex);
initialized = false; initialized = false;
virNWFilterDomainFWUpdateOpaque = NULL;
virNWFilterDomainFWUpdateCB = NULL;
} }
......
...@@ -587,7 +587,7 @@ enum UpdateStep { ...@@ -587,7 +587,7 @@ enum UpdateStep {
}; };
struct domUpdateCBStruct { struct domUpdateCBStruct {
virConnectPtr conn; void *opaque;
enum UpdateStep step; enum UpdateStep step;
virHashTablePtr skipInterfaces; virHashTablePtr skipInterfaces;
}; };
...@@ -723,7 +723,7 @@ void virNWFilterObjUnlock(virNWFilterObjPtr obj); ...@@ -723,7 +723,7 @@ void virNWFilterObjUnlock(virNWFilterObjPtr obj);
void virNWFilterLockFilterUpdates(void); void virNWFilterLockFilterUpdates(void);
void virNWFilterUnlockFilterUpdates(void); void virNWFilterUnlockFilterUpdates(void);
int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB); int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB, void *opaque);
void virNWFilterConfLayerShutdown(void); void virNWFilterConfLayerShutdown(void);
int virNWFilterInstFiltersOnAllVMs(virConnectPtr conn); int virNWFilterInstFiltersOnAllVMs(virConnectPtr conn);
......
...@@ -481,15 +481,15 @@ virNWFilterSnoopIPLeaseInstallRule(virNWFilterSnoopIPLeasePtr ipl, ...@@ -481,15 +481,15 @@ virNWFilterSnoopIPLeaseInstallRule(virNWFilterSnoopIPLeasePtr ipl,
/* instantiate the filters */ /* instantiate the filters */
if (req->ifname) if (req->ifname)
rc = virNWFilterInstantiateFilterLate(NULL, rc = virNWFilterInstantiateFilterLate(req->driver,
NULL,
req->ifname, req->ifname,
req->ifindex, req->ifindex,
req->linkdev, req->linkdev,
req->nettype, req->nettype,
&req->macaddr, &req->macaddr,
req->filtername, req->filtername,
req->vars, req->vars);
req->driver);
exit_snooprequnlock: exit_snooprequnlock:
virNWFilterSnoopReqUnlock(req); virNWFilterSnoopReqUnlock(req);
...@@ -871,15 +871,15 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req, ...@@ -871,15 +871,15 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
goto skip_instantiate; goto skip_instantiate;
if (ipAddrLeft) { if (ipAddrLeft) {
ret = virNWFilterInstantiateFilterLate(NULL, ret = virNWFilterInstantiateFilterLate(req->driver,
NULL,
req->ifname, req->ifname,
req->ifindex, req->ifindex,
req->linkdev, req->linkdev,
req->nettype, req->nettype,
&req->macaddr, &req->macaddr,
req->filtername, req->filtername,
req->vars, req->vars);
req->driver);
} else { } else {
const virNWFilterVarValuePtr dhcpsrvrs = const virNWFilterVarValuePtr dhcpsrvrs =
virHashLookup(req->vars->hashTable, NWFILTER_VARNAME_DHCPSERVER); virHashLookup(req->vars->hashTable, NWFILTER_VARNAME_DHCPSERVER);
......
...@@ -199,7 +199,8 @@ nwfilterDriverStartup(bool privileged, ...@@ -199,7 +199,8 @@ nwfilterDriverStartup(bool privileged,
virNWFilterTechDriversInit(privileged); virNWFilterTechDriversInit(privileged);
if (virNWFilterConfLayerInit(virNWFilterDomainFWUpdateCB) < 0) if (virNWFilterConfLayerInit(virNWFilterDomainFWUpdateCB,
driverState) < 0)
goto err_techdrivers_shutdown; goto err_techdrivers_shutdown;
nwfilterDriverLock(driverState); nwfilterDriverLock(driverState);
...@@ -646,7 +647,7 @@ nwfilterInstantiateFilter(virConnectPtr conn, ...@@ -646,7 +647,7 @@ nwfilterInstantiateFilter(virConnectPtr conn,
const unsigned char *vmuuid, const unsigned char *vmuuid,
virDomainNetDefPtr net) virDomainNetDefPtr net)
{ {
return virNWFilterInstantiateFilter(conn, vmuuid, net); return virNWFilterInstantiateFilter(conn->nwfilterPrivateData, vmuuid, net);
} }
......
...@@ -812,7 +812,8 @@ err_unresolvable_vars: ...@@ -812,7 +812,8 @@ err_unresolvable_vars:
* Call this function while holding the NWFilter filter update lock * Call this function while holding the NWFilter filter update lock
*/ */
static int static int
__virNWFilterInstantiateFilter(const unsigned char *vmuuid, __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid,
bool teardownOld, bool teardownOld,
const char *ifname, const char *ifname,
int ifindex, int ifindex,
...@@ -822,7 +823,6 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid, ...@@ -822,7 +823,6 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
const char *filtername, const char *filtername,
virNWFilterHashTablePtr filterparams, virNWFilterHashTablePtr filterparams,
enum instCase useNewFilter, enum instCase useNewFilter,
virNWFilterDriverStatePtr driver,
bool forceWithPendingReq, bool forceWithPendingReq,
bool *foundNewFilter) bool *foundNewFilter)
{ {
...@@ -935,7 +935,7 @@ err_exit: ...@@ -935,7 +935,7 @@ err_exit:
static int static int
_virNWFilterInstantiateFilter(virConnectPtr conn, _virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid, const unsigned char *vmuuid,
const virDomainNetDefPtr net, const virDomainNetDefPtr net,
bool teardownOld, bool teardownOld,
...@@ -962,7 +962,8 @@ _virNWFilterInstantiateFilter(virConnectPtr conn, ...@@ -962,7 +962,8 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
rc = __virNWFilterInstantiateFilter(vmuuid, rc = __virNWFilterInstantiateFilter(driver,
vmuuid,
teardownOld, teardownOld,
net->ifname, net->ifname,
ifindex, ifindex,
...@@ -972,7 +973,6 @@ _virNWFilterInstantiateFilter(virConnectPtr conn, ...@@ -972,7 +973,6 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
net->filter, net->filter,
net->filterparams, net->filterparams,
useNewFilter, useNewFilter,
conn->nwfilterPrivateData,
false, false,
foundNewFilter); foundNewFilter);
...@@ -984,22 +984,23 @@ cleanup: ...@@ -984,22 +984,23 @@ cleanup:
int int
virNWFilterInstantiateFilterLate(const unsigned char *vmuuid, virNWFilterInstantiateFilterLate(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid,
const char *ifname, const char *ifname,
int ifindex, int ifindex,
const char *linkdev, const char *linkdev,
enum virDomainNetType nettype, enum virDomainNetType nettype,
const virMacAddrPtr macaddr, const virMacAddrPtr macaddr,
const char *filtername, const char *filtername,
virNWFilterHashTablePtr filterparams, virNWFilterHashTablePtr filterparams)
virNWFilterDriverStatePtr driver)
{ {
int rc; int rc;
bool foundNewFilter = false; bool foundNewFilter = false;
virNWFilterLockFilterUpdates(); virNWFilterLockFilterUpdates();
rc = __virNWFilterInstantiateFilter(vmuuid, rc = __virNWFilterInstantiateFilter(driver,
vmuuid,
true, true,
ifname, ifname,
ifindex, ifindex,
...@@ -1009,7 +1010,6 @@ virNWFilterInstantiateFilterLate(const unsigned char *vmuuid, ...@@ -1009,7 +1010,6 @@ virNWFilterInstantiateFilterLate(const unsigned char *vmuuid,
filtername, filtername,
filterparams, filterparams,
INSTANTIATE_ALWAYS, INSTANTIATE_ALWAYS,
driver,
true, true,
&foundNewFilter); &foundNewFilter);
if (rc < 0) { if (rc < 0) {
...@@ -1029,13 +1029,13 @@ virNWFilterInstantiateFilterLate(const unsigned char *vmuuid, ...@@ -1029,13 +1029,13 @@ virNWFilterInstantiateFilterLate(const unsigned char *vmuuid,
int int
virNWFilterInstantiateFilter(virConnectPtr conn, virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid, const unsigned char *vmuuid,
const virDomainNetDefPtr net) const virDomainNetDefPtr net)
{ {
bool foundNewFilter = false; bool foundNewFilter = false;
return _virNWFilterInstantiateFilter(conn, vmuuid, net, return _virNWFilterInstantiateFilter(driver, vmuuid, net,
1, 1,
INSTANTIATE_ALWAYS, INSTANTIATE_ALWAYS,
&foundNewFilter); &foundNewFilter);
...@@ -1043,14 +1043,14 @@ virNWFilterInstantiateFilter(virConnectPtr conn, ...@@ -1043,14 +1043,14 @@ virNWFilterInstantiateFilter(virConnectPtr conn,
int int
virNWFilterUpdateInstantiateFilter(virConnectPtr conn, virNWFilterUpdateInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid, const unsigned char *vmuuid,
const virDomainNetDefPtr net, const virDomainNetDefPtr net,
bool *skipIface) bool *skipIface)
{ {
bool foundNewFilter = false; bool foundNewFilter = false;
int rc = _virNWFilterInstantiateFilter(conn, vmuuid, net, int rc = _virNWFilterInstantiateFilter(driver, vmuuid, net,
0, 0,
INSTANTIATE_FOLLOW_NEWFILTER, INSTANTIATE_FOLLOW_NEWFILTER,
&foundNewFilter); &foundNewFilter);
...@@ -1168,7 +1168,7 @@ virNWFilterDomainFWUpdateCB(virDomainObjPtr obj, ...@@ -1168,7 +1168,7 @@ virNWFilterDomainFWUpdateCB(virDomainObjPtr obj,
if ((net->filter) && (net->ifname)) { if ((net->filter) && (net->ifname)) {
switch (cb->step) { switch (cb->step) {
case STEP_APPLY_NEW: case STEP_APPLY_NEW:
ret = virNWFilterUpdateInstantiateFilter(cb->conn, ret = virNWFilterUpdateInstantiateFilter(cb->opaque,
vm->uuid, vm->uuid,
net, net,
&skipIface); &skipIface);
...@@ -1193,7 +1193,7 @@ virNWFilterDomainFWUpdateCB(virDomainObjPtr obj, ...@@ -1193,7 +1193,7 @@ virNWFilterDomainFWUpdateCB(virDomainObjPtr obj,
break; break;
case STEP_APPLY_CURRENT: case STEP_APPLY_CURRENT:
ret = virNWFilterInstantiateFilter(cb->conn, ret = virNWFilterInstantiateFilter(cb->opaque,
vm->uuid, vm->uuid,
net); net);
if (ret) if (ret)
......
...@@ -39,23 +39,23 @@ enum instCase { ...@@ -39,23 +39,23 @@ enum instCase {
}; };
int virNWFilterInstantiateFilter(virConnectPtr conn, int virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid, const unsigned char *vmuuid,
const virDomainNetDefPtr net); const virDomainNetDefPtr net);
int virNWFilterUpdateInstantiateFilter(virConnectPtr conn, int virNWFilterUpdateInstantiateFilter(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid, const unsigned char *vmuuid,
const virDomainNetDefPtr net, const virDomainNetDefPtr net,
bool *skipIface); bool *skipIface);
int virNWFilterInstantiateFilterLate(const unsigned char *vmuuid, int virNWFilterInstantiateFilterLate(virNWFilterDriverStatePtr driver,
const unsigned char *vmuuid,
const char *ifname, const char *ifname,
int ifindex, int ifindex,
const char *linkdev, const char *linkdev,
enum virDomainNetType nettype, enum virDomainNetType nettype,
const virMacAddrPtr macaddr, const virMacAddrPtr macaddr,
const char *filtername, const char *filtername,
virNWFilterHashTablePtr filterparams, virNWFilterHashTablePtr filterparams);
virNWFilterDriverStatePtr driver);
int virNWFilterTeardownFilter(const virDomainNetDefPtr net); int virNWFilterTeardownFilter(const virDomainNetDefPtr net);
......
...@@ -595,15 +595,15 @@ learnIPAddressThread(void *arg) ...@@ -595,15 +595,15 @@ learnIPAddressThread(void *arg)
"cache for interface %s"), inetaddr, req->ifname); "cache for interface %s"), inetaddr, req->ifname);
} }
ret = virNWFilterInstantiateFilterLate(NULL, ret = virNWFilterInstantiateFilterLate(req->driver,
NULL,
req->ifname, req->ifname,
req->ifindex, req->ifindex,
req->linkdev, req->linkdev,
req->nettype, req->nettype,
&req->macaddr, &req->macaddr,
req->filtername, req->filtername,
req->filterparams, req->filterparams);
req->driver);
VIR_DEBUG("Result from applying firewall rules on " VIR_DEBUG("Result from applying firewall rules on "
"%s with IP addr %s : %d\n", req->ifname, inetaddr, ret); "%s with IP addr %s : %d\n", req->ifname, inetaddr, ret);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册