Changeset 38927 in vbox
- Timestamp:
- Oct 1, 2011 3:28:49 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r37936 r38927 89 89 }; 90 90 91 static int icmp_cache_count(PNATState pData); 92 static void icmp_cache_clean(PNATState pData, int iEntries); 93 91 94 int 92 95 icmp_init(PNATState pData) … … 308 311 } 309 312 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 /** 324 * iEntries how many entries to leave, if iEntries < 0, clean all 325 */ 326 static void icmp_cache_clean(PNATState pData, int iEntries) 327 { 328 int iIcmpCount = 0; 329 struct icmp_msg *icm = NULL; 330 LogFlowFunc(("iEntries:%d\n", iEntries)); 331 if (iEntries > icmp_cache_count(pData)) 332 { 333 LogFlowFuncLeave(); 334 return; 335 } 336 while(!LIST_EMPTY(&pData->icmp_msg_head)) 337 { 338 icm = LIST_FIRST(&pData->icmp_msg_head); 339 if ( iEntries > 0 340 && iIcmpCount < iEntries) 341 { 342 iIcmpCount++; 343 continue; 344 } 345 346 LIST_REMOVE(icm, im_list); 347 if (icm->im_m) 348 m_freem(pData, icm->im_m); 349 RTMemFree(icm); 350 } 351 LogFlowFuncLeave(); 352 } 353 310 354 static int 311 355 icmp_attach(PNATState pData, struct mbuf *m) … … 319 363 icm->im_so = m->m_so; 320 364 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list); 365 if (icmp_cache_count(pData) > 100) 366 icmp_cache_clean(pData, 50); 321 367 return 0; 322 368 }
Note:
See TracChangeset
for help on using the changeset viewer.