diff options
author | Stefan Berger <stefanb@us.ibm.com> | 2010-11-19 20:41:25 -0500 |
---|---|---|
committer | Stefan Berger <stefanb@us.ibm.com> | 2010-11-19 20:41:25 -0500 |
commit | 52834904d2666894242b2f824229c98ed3a74a81 (patch) | |
tree | ed7fe97ec36fbeeb537df799be7ab859100223d4 /src/nwfilter/nwfilter_gentech_driver.c | |
parent | Support for probing qed image metadata (diff) | |
download | libvirt-52834904d2666894242b2f824229c98ed3a74a81.tar.gz libvirt-52834904d2666894242b2f824229c98ed3a74a81.tar.bz2 libvirt-52834904d2666894242b2f824229c98ed3a74a81.zip |
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.
Diffstat (limited to 'src/nwfilter/nwfilter_gentech_driver.c')
-rw-r--r-- | src/nwfilter/nwfilter_gentech_driver.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 494637354..fcd479cc0 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -552,6 +552,8 @@ virNWFilterRuleInstancesToArray(int nEntries, * 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 * provided. Apply the values of variables as needed. + * + * Call this function while holding the NWFilter filter update lock */ static int virNWFilterInstantiate(virConnectPtr conn, @@ -575,8 +577,6 @@ virNWFilterInstantiate(virConnectPtr conn, void **ptrs = NULL; int instantiate = 1; - virNWFilterLockFilterUpdates(); - virNWFilterHashTablePtr missing_vars = virNWFilterHashTableCreate(0); if (!missing_vars) { virReportOOMError(); @@ -668,8 +668,6 @@ virNWFilterInstantiate(virConnectPtr conn, err_exit: - virNWFilterUnlockFilterUpdates(); - for (j = 0; j < nEntries; j++) virNWFilterRuleInstFree(insts[j]); @@ -681,6 +679,9 @@ err_exit: } +/* + * Call this function while holding the NWFilter filter update lock + */ static int __virNWFilterInstantiateFilter(virConnectPtr conn, bool teardownOld, @@ -823,23 +824,30 @@ _virNWFilterInstantiateFilter(virConnectPtr conn, ? net->data.direct.linkdev : NULL; int ifindex; + int rc; if (ifaceGetIndex(true, net->ifname, &ifindex)) return 1; - return __virNWFilterInstantiateFilter(conn, - teardownOld, - net->ifname, - ifindex, - linkdev, - net->type, - net->mac, - net->filter, - net->filterparams, - useNewFilter, - conn->nwfilterPrivateData, - false, - foundNewFilter); + virNWFilterLockFilterUpdates(); + + rc = __virNWFilterInstantiateFilter(conn, + teardownOld, + net->ifname, + ifindex, + linkdev, + net->type, + net->mac, + net->filter, + net->filterparams, + useNewFilter, + conn->nwfilterPrivateData, + false, + foundNewFilter); + + virNWFilterUnlockFilterUpdates(); + + return rc; } @@ -857,6 +865,8 @@ virNWFilterInstantiateFilterLate(virConnectPtr conn, int rc; bool foundNewFilter = false; + virNWFilterLockFilterUpdates(); + rc = __virNWFilterInstantiateFilter(conn, 1, ifname, @@ -878,6 +888,9 @@ virNWFilterInstantiateFilterLate(virConnectPtr conn, _virNWFilterTeardownFilter(ifname); } } + + virNWFilterUnlockFilterUpdates(); + return rc; } |