VirtualBox

Ignore:
Timestamp:
Jul 31, 2013 5:36:16 PM (11 years ago)
Author:
vboxsync
Message:

Devices/Network: Temporarily disconnect network devices after the host resumed for NAT and bridged networks to let the guest pick up changed networks

File:
1 edited

Legend:

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

    r46904 r47499  
    10351035    LogFlow(("drvR3IntNetPowerResume\n"));
    10361036    PDRVINTNET pThis = PDMINS_2_DATA(pDrvIns, PDRVINTNET);
     1037    VMRESUMEREASON enmReason = PDMDrvHlpVMGetResumeReason(pDrvIns);
     1038
    10371039    if (!pThis->fActivateEarlyDeactivateLate)
    10381040    {
     
    10421044        drvR3IntNetSetActive(pThis, true /* fActive */);
    10431045    }
    1044     if (   PDMDrvHlpVMTeleportedAndNotFullyResumedYet(pDrvIns)
    1045         && pThis->pIAboveConfigR3)
    1046     {
    1047         /*
    1048          * We've just been teleported and need to drop a hint to the switch
    1049          * since we're likely to have changed to a different port.  We just
    1050          * push out some ethernet frame that doesn't mean anything to anyone.
    1051          * For this purpose ethertype 0x801e was chosen since it was registered
    1052          * to Sun (dunno what it is/was used for though).
    1053          */
    1054         union
     1046
     1047    switch (enmReason)
     1048    {
     1049        case VMRESUMEREASON_HOST_RESUME:
    10551050        {
    1056             RTNETETHERHDR   Hdr;
    1057             uint8_t         ab[128];
    1058         } Frame;
    1059         RT_ZERO(Frame);
    1060         Frame.Hdr.DstMac.au16[0] = 0xffff;
    1061         Frame.Hdr.DstMac.au16[1] = 0xffff;
    1062         Frame.Hdr.DstMac.au16[2] = 0xffff;
    1063         Frame.Hdr.EtherType      = RT_H2BE_U16_C(0x801e);
    1064         int rc = pThis->pIAboveConfigR3->pfnGetMac(pThis->pIAboveConfigR3, &Frame.Hdr.SrcMac);
    1065         if (RT_SUCCESS(rc))
    1066             rc = drvR3IntNetResumeSend(pThis, &Frame, sizeof(Frame));
    1067         if (RT_FAILURE(rc))
    1068             LogRel(("IntNet#%u: Sending dummy frame failed: %Rrc\n", pDrvIns->iInstance, rc));
    1069     }
     1051            uint32_t u32TrunkType;
     1052            int rc = CFGMR3QueryU32(pDrvIns->pCfg, "TrunkType", &u32TrunkType);
     1053            AssertRC(rc);
     1054
     1055            /*
     1056             * Only do the disconnect for bridged networking. Host-only and
     1057             * internal networks are not affected by a host resume.
     1058             */
     1059            if (   RT_SUCCESS(rc)
     1060                && u32TrunkType == kIntNetTrunkType_NetFlt)
     1061            {
     1062                rc = pThis->pIAboveConfigR3->pfnSetLinkState(pThis->pIAboveConfigR3,
     1063                                                             PDMNETWORKLINKSTATE_DOWN_RESUME);
     1064                AssertRC(rc);
     1065            }
     1066            break;
     1067        }
     1068        case VMRESUMEREASON_TELEPORTED:
     1069        case VMRESUMEREASON_TELEPORT_FAILED:
     1070        {
     1071            if (   PDMDrvHlpVMTeleportedAndNotFullyResumedYet(pDrvIns)
     1072                   && pThis->pIAboveConfigR3)
     1073            {
     1074                /*
     1075                 * We've just been teleported and need to drop a hint to the switch
     1076                 * since we're likely to have changed to a different port.  We just
     1077                 * push out some ethernet frame that doesn't mean anything to anyone.
     1078                 * For this purpose ethertype 0x801e was chosen since it was registered
     1079                 * to Sun (dunno what it is/was used for though).
     1080                 */
     1081                union
     1082                {
     1083                    RTNETETHERHDR   Hdr;
     1084                    uint8_t         ab[128];
     1085                } Frame;
     1086                RT_ZERO(Frame);
     1087                Frame.Hdr.DstMac.au16[0] = 0xffff;
     1088                Frame.Hdr.DstMac.au16[1] = 0xffff;
     1089                Frame.Hdr.DstMac.au16[2] = 0xffff;
     1090                Frame.Hdr.EtherType      = RT_H2BE_U16_C(0x801e);
     1091                int rc = pThis->pIAboveConfigR3->pfnGetMac(pThis->pIAboveConfigR3,
     1092                                                           &Frame.Hdr.SrcMac);
     1093                if (RT_SUCCESS(rc))
     1094                    rc = drvR3IntNetResumeSend(pThis, &Frame, sizeof(Frame));
     1095                if (RT_FAILURE(rc))
     1096                    LogRel(("IntNet#%u: Sending dummy frame failed: %Rrc\n",
     1097                            pDrvIns->iInstance, rc));
     1098            }
     1099            break;
     1100        }
     1101        default: /* ignore every other resume reason else */
     1102            break;
     1103    } /* end of switch(enmReason) */
    10701104}
    10711105
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