Changeset 36089 in vbox
- Timestamp:
- Feb 25, 2011 3:32:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r36087 r36089 72 72 /** The MAC address of this entry. */ 73 73 RTMAC MacAddr; 74 /** Is it promiscuous. 75 * Shadows INTNETIF::fPromiscuousEff. */ 74 /** Is it is effectively promiscuous mode. */ 76 75 bool fPromiscuousEff; 77 76 /** Is it promiscuous and should it see unrelated trunk traffic. */ … … 102 101 /** Table entries. */ 103 102 PINTNETMACTABENTRY paEntries; 103 104 /** The number of interface entries currently in promicuous mode. */ 105 uint32_t cPromiscuousEntries; 106 /** The number of interface entries currently in promicuous mode that 107 * shall not see unrelated trunk traffic. */ 108 uint32_t cPromiscuousNoTrunkEntries; 104 109 105 110 /** The host MAC address (reported). */ … … 224 229 /** Set if the INTNET::MacAddr member has been explicitly set. */ 225 230 bool fMacSet; 226 /** Set if the interface is in promiscuous mode.227 * This is shadowed by INTNETMACTABENTRY::fPromiscuous. */228 bool fPromiscuousEff;229 231 /** Tracks the desired promiscuous setting of the interface. */ 230 232 bool fPromiscuousReal; … … 1475 1477 } 1476 1478 1479 /* Network only promicuous mode ifs should see related trunk traffic. */ 1480 if ( cExactHits 1481 && fSrc 1482 && pNetwork->MacTab.cPromiscuousNoTrunkEntries) 1483 { 1484 iIfMac = pTab->cEntries; 1485 while (iIfMac-- > 0) 1486 { 1487 if ( pTab->paEntries[iIfMac].fActive 1488 && pTab->paEntries[iIfMac].fPromiscuousEff 1489 && !pTab->paEntries[iIfMac].fPromiscuousSeeTrunk) 1490 { 1491 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork); 1492 if (intnetR0IfAddrCacheLookup(&pIf->aAddrCache[enmL3AddrType], pL3Addr, cbL3Addr) < 0) 1493 { 1494 uint32_t iIfDst = pDstTab->cIfs++; 1495 pDstTab->aIfs[iIfDst].pIf = pIf; 1496 pDstTab->aIfs[iIfDst].fReplaceDstMac = false; 1497 intnetR0BusyIncIf(pIf); 1498 } 1499 } 1500 } 1501 } 1502 1477 1503 /* Does it match the host, or is the host promiscuous? */ 1478 1504 if (pTab->fHostActive) … … 1623 1649 } 1624 1650 } 1625 /** @todo Interfaces with fPromiscuousEff && !fPromiscuousSeeTrunk needs to 1626 * be added if there are exact matches and fSrc != 0. This means 1627 * we need to count interfaces in this state to avoid traversing 1628 * the table a second time for no good reason. */ 1651 1652 /* Network only promicuous mode ifs should see related trunk traffic. */ 1653 if ( cExactHits 1654 && fSrc 1655 && pNetwork->MacTab.cPromiscuousNoTrunkEntries) 1656 { 1657 iIfMac = pTab->cEntries; 1658 while (iIfMac-- > 0) 1659 { 1660 if ( pTab->paEntries[iIfMac].fPromiscuousEff 1661 && !pTab->paEntries[iIfMac].fPromiscuousSeeTrunk 1662 && pTab->paEntries[iIfMac].fActive 1663 && !intnetR0AreMacAddrsEqual(&pTab->paEntries[iIfMac].MacAddr, pDstAddr) 1664 && !intnetR0IsMacAddrDummy(&pTab->paEntries[iIfMac].MacAddr) ) 1665 { 1666 PINTNETIF pIf = pTab->paEntries[iIfMac].pIf; AssertPtr(pIf); Assert(pIf->pNetwork == pNetwork); 1667 uint32_t iIfDst = pDstTab->cIfs++; 1668 pDstTab->aIfs[iIfDst].pIf = pIf; 1669 pDstTab->aIfs[iIfDst].fReplaceDstMac = false; 1670 intnetR0BusyIncIf(pIf); 1671 } 1672 } 1673 } 1629 1674 1630 1675 /* Does it match the host, or is the host promiscuous? */ … … 3664 3709 && (pIf->fOpenFlags & INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW) 3665 3710 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS); 3666 Log(("IntNetR0IfSetPromiscuousMode: hIf=%RX32: Changed from %d (%d)-> %d (%d)\n",3667 hIf, !fPromiscuous, pIf->fPromiscuousEff,!!fPromiscuous, fPromiscuousEff));3711 Log(("IntNetR0IfSetPromiscuousMode: hIf=%RX32: Changed from %d -> %d (%d)\n", 3712 hIf, !fPromiscuous, !!fPromiscuous, fPromiscuousEff)); 3668 3713 3669 3714 pIf->fPromiscuousReal = fPromiscuous; 3670 pIf->fPromiscuousEff = fPromiscuousEff;3671 3715 3672 3716 PINTNETMACTABENTRY pEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIf); Assert(pEntry); 3673 3717 if (RT_LIKELY(pEntry)) 3674 3718 { 3719 if (pEntry->fPromiscuousEff) 3720 { 3721 pNetwork->MacTab.cPromiscuousEntries--; 3722 if (!pEntry->fPromiscuousSeeTrunk) 3723 pNetwork->MacTab.cPromiscuousNoTrunkEntries--; 3724 Assert(pNetwork->MacTab.cPromiscuousEntries < pNetwork->MacTab.cEntries); 3725 Assert(pNetwork->MacTab.cPromiscuousNoTrunkEntries < pNetwork->MacTab.cEntries); 3726 } 3727 3675 3728 pEntry->fPromiscuousEff = fPromiscuousEff; 3676 3729 pEntry->fPromiscuousSeeTrunk = fPromiscuousEff 3677 3730 && (pIf->fOpenFlags & INTNET_OPEN_FLAGS_IF_PROMISC_SEE_TRUNK); 3731 3732 if (pEntry->fPromiscuousEff) 3733 { 3734 pNetwork->MacTab.cPromiscuousEntries++; 3735 if (!pEntry->fPromiscuousSeeTrunk) 3736 pNetwork->MacTab.cPromiscuousNoTrunkEntries++; 3737 } 3738 Assert(pNetwork->MacTab.cPromiscuousEntries <= pNetwork->MacTab.cEntries); 3739 Assert(pNetwork->MacTab.cPromiscuousNoTrunkEntries <= pNetwork->MacTab.cEntries); 3678 3740 } 3679 3741 } … … 4236 4298 if (pNetwork->MacTab.paEntries[iIf].pIf == pIf) 4237 4299 { 4300 if (pNetwork->MacTab.paEntries[iIf].fPromiscuousEff) 4301 { 4302 pNetwork->MacTab.cPromiscuousEntries--; 4303 if (!pNetwork->MacTab.paEntries[iIf].fPromiscuousSeeTrunk) 4304 pNetwork->MacTab.cPromiscuousNoTrunkEntries--; 4305 } 4306 Assert(pNetwork->MacTab.cPromiscuousEntries < pNetwork->MacTab.cEntries); 4307 Assert(pNetwork->MacTab.cPromiscuousNoTrunkEntries < pNetwork->MacTab.cEntries); 4308 4238 4309 if (iIf + 1 < pNetwork->MacTab.cEntries) 4239 4310 memmove(&pNetwork->MacTab.paEntries[iIf], … … 4258 4329 pNetwork->fMinFlags = fMinFlags; 4259 4330 } 4331 4260 4332 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk; 4261 4333 … … 4402 4474 memset(&pIf->MacAddr, 0xff, sizeof(pIf->MacAddr)); /* broadcast */ 4403 4475 //pIf->fMacSet = false; 4404 //pIf->fPromiscuousEff = false;4405 4476 //pIf->fPromiscuousReal = false; 4406 4477 //pIf->fActive = false; … … 5351 5422 if ((fOldNetFlags ^ fNetFlags) & INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS) 5352 5423 { 5424 pNetwork->MacTab.cPromiscuousEntries = 0; 5425 pNetwork->MacTab.cPromiscuousNoTrunkEntries = 0; 5426 5353 5427 uint32_t iIf = pNetwork->MacTab.cEntries; 5354 5428 while (iIf-- > 0) … … 5361 5435 bool fPromiscuousEff = (fNetFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS) 5362 5436 && (pIf2->fOpenFlags & INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW); 5363 pIf2->fPromiscuousEff = fPromiscuousEff;5364 5437 pEntry->fPromiscuousEff = fPromiscuousEff; 5365 5438 pEntry->fPromiscuousSeeTrunk = fPromiscuousEff 5366 5439 && (pIf2->fOpenFlags & INTNET_OPEN_FLAGS_IF_PROMISC_SEE_TRUNK); 5440 5441 if (pEntry->fPromiscuousEff) 5442 { 5443 pNetwork->MacTab.cPromiscuousEntries++; 5444 if (!pEntry->fPromiscuousSeeTrunk) 5445 pNetwork->MacTab.cPromiscuousNoTrunkEntries++; 5446 } 5367 5447 } 5368 5448 } … … 5541 5621 pNetwork->MacTab.cEntries = 0; 5542 5622 pNetwork->MacTab.cEntriesAllocated = INTNET_GROW_DSTTAB_SIZE; 5623 //pNetwork->MacTab.cPromiscuousEntries = 0; 5624 //pNetwork->MacTab.cPromiscuousNoTrunkEntries = 0; 5543 5625 pNetwork->MacTab.paEntries = NULL; 5544 5626 pNetwork->MacTab.fHostPromiscuousReal = false;
Note:
See TracChangeset
for help on using the changeset viewer.