VirtualBox

Changeset 11436 in vbox for trunk


Ignore:
Timestamp:
Aug 14, 2008 6:26:29 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34788
Message:

PCNet: Added check of incoming frame size. Frames over 1514 bytes (1518 with vlan tag) are discarded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r11284 r11436  
    43864386    PCNetState *pThis = INETWORKPORT_2_DATA(pInterface);
    43874387    int         rc;
     4388    static bool firstBigFrameLoss = true;
    43884389
    43894390    STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
     
    43914392    AssertReleaseRC(rc);
    43924393
    4393     if (cb > 70) /* unqualified guess */
    4394         pThis->Led.Asserted.s.fReading = pThis->Led.Actual.s.fReading = 1;
    4395     pcnetReceiveNoSync(pThis, (const uint8_t *)pvBuf, cb);
    4396     pThis->Led.Actual.s.fReading = 0;
     4394    /*
     4395     * Determine max ethernet frame size with vlan tag (TPID == 0x8100) or without it
     4396     * (excluding CRC which is not transferred).
     4397     * It consists of 14-byte header [+ 4-byte vlan tag] + 1500-byte body.
     4398     */
     4399    register maxFrameSize = ((uint16_t*)pvBuf)[6] == 0x81 ? 1518 : 1514;
     4400    if (RT_UNLIKELY(cb > maxFrameSize))
     4401    {
     4402        if (RT_UNLIKELY(firstBigFrameLoss))
     4403        {
     4404            firstBigFrameLoss = false;
     4405            Log(("#%d Received frame exceeds max size (%u > %u). "
     4406                 "Further frame losses will be reported at level5\n",
     4407                 PCNET_INST_NR, (unsigned)cb, (unsigned)maxFrameSize));
     4408        }
     4409        else
     4410            Log5(("#%d Received frame exceeds max size (%u > %u)\n",
     4411                  PCNET_INST_NR, (unsigned)cb, (unsigned)maxFrameSize));
     4412    }
     4413    else
     4414    {
     4415        if (cb > 70) /* unqualified guess */
     4416            pThis->Led.Asserted.s.fReading = pThis->Led.Actual.s.fReading = 1;
     4417        pcnetReceiveNoSync(pThis, (const uint8_t *)pvBuf, cb);
     4418        pThis->Led.Actual.s.fReading = 0;
     4419    }
    43974420
    43984421    PDMCritSectLeave(&pThis->CritSect);
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