Changeset 39468 in vbox for trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp
- Timestamp:
- Nov 30, 2011 4:05:54 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp
r39410 r39468 195 195 AssertReleaseRC(rc); 196 196 197 g_pNAT->fIsRunning = true; 197 198 rc = RTThreadCreate(&m_ThrNAT, AsyncIoThread, this, 128 * _1K, RTTHREADTYPE_DEFAULT, 0, "NAT"); 198 199 rc = RTThreadCreate(&m_ThrSndNAT, natSndThread, this, 128 * _1K, RTTHREADTYPE_DEFAULT, 0, "SndNAT"); … … 212 213 fIsRunning = true; 213 214 PINTNETRINGBUF pRingBuf = &m_pIfBuf->Recv; 214 //RTThreadSetType(RTThreadSelf(), RTTHREADTYPE_IO);215 RTThreadSetType(RTThreadSelf(), RTTHREADTYPE_IO); 215 216 for (;;) 216 217 { … … 224 225 WaitReq.hIf = m_hIf; 225 226 WaitReq.cMillies = 2000; /* 2 secs - the sleep is for some reason uninterruptible... */ /** @todo fix interruptability in SrvIntNet! */ 226 #if 1227 #if 0 227 228 RTReqProcess(m_pSendQueue, 0); 228 229 RTReqProcess(m_pUrgSendQueue, 0); … … 232 233 { 233 234 if (rc == VERR_TIMEOUT || rc == VERR_INTERRUPTED) 235 { 236 natNotifyNATThread(); 234 237 continue; 238 } 235 239 LogRel(("VBoxNetNAT: VMMR0_DO_INTNET_IF_WAIT returned %Rrc\n", rc)); 236 240 return; … … 258 262 } 259 263 memcpy(pvSlirpFrame, IntNetHdrGetFramePtr(pHdr, m_pIfBuf), cbFrame); 264 #if 0 260 265 IntNetRingSkipFrame(&m_pIfBuf->Recv); 266 #endif 261 267 262 268 /* don't wait, we may have to wakeup the NAT thread first */ 263 269 rc = RTReqCallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 264 270 (PFNRT)SendWorker, 2, m, cbFrame); 271 natNotifyNATThread(); 265 272 AssertReleaseRC(rc); 266 273 break; 267 274 case INTNETHDR_TYPE_GSO: 275 #if 1 268 276 { 269 277 /** @todo pass these unmodified. */ … … 277 285 278 286 uint8_t abHdrScratch[256]; 279 uint32_t const cSegs = PDMNetGsoCalcSegmentCount(pGso, cbFrame - sizeof(*pGso)); 287 cbFrame -= sizeof(PDMNETWORKGSO); 288 uint32_t const cSegs = PDMNetGsoCalcSegmentCount(pGso, cbFrame); 280 289 for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++) 281 290 { … … 283 292 void *pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)(pGso + 1), cbFrame, abHdrScratch, 284 293 iSeg, cSegs, &cbSegFrame); 285 m = slirp_ext_m_get(g_pNAT->m_pNATState, cb Frame, &pvSlirpFrame, &cbIgnored);294 m = slirp_ext_m_get(g_pNAT->m_pNATState, cbSegFrame, &pvSlirpFrame, &cbIgnored); 286 295 if (!m) 287 296 { … … 290 299 break; 291 300 } 292 memcpy(pvSlirpFrame, pvSegFrame, cb Frame);301 memcpy(pvSlirpFrame, pvSegFrame, cbSegFrame); 293 302 294 303 rc = RTReqCallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, … … 297 306 AssertReleaseRC(rc); 298 307 } 299 IntNetRingSkipFrame(&m_pIfBuf->Recv);300 308 } 301 309 break; 310 #endif 302 311 case INTNETHDR_TYPE_PADDING: 303 IntNetRingSkipFrame(&m_pIfBuf->Recv);304 312 break; 305 313 default: 306 IntNetRingSkipFrame(&m_pIfBuf->Recv);307 314 STAM_REL_COUNTER_INC(&m_pIfBuf->cStatBadFrames); 308 315 break; 309 316 } 310 317 311 #ifndef RT_OS_WINDOWS 312 /* kick select() */ 313 rc = RTPipeWrite(m_hPipeWrite, "", 1, &cbIgnored); 314 AssertRC(rc); 315 #else 316 /* kick WSAWaitForMultipleEvents */ 317 rc = WSASetEvent(m_hWakeupEvent); 318 AssertRelease(rc == TRUE); 319 #endif 318 IntNetRingSkipFrame(&m_pIfBuf->Recv); 320 319 } 321 natNotifyNATThread();322 323 320 } 324 321 fIsRunning = false; … … 359 356 extern "C" void slirp_urg_output(void *pvUser, struct mbuf *m, const uint8_t *pu8Buf, int cb) 360 357 { 358 LogFlowFunc(("ENTER: m:%p, pu8Buf:%p, cb:%d\n", m, pu8Buf, cb)); 361 359 int rc = RTReqCallEx(g_pNAT->m_pUrgSendQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 362 360 (PFNRT)IntNetSendWorker, 4, (uintptr_t)1, (uintptr_t)pu8Buf, (uintptr_t)cb, (uintptr_t)m); … … 364 362 RTSemEventSignal(g_pNAT->m_EventUrgSend); 365 363 AssertReleaseRC(rc); 364 LogFlowFuncLeave(); 366 365 } 367 366 extern "C" void slirp_output(void *pvUser, struct mbuf *m, const uint8_t *pu8Buf, int cb) 368 367 { 368 LogFlowFunc(("ENTER: m:%p, pu8Buf:%p, cb:%d\n", m, pu8Buf, cb)); 369 369 AssertRelease(g_pNAT == pvUser); 370 370 int rc = RTReqCallEx(g_pNAT->m_pSendQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, … … 373 373 RTSemEventSignal(g_pNAT->m_EventSend); 374 374 AssertReleaseRC(rc); 375 LogFlowFuncLeave(); 375 376 } 376 377 … … 386 387 static void SendWorker(struct mbuf *m, size_t cb) 387 388 { 389 LogFlowFunc(("ENTER: m:%p ,cb:%d\n", m, cb)); 388 390 slirp_input(g_pNAT->m_pNATState, m, cb); 389 } 390 391 static void IntNetSendWorker(bool urg, void *pvFrame, size_t cbFrame, struct mbuf *m) 392 { 393 Log2(("VBoxNetNAT: going to send some bytes ... \n")); 391 LogFlowFuncLeave(); 392 } 393 394 static void IntNetSendWorker(bool fUrg, void *pvFrame, size_t cbFrame, struct mbuf *m) 395 { 394 396 VBoxNetNAT *pThis = g_pNAT; 395 397 INTNETIFSENDREQ SendReq; 396 398 int rc; 397 399 398 if (!urg) 399 { 400 while (ASMAtomicReadU32(&g_pNAT->cUrgPkt) != 0 400 LogFlowFunc(("ENTER: urg:%RTbool ,pvFrame:%p, cbFrame:%d, m:%p\n", fUrg, pvFrame, cbFrame, m)); 401 if (!fUrg) 402 { 403 /* non-urgent datagramm sender */ 404 while ( ASMAtomicReadU32(&g_pNAT->cUrgPkt) != 0 401 405 || ASMAtomicReadU32(&g_pNAT->cPkt) == 0) 402 406 rc = RTSemEventWait(g_pNAT->m_EventSend, RT_INDEFINITE_WAIT); … … 427 431 rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_SEND, 0, &SendReq.Hdr); 428 432 } 433 AssertRC((rc)); 429 434 if (RT_FAILURE(rc)) 430 435 Log2(("VBoxNetNAT: Failed to send packet; rc=%Rrc\n", rc)); 431 436 432 if (! urg)437 if (!fUrg) 433 438 { 434 439 ASMAtomicDecU32(&g_pNAT->cPkt); … … 438 443 RTSemEventSignal(g_pNAT->m_EventSend); 439 444 } 445 slirp_ext_m_free(pThis->m_pNATState, m, (uint8_t *)pvFrame); 440 446 natNotifyNATThread(); 441 slirp_ext_m_free(pThis->m_pNATState, m, (uint8_t *)pvFrame);447 LogFlowFuncLeave(); 442 448 } 443 449
Note:
See TracChangeset
for help on using the changeset viewer.