VirtualBox

Ignore:
Timestamp:
Nov 12, 2014 3:47:13 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96888
Message:

NAT: don't create contiguous copy of all large ICMP datagrams, only do
one when necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/ip_icmp.c

    r53303 r53309  
    346346icmp_input(PNATState pData, struct mbuf *m, int hlen)
    347347{
    348     register struct icmp *icp;
    349     void *icp_buf = NULL;
    350348    register struct ip *ip = mtod(m, struct ip *);
    351349    int icmplen = ip->ip_len;
     350    uint8_t icmp_type;
     351    void *icp_buf = NULL;
    352352    int status;
    353353    uint32_t dst;
     
    382382    }
    383383
    384     if (m->m_next)
    385     {
    386         icp_buf = RTMemAlloc(icmplen);
    387         if (!icp_buf)
    388         {
    389             Log(("NAT: not enought memory to allocate the buffer\n"));
    390             goto end_error_free_m;
    391         }
    392         m_copydata(m, 0, icmplen, icp_buf);
    393         icp = (struct icmp *)icp_buf;
    394     }
    395     else
    396         icp = mtod(m, struct icmp *);
     384    /* are we guaranteed to have ICMP header in first mbuf? be safe. */
     385    m_copydata(m, 0, sizeof(icmp_type), (caddr_t)&icmp_type);
    397386
    398387    m->m_len += hlen;
     
    402391    /* code = icp->icmp_code; */
    403392
    404     LogFlow(("icmp_type = %d\n", icp->icmp_type));
    405     switch (icp->icmp_type)
     393    LogFlow(("icmp_type = %d\n", icmp_type));
     394    switch (icmp_type)
    406395    {
    407396        case ICMP_ECHO:
     
    422411            else
    423412            {
     413                struct icmp *icp;
    424414                struct sockaddr_in addr;
    425415#ifdef RT_OS_WINDOWS
     
    442432                else
    443433                    addr.sin_addr.s_addr = ip->ip_dst.s_addr;
     434
     435                if (m->m_next)
     436                {
     437                    icp_buf = RTMemAlloc(icmplen);
     438                    if (!icp_buf)
     439                    {
     440                        Log(("NAT: not enought memory to allocate the buffer\n"));
     441                        goto end_error_free_m;
     442                    }
     443                    m_copydata(m, hlen, icmplen, icp_buf);
     444                    icp = (struct icmp *)icp_buf;
     445                }
     446                else
     447                    icp = (struct icmp *)(mtod(m, char *) + hlen);
     448
    444449#ifndef RT_OS_WINDOWS
    445450                if (pData->icmp_socket.s != -1)
Note: See TracChangeset for help on using the changeset viewer.

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