On Thu, Apr 29, 2010 at 09:34:47PM -0400, Stefan Berger wrote: > Introduce a function to notify the IP address learning > thread to terminate and thus release the lock on the interface. > Notify the thread before grabbing the lock on the interface > and tearing down the rules. This prevents a 'virsh destroy' to > tear down the rules that the IP address learning thread has > applied. > > Signed-off-by; Stefan Berger <stefanb@xxxxxxxxxx> > > --- > src/nwfilter/nwfilter_gentech_driver.c | 8 ++++++++ > src/nwfilter/nwfilter_learnipaddr.c | 27 ++++++++++++++++++++++++++- > src/nwfilter/nwfilter_learnipaddr.h | 1 + > 3 files changed, 35 insertions(+), 1 deletion(-) > > Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c > =================================================================== > --- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c > +++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c > @@ -243,8 +243,33 @@ virNWFilterRegisterLearnReq(virNWFilterI > return res; > } > > + > #endif > > +int > +virNWFilterTerminateLearnReq(const char *ifname) { > + int rc = 1; > + int ifindex; > + virNWFilterIPAddrLearnReqPtr req; > + > + if (ifaceGetIndex(false, ifname, &ifindex) == 0) { > + > + IFINDEX2STR(ifindex_str, ifindex); > + > + virMutexLock(&pendingLearnReqLock); > + > + req = virHashLookup(pendingLearnReq, ifindex_str); > + if (req) { > + rc = 0; > + req->terminate = true; > + } > + > + virMutexUnlock(&pendingLearnReqLock); > + } > + > + return rc; > +} > + > > virNWFilterIPAddrLearnReqPtr > virNWFilterLookupLearnReq(int ifindex) { > @@ -472,7 +497,7 @@ learnIPAddressThread(void *arg) > > if (!packet) { > > - if (threadsTerminate) { > + if (threadsTerminate || req->terminate) { > req->status = ECANCELED; > showError = false; > break; > Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c > =================================================================== > --- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c > +++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c > @@ -937,10 +937,18 @@ _virNWFilterTeardownFilter(const char *i > drvname); > return 1; > } > + > + virNWFilterTerminateLearnReq(ifname); > + > + if (virNWFilterLockIface(ifname)) > + return 1; > + > techdriver->allTeardown(ifname); > > virNWFilterDelIpAddrForIfname(ifname); > > + virNWFilterUnlockIface(ifname); > + > return 0; > } > > Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h > =================================================================== > --- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.h > +++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h > @@ -46,6 +46,7 @@ struct _virNWFilterIPAddrLearnReq { > > int status; > pthread_t thread; > + volatile bool terminate; > }; > > int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, > ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@xxxxxxxxxxxx | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list