OCT 1. 更新并发请求预分配IP地址时,不同MAC分配同一个IP地址问题
This commit is contained in:
parent
7e0f1aa8ef
commit
664ba3505f
|
@ -15,6 +15,8 @@
|
|||
//static PMAC_FILTER g_blackListTbl = NULL;
|
||||
//static PPRE_ALLOC_IP g_pPreAllocIp = NULL;
|
||||
|
||||
static uv_mutex_t g_uvLock;
|
||||
|
||||
U32 lease_is_pre_assign(PDHCP_REQ pReq) {
|
||||
char macStr[20] = {0};
|
||||
U32 ipAddr;
|
||||
|
@ -84,7 +86,6 @@ int pre_alloc_dhcp_res(PDHCP_REQ pReq, PDHCP_USER pUser, U32 *pOutIp, PPOOL_CTX
|
|||
|
||||
LL_FOREACH_SAFE(pUser->pUserPool, pPool, pTemp) {
|
||||
U32 addr;
|
||||
|
||||
// 查看是否预分配过该设备
|
||||
if ((addr = lease_is_pre_assign(pReq)) != 0) {
|
||||
*pOutIp = addr;
|
||||
|
@ -92,6 +93,7 @@ int pre_alloc_dhcp_res(PDHCP_REQ pReq, PDHCP_USER pUser, U32 *pOutIp, PPOOL_CTX
|
|||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&g_uvLock);
|
||||
addr = pPool->minAddr;
|
||||
do {
|
||||
PLOCK_IP pLock;
|
||||
|
@ -103,12 +105,13 @@ int pre_alloc_dhcp_res(PDHCP_REQ pReq, PDHCP_USER pUser, U32 *pOutIp, PPOOL_CTX
|
|||
*pOutIp = addr;
|
||||
*pOutPool = pPool;
|
||||
db_add_pre_assign(pReq, addr, pPool);
|
||||
uv_mutex_unlock(&g_uvLock);
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
addr++;
|
||||
} while (addr <= pPool->maxAddr);
|
||||
uv_mutex_unlock(&g_uvLock);
|
||||
}
|
||||
|
||||
// 清理所有超时的预分配IP
|
||||
|
@ -121,6 +124,8 @@ int pre_alloc_dhcp_res(PDHCP_REQ pReq, PDHCP_USER pUser, U32 *pOutIp, PPOOL_CTX
|
|||
int dhcp_lease_init() {
|
||||
int rc;
|
||||
|
||||
uv_mutex_init(&g_uvLock);
|
||||
|
||||
rc = db_init_lease_database();
|
||||
|
||||
if (rc != ERR_SUCCESS) {
|
||||
|
|
Loading…
Reference in New Issue