VirtualBox

Changeset 38968 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Oct 10, 2011 2:27:41 AM (13 years ago)
Author:
vboxsync
Message:

NAT: replacement of in-place icmp depth calculation with reference counting.

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  
    9797    pData->icmp_socket.so_type = IPPROTO_ICMP;
    9898    pData->icmp_socket.so_state = SS_ISFCONNECTED;
     99    pData->iIcmpCacheLimit = 100;
    99100#ifndef RT_OS_WINDOWS
    100101# ifndef RT_OS_DARWIN
     
    298299         */
    299300        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);
    300304        LogFlowFunc(("LEAVE: icm:%p\n", icm));
    301305        return (icm);
     
    311315}
    312316
    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 }
    323317/**
    324318 * iEntries how many entries to leave, if iEntries < 0, clean all
     
    329323    struct icmp_msg *icm = NULL;
    330324    LogFlowFunc(("iEntries:%d\n", iEntries));
    331     if (iEntries > icmp_cache_count(pData))
     325    if (iEntries > pData->cIcmpCacheSize)
    332326    {
    333327        LogFlowFuncLeave();
     
    346340        LIST_REMOVE(icm, im_list);
    347341        if (icm->im_m)
     342        {
     343            pData->cIcmpCacheSize--;
    348344            m_freem(pData, icm->im_m);
     345        }
    349346        RTMemFree(icm);
    350347    }
     
    363360    icm->im_so = m->m_so;
    364361    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);
    367365    return 0;
    368366}
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r38111 r38968  
    198198#  define NSOCK_DEC_EX(ex) do {} while (0)
    199199# endif
     200    int cIcmpCacheSize;
     201    int iIcmpCacheLimit;
    200202# ifdef RT_OS_WINDOWS
    201203    void *pvIcmpBuffer;
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r38905 r38968  
    13161316    icmp_reflect(pData, m);
    13171317    LIST_REMOVE(icm, im_list);
     1318    pData->cIcmpCacheSize--;
    13181319    /* Don't call m_free here*/
    13191320
     
    14281429                    m_freem(pData, icm->im_m);
    14291430                    LIST_REMOVE(icm, im_list);
     1431                    pData->cIcmpCacheSize--;
    14301432                    RTMemFree(icm);
    14311433                }
     
    14771479                /* Here is different situation from Unix world, where we can receive icmp in response on TCP/UDP */
    14781480                LIST_REMOVE(icm, im_list);
     1481                pData->cIcmpCacheSize--;
    14791482                RTMemFree(icm);
    14801483                break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette