mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
nwfilter: re-order lock grabbed by IP addr. learn thread
The IP address learning thread was causing a deadlock when it instantiated a filter while a filter update/change was ongoing. The reason for this was the ordering of locks due to the following calls virNWFilterUnlockFilterUpdates() virNWFilterPoolObjFindByName() The below patch now puts the order of the locks in the above shown order when instantiating the filter from the IP address learning thread.
This commit is contained in:
@@ -552,6 +552,8 @@ virNWFilterRuleInstancesToArray(int nEntries,
|
|||||||
* all its subfilters in a depth-first traversal of the tree of referenced
|
* all its subfilters in a depth-first traversal of the tree of referenced
|
||||||
* filters. The name of the interface to which the rules belong must be
|
* filters. The name of the interface to which the rules belong must be
|
||||||
* provided. Apply the values of variables as needed.
|
* provided. Apply the values of variables as needed.
|
||||||
|
*
|
||||||
|
* Call this function while holding the NWFilter filter update lock
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virNWFilterInstantiate(virConnectPtr conn,
|
virNWFilterInstantiate(virConnectPtr conn,
|
||||||
@@ -575,8 +577,6 @@ virNWFilterInstantiate(virConnectPtr conn,
|
|||||||
void **ptrs = NULL;
|
void **ptrs = NULL;
|
||||||
int instantiate = 1;
|
int instantiate = 1;
|
||||||
|
|
||||||
virNWFilterLockFilterUpdates();
|
|
||||||
|
|
||||||
virNWFilterHashTablePtr missing_vars = virNWFilterHashTableCreate(0);
|
virNWFilterHashTablePtr missing_vars = virNWFilterHashTableCreate(0);
|
||||||
if (!missing_vars) {
|
if (!missing_vars) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@@ -668,8 +668,6 @@ virNWFilterInstantiate(virConnectPtr conn,
|
|||||||
|
|
||||||
err_exit:
|
err_exit:
|
||||||
|
|
||||||
virNWFilterUnlockFilterUpdates();
|
|
||||||
|
|
||||||
for (j = 0; j < nEntries; j++)
|
for (j = 0; j < nEntries; j++)
|
||||||
virNWFilterRuleInstFree(insts[j]);
|
virNWFilterRuleInstFree(insts[j]);
|
||||||
|
|
||||||
@@ -681,6 +679,9 @@ err_exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call this function while holding the NWFilter filter update lock
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
__virNWFilterInstantiateFilter(virConnectPtr conn,
|
__virNWFilterInstantiateFilter(virConnectPtr conn,
|
||||||
bool teardownOld,
|
bool teardownOld,
|
||||||
@@ -823,11 +824,14 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
|
|||||||
? net->data.direct.linkdev
|
? net->data.direct.linkdev
|
||||||
: NULL;
|
: NULL;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (ifaceGetIndex(true, net->ifname, &ifindex))
|
if (ifaceGetIndex(true, net->ifname, &ifindex))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return __virNWFilterInstantiateFilter(conn,
|
virNWFilterLockFilterUpdates();
|
||||||
|
|
||||||
|
rc = __virNWFilterInstantiateFilter(conn,
|
||||||
teardownOld,
|
teardownOld,
|
||||||
net->ifname,
|
net->ifname,
|
||||||
ifindex,
|
ifindex,
|
||||||
@@ -840,6 +844,10 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
|
|||||||
conn->nwfilterPrivateData,
|
conn->nwfilterPrivateData,
|
||||||
false,
|
false,
|
||||||
foundNewFilter);
|
foundNewFilter);
|
||||||
|
|
||||||
|
virNWFilterUnlockFilterUpdates();
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -857,6 +865,8 @@ virNWFilterInstantiateFilterLate(virConnectPtr conn,
|
|||||||
int rc;
|
int rc;
|
||||||
bool foundNewFilter = false;
|
bool foundNewFilter = false;
|
||||||
|
|
||||||
|
virNWFilterLockFilterUpdates();
|
||||||
|
|
||||||
rc = __virNWFilterInstantiateFilter(conn,
|
rc = __virNWFilterInstantiateFilter(conn,
|
||||||
1,
|
1,
|
||||||
ifname,
|
ifname,
|
||||||
@@ -878,6 +888,9 @@ virNWFilterInstantiateFilterLate(virConnectPtr conn,
|
|||||||
_virNWFilterTeardownFilter(ifname);
|
_virNWFilterTeardownFilter(ifname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virNWFilterUnlockFilterUpdates();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user