Changeset 38968 in vbox
- Timestamp:
- Oct 10, 2011 2:27:41 AM (13 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r38927 r38968 97 97 pData->icmp_socket.so_type = IPPROTO_ICMP; 98 98 pData->icmp_socket.so_state = SS_ISFCONNECTED; 99 pData->iIcmpCacheLimit = 100; 99 100 #ifndef RT_OS_WINDOWS 100 101 # ifndef RT_OS_DARWIN … … 298 299 */ 299 300 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list); 301 pData->cIcmpCacheSize++; 302 if (pData->cIcmpCacheSize > pData->iIcmpCacheLimit) 303 icmp_cache_clean(pData, pData->iIcmpCacheLimit/2); 300 304 LogFlowFunc(("LEAVE: icm:%p\n", icm)); 301 305 return (icm); … … 311 315 } 312 316 313 static int icmp_cache_count(PNATState pData)314 {315 int iIcmpCount = 0;316 struct icmp_msg *icm = NULL;317 LogFlowFuncEnter();318 LIST_FOREACH(icm, &pData->icmp_msg_head, im_list)319 iIcmpCount++;320 LogFlowFunc(("LEAVE: %d\n", iIcmpCount));321 return iIcmpCount;322 }323 317 /** 324 318 * iEntries how many entries to leave, if iEntries < 0, clean all … … 329 323 struct icmp_msg *icm = NULL; 330 324 LogFlowFunc(("iEntries:%d\n", iEntries)); 331 if (iEntries > icmp_cache_count(pData))325 if (iEntries > pData->cIcmpCacheSize) 332 326 { 333 327 LogFlowFuncLeave(); … … 346 340 LIST_REMOVE(icm, im_list); 347 341 if (icm->im_m) 342 { 343 pData->cIcmpCacheSize--; 348 344 m_freem(pData, icm->im_m); 345 } 349 346 RTMemFree(icm); 350 347 } … … 363 360 icm->im_so = m->m_so; 364 361 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list); 365 if (icmp_cache_count(pData) > 100) 366 icmp_cache_clean(pData, 50); 362 pData->cIcmpCacheSize++; 363 if (pData->cIcmpCacheSize > pData->iIcmpCacheLimit) 364 icmp_cache_clean(pData, pData->iIcmpCacheLimit/2); 367 365 return 0; 368 366 } -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r38111 r38968 198 198 # define NSOCK_DEC_EX(ex) do {} while (0) 199 199 # endif 200 int cIcmpCacheSize; 201 int iIcmpCacheLimit; 200 202 # ifdef RT_OS_WINDOWS 201 203 void *pvIcmpBuffer; -
trunk/src/VBox/Devices/Network/slirp/socket.c
r38905 r38968 1316 1316 icmp_reflect(pData, m); 1317 1317 LIST_REMOVE(icm, im_list); 1318 pData->cIcmpCacheSize--; 1318 1319 /* Don't call m_free here*/ 1319 1320 … … 1428 1429 m_freem(pData, icm->im_m); 1429 1430 LIST_REMOVE(icm, im_list); 1431 pData->cIcmpCacheSize--; 1430 1432 RTMemFree(icm); 1431 1433 } … … 1477 1479 /* Here is different situation from Unix world, where we can receive icmp in response on TCP/UDP */ 1478 1480 LIST_REMOVE(icm, im_list); 1481 pData->cIcmpCacheSize--; 1479 1482 RTMemFree(icm); 1480 1483 break;
Note:
See TracChangeset
for help on using the changeset viewer.