--- freeradius-server-2.0.4/src/modules/rlm_ippool/rlm_ippool.c 2008-01-06 18:27:41.000000000 +0100 +++ freeradius-server-2.0.4/src/modules/rlm_ippool/rlm_ippool.c 2008-11-18 11:32:08.000000000 +0100 @@ -53,6 +53,10 @@ * - If Pool-Name is set to DEFAULT then always run. * Mar 2005, Kostas Kalevras * - Make the key an MD5 of a configurable xlated string. This closes Bug #42 + * Jul 2006, Sebastien Cantos + * - Add a retention parameter that allows to make sure an IP is kept used in the pool for a certain + * amount of time before being avalaible in the pool. This solves a problem dealing with TCP + * TIME_WAIT state when an IP is assigned to a client just after being released. */ #include @@ -98,6 +102,7 @@ uint32_t range_stop; uint32_t netmask; time_t max_timeout; + time_t ret_time; int cache_size; int override; GDBM_FILE gdbm; @@ -149,6 +154,7 @@ { "cache-size", PW_TYPE_INTEGER, offsetof(rlm_ippool_t,cache_size), NULL, "1000" }, { "override", PW_TYPE_BOOLEAN, offsetof(rlm_ippool_t,override), NULL, "no" }, { "maximum-timeout", PW_TYPE_INTEGER, offsetof(rlm_ippool_t,max_timeout), NULL, "0" }, + { "retention-time", PW_TYPE_INTEGER, offsetof(rlm_ippool_t,ret_time), NULL, "0" }, { NULL, -1, 0, NULL, NULL } }; @@ -363,13 +369,20 @@ /* * If the entry was found set active to zero + * or keep it active during retention time */ memcpy(&entry, data_datum.dptr, sizeof(ippool_info)); free(data_datum.dptr); DEBUG("rlm_ippool: Deallocated entry for ip: %s",ip_ntoa(str,entry.ipaddr)); - entry.active = 0; - entry.timestamp = 0; - entry.timeout = 0; + if (data->ret_time > 0) { + DEBUG("rlm_ippool: Entry will be kept active during retention time: %d seconds",data->ret_time); + entry.timestamp = request->timestamp; + entry.timeout = data->ret_time; + } else { + entry.active = 0; + entry.timestamp = 0; + entry.timeout = 0; + } /* * Save the reference to the entry