Changeset 46922 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
- Timestamp:
- Jul 3, 2013 9:59:12 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r46904 r46922 565 565 DECLINLINE(uint32_t) vboxNetFltLinuxFrameSize(PINTNETSG pSG) 566 566 { 567 RTNETETHERHDR EthHdr; 568 uint16_t u16Type = 0; 569 uint32_t cbVlanTag = 0; 570 if (pSG->aSegs[0].cb >= sizeof(EthHdr)) 567 uint16_t u16Type = 0; 568 uint32_t cbVlanTag = 0; 569 if (pSG->aSegs[0].cb >= sizeof(RTNETETHERHDR)) 571 570 u16Type = RT_BE2H_U16(((PCRTNETETHERHDR)pSG->aSegs[0].pv)->EtherType); 572 else if (pSG->cbTotal >= sizeof(EthHdr)) 573 { 574 uint32_t i, uOffset = RT_OFFSETOF(RTNETETHERHDR, EtherType); 571 else if (pSG->cbTotal >= sizeof(RTNETETHERHDR)) 572 { 573 uint32_t off = RT_OFFSETOF(RTNETETHERHDR, EtherType); 574 uint32_t i; 575 575 for (i = 0; i < pSG->cSegsUsed; ++i) 576 576 { 577 if ( uOffset >pSG->aSegs[i].cb)577 if (off <= pSG->aSegs[i].cb) 578 578 { 579 uOffset -= pSG->aSegs[i].cb; 580 continue; 579 if (off + sizeof(uint16_t) <= pSG->aSegs[i].cb) 580 u16Type = RT_BE2H_U16(*(uint16_t *)((uintptr_t)pSG->aSegs[i].pv + off)); 581 else if (i + 1 < pSG->cSegsUsed) 582 u16Type = RT_BE2H_U16( ((uint16_t)( ((uint8_t *)pSG->aSegs[i].pv)[off] ) << 8) 583 + *(uint8_t *)pSG->aSegs[i + 1].pv); /* ASSUMES no empty segments! */ 584 /* else: frame is too short. */ 585 break; 581 586 } 582 if (uOffset + sizeof(uint16_t) > pSG->aSegs[i].cb) 583 { 584 if (i + 1 < pSG->cSegsUsed) 585 u16Type = RT_BE2H_U16( ((uint16_t)( ((uint8_t*)pSG->aSegs[i].pv)[uOffset] ) << 8) 586 + *(uint8_t*)pSG->aSegs[i + 1].pv); 587 } 588 else 589 u16Type = RT_BE2H_U16(*(uint16_t*)((uint8_t*)pSG->aSegs[i].pv + uOffset)); 587 off -= pSG->aSegs[i].cb; 590 588 } 591 589 } … … 619 617 if (fDstWire && (vboxNetFltLinuxFrameSize(pSG) > ASMAtomicReadU32(&pThis->u.s.cbMtu) + 14)) 620 618 { 621 static bool fOnce = true;622 if ( fOnce)623 { 624 fOnce = false;619 static bool s_fOnce = true; 620 if (s_fOnce) 621 { 622 s_fOnce = false; 625 623 printk("VBoxNetFlt: Dropped over-sized packet (%d bytes) coming from internal network.\n", vboxNetFltLinuxFrameSize(pSG)); 626 624 }
Note:
See TracChangeset
for help on using the changeset viewer.