Changeset 71945 in vbox for trunk/src/VBox
- Timestamp:
- Apr 20, 2018 2:10:36 PM (7 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r71829 r71945 680 680 $(if $(VBOX_WITH_DEBUG_NAT_SOCKETS),VBOX_WITH_DEBUG_NAT_SOCKETS,) \ 681 681 $(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,) \683 682 $(if $(VBOX_WITH_NAT_SEND2HOME),VBOX_WITH_NAT_SEND2HOME,) \ 684 683 $(if $(VBOX_WITH_HIDDEN_TCPTEMPLATE),VBOX_WITH_HIDDEN_TCPTEMPLATE,) \ -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r71940 r71945 686 686 #endif 687 687 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 692 689 /* 693 690 * See if we need a tcp_fasttimo … … 798 795 } 799 796 } 800 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE801 if (so->so_cloneOf)802 CONTINUE_NO_UNLOCK(udp);803 #endif804 797 805 798 /* … … 963 956 QSOCKET_FOREACH(so, so_next, tcp) 964 957 /* { */ 965 /* TCP socket can't be cloned */966 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE967 Assert((!so->so_cloneOf));968 #endif969 958 Assert(!so->fUnderPolling); 970 959 so->fUnderPolling = 1; … … 1235 1224 QSOCKET_FOREACH(so, so_next, udp) 1236 1225 /* { */ 1237 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE1238 if (so->so_cloneOf)1239 CONTINUE_NO_UNLOCK(udp);1240 #endif1241 1226 #if 0 1242 1227 so->fUnderPolling = 1; -
trunk/src/VBox/Devices/Network/slirp/socket.c
r69500 r71945 40 40 AssertCompileMembersSameSizeAndOffset(struct iovec, iov_base, WSABUF, buf); 41 41 AssertCompileMembersSameSizeAndOffset(struct iovec, iov_len, WSABUF, len); 42 #endif43 44 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE45 /**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 else69 {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_cloneOf90 && pSoClone->so_cloneOf == pcSo91 && pSoClone->so_lport == pcSo->so_lport92 && pSoClone->so_fport == pcSo->so_fport93 && pSoClone->so_laddr.s_addr == pcSo->so_laddr.s_addr94 && 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 }102 42 #endif 103 43 -
trunk/src/VBox/Devices/Network/slirp/socket.h
r69500 r71945 98 98 void *so_timeout_arg; 99 99 100 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE101 struct socket *so_cloneOf; /* pointer to master instance */102 int so_cCloneCounter; /* number of clones */103 #endif104 100 /** These flags (''fUnderPolling'' and ''fShouldBeRemoved'') introduced to 105 101 * to let polling routine gain control over freeing socket whatever level of … … 187 183 void sofwdrain (struct socket *); 188 184 189 /**190 * Creates copy of UDP socket with specified addr191 * fBindSocket - in case we want bind a real socket.192 * @return copy of the socket with f_addr equal to u32ForeignAddr193 */194 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE195 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 #endif198 199 185 static inline int soIgnorableErrorCode(int iErrorCode) 200 186 { -
trunk/src/VBox/Devices/Network/slirp/udp.c
r69500 r71945 468 468 { 469 469 struct sockaddr_in saddr, daddr; 470 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE 471 struct socket *pSocketClone = NULL; 472 #endif 470 473 471 Assert(so->so_type == IPPROTO_UDP); 474 472 LogFlowFunc(("ENTER: so = %R[natsock], m = %p, saddr = %RTnaipv4\n", so, m, addr->sin_addr.s_addr)); … … 509 507 else 510 508 saddr.sin_addr.s_addr = addr->sin_addr.s_addr; 511 /* we shouldn't override initial socket */512 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE513 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 #else520 509 so->so_faddr.s_addr = addr->sin_addr.s_addr; 521 #endif522 510 } 523 511 } … … 606 594 SOCKET_LOCK(so); 607 595 QSOCKET_UNLOCK(udb); 608 #ifdef VBOX_WITH_NAT_UDP_SOCKET_CLONE609 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 #endif618 596 closesocket(so->s); 619 597 sofree(pData, so);
Note:
See TracChangeset
for help on using the changeset viewer.