VirtualBox

Changeset 71945 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 20, 2018 2:10:36 PM (7 years ago)
Author:
vboxsync
Message:

NAT: unifdef -U VBOX_WITH_NAT_UDP_SOCKET_CLONE - g/c old experiment.

Location:
trunk/src/VBox/Devices
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Makefile.kmk

    r71829 r71945  
    680680       $(if $(VBOX_WITH_DEBUG_NAT_SOCKETS),VBOX_WITH_DEBUG_NAT_SOCKETS,)        \
    681681       $(if $(VBOX_WITH_DNSMAPPING_IN_HOSTRESOLVER),VBOX_WITH_DNSMAPPING_IN_HOSTRESOLVER,)      \
    682        $(if $(VBOX_WITH_NAT_UDP_SOCKET_CLONE),VBOX_WITH_NAT_UDP_SOCKET_CLONE,)  \
    683682       $(if $(VBOX_WITH_NAT_SEND2HOME),VBOX_WITH_NAT_SEND2HOME,)        \
    684683       $(if $(VBOX_WITH_HIDDEN_TCPTEMPLATE),VBOX_WITH_HIDDEN_TCPTEMPLATE,)      \
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r71940 r71945  
    686686#endif
    687687        STAM_COUNTER_INC(&pData->StatTCP);
    688 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    689         /* TCP socket can't be cloned */
    690         Assert((!so->so_cloneOf));
    691 #endif
     688
    692689        /*
    693690         * See if we need a tcp_fasttimo
     
    798795            }
    799796        }
    800 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    801         if (so->so_cloneOf)
    802                 CONTINUE_NO_UNLOCK(udp);
    803 #endif
    804797
    805798        /*
     
    963956    QSOCKET_FOREACH(so, so_next, tcp)
    964957    /* { */
    965         /* TCP socket can't be cloned */
    966 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    967         Assert((!so->so_cloneOf));
    968 #endif
    969958        Assert(!so->fUnderPolling);
    970959        so->fUnderPolling = 1;
     
    12351224     QSOCKET_FOREACH(so, so_next, udp)
    12361225     /* { */
    1237 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    1238         if (so->so_cloneOf)
    1239             CONTINUE_NO_UNLOCK(udp);
    1240 #endif
    12411226#if 0
    12421227        so->fUnderPolling = 1;
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r69500 r71945  
    4040AssertCompileMembersSameSizeAndOffset(struct iovec, iov_base, WSABUF, buf);
    4141AssertCompileMembersSameSizeAndOffset(struct iovec, iov_len,  WSABUF, len);
    42 #endif
    43 
    44 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    45 /**
    46  *
    47  */
    48 struct socket * soCloneUDPSocketWithForegnAddr(PNATState pData, bool fBindSocket, struct socket *pSo, uint32_t u32ForeignAddr)
    49 {
    50     struct socket *pNewSocket = NULL;
    51     LogFlowFunc(("Enter: fBindSocket:%RTbool, so:%R[natsock], u32ForeignAddr:%RTnaipv4\n", fBindSocket, pSo, u32ForeignAddr));
    52     pNewSocket = socreate();
    53     if (!pNewSocket)
    54     {
    55         LogFunc(("Can't create socket\n"));
    56         LogFlowFunc(("Leave: NULL\n"));
    57         return NULL;
    58     }
    59     if (fBindSocket)
    60     {
    61         if (udp_attach(pData, pNewSocket, 0) <= 0)
    62         {
    63             sofree(pData, pNewSocket);
    64             LogFunc(("Can't attach fresh created socket\n"));
    65             return NULL;
    66         }
    67     }
    68     else
    69     {
    70         pNewSocket->so_cloneOf = (struct socket *)pSo;
    71         pNewSocket->s = pSo->s;
    72         insque(pData, pNewSocket, &udb);
    73     }
    74     pNewSocket->so_laddr = pSo->so_laddr;
    75     pNewSocket->so_lport = pSo->so_lport;
    76     pNewSocket->so_faddr.s_addr = u32ForeignAddr;
    77     pNewSocket->so_fport = pSo->so_fport;
    78     pSo->so_cCloneCounter++;
    79     LogFlowFunc(("Leave: %R[natsock]\n", pNewSocket));
    80     return pNewSocket;
    81 }
    82 
    83 struct socket *soLookUpClonedUDPSocket(PNATState pData, const struct socket *pcSo, uint32_t u32ForeignAddress)
    84 {
    85     struct socket *pSoClone = NULL;
    86     LogFlowFunc(("Enter: pcSo:%R[natsock], u32ForeignAddress:%RTnaipv4\n", pcSo, u32ForeignAddress));
    87     for (pSoClone = udb.so_next; pSoClone != &udb; pSoClone = pSoClone->so_next)
    88     {
    89         if (   pSoClone->so_cloneOf
    90             && pSoClone->so_cloneOf == pcSo
    91             && pSoClone->so_lport == pcSo->so_lport
    92             && pSoClone->so_fport == pcSo->so_fport
    93             && pSoClone->so_laddr.s_addr == pcSo->so_laddr.s_addr
    94             && pSoClone->so_faddr.s_addr == u32ForeignAddress)
    95             goto done;
    96     }
    97     pSoClone = NULL;
    98 done:
    99     LogFlowFunc(("Leave: pSoClone: %R[natsock]\n", pSoClone));
    100     return pSoClone;
    101 }
    10242#endif
    10343
  • trunk/src/VBox/Devices/Network/slirp/socket.h

    r69500 r71945  
    9898    void *so_timeout_arg;
    9999
    100 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    101     struct socket *so_cloneOf; /* pointer to master instance */
    102     int so_cCloneCounter;      /* number of clones */
    103 #endif
    104100    /** These flags (''fUnderPolling'' and ''fShouldBeRemoved'') introduced to
    105101     *  to let polling routine gain control over freeing socket whatever level of
     
    187183void sofwdrain (struct socket *);
    188184
    189 /**
    190  * Creates copy of UDP socket with specified addr
    191  * fBindSocket - in case we want bind a real socket.
    192  * @return copy of the socket with f_addr equal to u32ForeignAddr
    193  */
    194 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    195 struct socket * soCloneUDPSocketWithForegnAddr(PNATState pData, bool fBindSocket, struct socket *pSo, uint32_t u32ForeignAddr);
    196 struct socket *soLookUpClonedUDPSocket(PNATState pData, const struct socket *pcSo, uint32_t u32ForeignAddress);
    197 #endif
    198 
    199185static inline int soIgnorableErrorCode(int iErrorCode)
    200186{
  • trunk/src/VBox/Devices/Network/slirp/udp.c

    r69500 r71945  
    468468{
    469469    struct sockaddr_in saddr, daddr;
    470 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    471     struct socket *pSocketClone = NULL;
    472 #endif
     470
    473471    Assert(so->so_type == IPPROTO_UDP);
    474472    LogFlowFunc(("ENTER: so = %R[natsock], m = %p, saddr = %RTnaipv4\n", so, m, addr->sin_addr.s_addr));
     
    509507            else
    510508                saddr.sin_addr.s_addr = addr->sin_addr.s_addr;
    511             /* we shouldn't override initial socket */
    512 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    513             if (so->so_cCloneCounter)
    514                 pSocketClone = soLookUpClonedUDPSocket(pData, so, addr->sin_addr.s_addr);
    515             if (!pSocketClone)
    516                 pSocketClone = soCloneUDPSocketWithForegnAddr(pData, false, so, addr->sin_addr.s_addr);
    517             Assert((pSocketClone));
    518             so = pSocketClone;
    519 #else
    520509            so->so_faddr.s_addr = addr->sin_addr.s_addr;
    521 #endif
    522510        }
    523511    }
     
    606594        SOCKET_LOCK(so);
    607595        QSOCKET_UNLOCK(udb);
    608 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE
    609         if (so->so_cloneOf)
    610             so->so_cloneOf->so_cCloneCounter--;
    611         else if (so->so_cCloneCounter > 0)
    612         {
    613             /* we can't close socket yet */
    614             SOCKET_UNLOCK(so);
    615             return;
    616         }
    617 #endif
    618596        closesocket(so->s);
    619597        sofree(pData, so);
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