VirtualBox

Changeset 105023 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 25, 2024 7:13:12 PM (5 months ago)
Author:
vboxsync
Message:

Devices/Network: code cleanup. bugref:10268

Location:
trunk/src/VBox/Devices/Network
Files:
2 edited

Legend:

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

    r105014 r105023  
    4343/**
    4444 * @callback_method_impl{FNPDMTHREADDRV}
     45 *
     46 * Queues guest process received packet. Triggered by drvNATRecvWakeup.
    4547 */
    4648static DECLCALLBACK(int) drvNATRecv(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
    4749{
    48     LogFlow(("Recv... \n"));
    4950    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
    5051
     
    110111}
    111112
     113/**
     114 * @brief Processes incoming packet (to guest).
     115 *
     116 * @param   pThis   Pointer to DRVNAT state for current context.
     117 * @param   pBuf    Pointer to packet buffer.
     118 * @param   cb      Size of packet in buffer.
     119 *
     120 * @thread  NAT
     121 */
    112122static DECLCALLBACK(void) drvNATRecvWorker(PDRVNAT pThis, void *pBuf, int cb)
    113123{
     
    135145        rc = pThis->pIAboveNet->pfnReceive(pThis->pIAboveNet, pBuf, cb);
    136146        AssertRC(rc);
    137         // RTMemFree(pBuf);
    138         // pBuf = NULL;
     147        RTMemFree(pBuf);
     148        pBuf = NULL;
    139149    }
    140150    else if (   rc != VERR_TIMEOUT
     
    148158
    149159done_unlocked:
    150     // m_free(m);
    151160    ASMAtomicDecU32(&pThis->cPkts);
    152161
     
    164173 * @param   pThis               Pointer to the NAT instance.
    165174 * @param   pSgBuf              The S/G buffer to free.
     175 *
     176 * @thread  NAT
    166177 */
    167178static void drvNATFreeSgBuf(PDRVNAT pThis, PPDMSCATTERGATHER pSgBuf)
     
    175186
    176187        RTMemFree(pSgBuf->aSegs[0].pvSeg);
    177         // RTMemFree(pSgBuf->pvAllocator);
     188        RTMemFree(pSgBuf->pvAllocator);
    178189
    179190        pSgBuf->pvAllocator = NULL;
     
    548559    if (pThis->pNATState->nsock + 1 >= pThis->pNATState->uPollCap)
    549560    {
    550         // LogFlow(("OLD SIZE: %d\n", sizeof(pThis->pNATState->polls)));
    551561        int cbNew = pThis->pNATState->uPollCap * 2 * sizeof(struct pollfd);
    552         // LogFlow(("NEW SIZE: %d\n", cbNew));
    553562        struct pollfd *pvNew = (struct pollfd *)RTMemRealloc(pThis->pNATState->polls, cbNew);
    554563        if(pvNew)
     
    564573
    565574    int idx = pThis->pNATState->nsock;
    566     // LogFlow(("**** nsock = %d\n", pThis->pNATState->nsock));
    567575#ifdef RT_OS_WINDOWS
    568576    pThis->pNATState->polls[idx].fd = libslirp_wrap_RTHandleTableLookup(fd);
     
    573581    pThis->pNATState->polls[idx].revents = 0;
    574582    pThis->pNATState->nsock += 1;
    575     // LogFlow(("add_poll_cb: fd=%d, return=%d\n", fd, idx));
    576583    return idx;
    577584}
     
    579586static int get_revents_cb(int idx, void *opaque)
    580587{
    581 // #ifndef RT_OS_WINDOWS
    582588    PDRVNAT pThis = (PDRVNAT)opaque;
    583589    struct pollfd* polls = pThis->pNATState->polls;
    584590    return poll_to_slirp(polls[idx].revents);
    585 // #else
    586 //     return 0;
    587 // #endif
    588591}
    589592
     
    680683        pThis->pNATState->nsock = 0;
    681684        slirp_pollfds_fill(pThis->pNATState->pSlirp, &uTimeout, add_poll_cb /* SlirpAddPollCb */, pThis /* opaque */);
    682                 LogFlow(("******** nsock = %d\n", pThis->pNATState->nsock));
    683 
    684685        slirpUpdateTimeout(&uTimeout, pThis);
    685         // DWORD dwEvent = WSAWaitForMultipleEvents(VBOX_EVENT_COUNT, phEvents, FALSE,
    686         //                                          uTimeout, /* :fAlertable */ TRUE);
    687         // AssertCompile(WSA_WAIT_EVENT_0 == 0);
    688         // if (   (/*dwEvent < WSA_WAIT_EVENT_0 ||*/ dwEvent > WSA_WAIT_EVENT_0 + pThis->pNATState->nsock - 1)
    689         //     && dwEvent != WSA_WAIT_TIMEOUT && dwEvent != WSA_WAIT_IO_COMPLETION)
    690         // {
    691         //     int error = WSAGetLastError();
    692         //     LogFlow(("NAT: WSAWaitForMultipleEvents returned %d (error %d)\n", dwEvent, error));
    693         //     // RTAssertPanic();
    694         // }
    695 
    696         // LogFlow(("WSAWaitForMultipleEvents = %d\n", dwEvent));
    697 
    698         // if(pThis->pNATState->nsock <= 0)
    699         // {
    700         //     RTThreadSleep(100);
    701         //     continue;
    702         // }
    703686
    704687        int cChangedFDs = WSAPoll(pThis->pNATState->polls, pThis->pNATState->nsock, uTimeout /* timeout */);
    705             int error = WSAGetLastError();
    706 
    707         LogFlow(("changed fds: %d\n", cChangedFDs));
     688        int error = WSAGetLastError();
     689
    708690        if (cChangedFDs < 0)
    709691        {
     
    717699        if (cChangedFDs == 0)
    718700        {
    719             LogFlow(("WSA_WAIT_TIMEOUT\n"));
    720701            /* only check for slow/fast timers */
    721702            slirp_pollfds_poll(pThis->pNATState->pSlirp, false /*select error*/, get_revents_cb /* SlirpGetREventsCb */, pThis /* opaque */);
     
    13411322    vhost.S_un.S_addr = RT_BSWAP_U32(0x0a000202);
    13421323
    1343     // struct in6_addr vprefix_addr6 = { 0 };
    1344 
    13451324    struct in_addr vdhcp_start;
    13461325    vdhcp_start.S_un.S_addr = RT_BSWAP_U32(0x0a00020f);
     
    13491328    vnameserver.S_un.S_addr = RT_BSWAP_U32(0x0a000203);
    13501329#endif
    1351     // AssertRC(inet_pton(AF_INET6, "fec0::", &vprefix_addr6));
    13521330
    13531331    SlirpConfig *pSlirpCfg = new SlirpConfig { 0 };
     
    13591337    pSlirpCfg->vnetmask = vnetmask;
    13601338    pSlirpCfg->vhost = vhost;
    1361 // #ifndef RT_OS_WINDOWS
    13621339    pSlirpCfg->in6_enabled = true;
    1363 // #else
    1364 //     pSlirpCfg->in6_enabled = false;
    1365 // #endif
    1366 
    1367 #ifndef RT_OS_WINDOWS
     1340
    13681341    inet_pton(AF_INET6, "fd00::", &pSlirpCfg->vprefix_addr6);
    1369 #else
    1370     inet_pton(23, "fd00::", &pSlirpCfg->vprefix_addr6);
    1371 #endif
    1372 
    13731342    pSlirpCfg->vprefix_len = 64;
    1374 
    1375 #ifndef RT_OS_WINDOWS
    13761343    inet_pton(AF_INET6, "fd00::2", &pSlirpCfg->vhost6);
    1377 #else
    1378     inet_pton(23, "fd00::2", &pSlirpCfg->vhost6);
    1379 #endif
    1380 
    1381     pSlirpCfg->vhostname = "tmp-vbox-dev";
     1344
     1345    pSlirpCfg->vhostname = "vbox";
    13821346    pSlirpCfg->tftp_server_name = pThis->pszNextServer;
    13831347    pSlirpCfg->tftp_path = pThis->pszTFTPPrefix;
  • trunk/src/VBox/Devices/Network/DrvNATlibslirp.h

    r105013 r105023  
    6464# endif
    6565# define inet_aton(x, y) inet_pton(2, x, y)
     66# define AF_INET6 23
    6667#endif
    6768
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