提交 ebacb31f 编写于 作者: S Stefan Berger

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.
上级 59fe163f
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册