mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 20:32:22 +00:00
Syncronize the teardown of rules with the thread
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.
This commit is contained in:
parent
59fe163f2f
commit
ebacb31fb5
@ -937,10 +937,18 @@ _virNWFilterTeardownFilter(const char *ifname)
|
||||
drvname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
virNWFilterTerminateLearnReq(ifname);
|
||||
|
||||
if (virNWFilterLockIface(ifname))
|
||||
return 1;
|
||||
|
||||
techdriver->allTeardown(ifname);
|
||||
|
||||
virNWFilterDelIpAddrForIfname(ifname);
|
||||
|
||||
virNWFilterUnlockIface(ifname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -243,8 +243,33 @@ virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReqPtr req) {
|
||||
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;
|
||||
|
@ -46,6 +46,7 @@ struct _virNWFilterIPAddrLearnReq {
|
||||
|
||||
int status;
|
||||
pthread_t thread;
|
||||
volatile bool terminate;
|
||||
};
|
||||
|
||||
int virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user