- Timestamp:
- Nov 6, 2020 12:46:48 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
r85506 r86822 139 139 int ifActivate(); 140 140 141 int ifWait(uint32_t cMillies = RT_INDEFINITE_WAIT);142 141 int ifProcessInput(); 143 142 int ifFlush(); … … 378 377 379 378 379 /** 380 * Process incoming packages forever. 381 * 382 * @note This function normally never returns, given that the process is 383 * typically just killed when shutting down a network. 384 */ 380 385 void VBoxNetDhcpd::ifPump() 381 386 { 382 387 for (;;) 383 388 { 384 int rc = ifWait(); 385 if ( rc != VERR_INTERRUPTED 386 #if 0 /* we wait indefinitely */ 387 && rc != VERR_TIMEOUT 388 #endif 389 ) 389 /* 390 * Wait for input: 391 */ 392 INTNETIFWAITREQ WaitReq; 393 WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 394 WaitReq.Hdr.cbReq = sizeof(WaitReq); 395 WaitReq.pSession = m_pSession; 396 WaitReq.hIf = m_hIf; 397 WaitReq.cMillies = RT_INDEFINITE_WAIT; 398 int rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_WAIT, WaitReq); 399 400 /* 401 * Process any pending input before we wait again: 402 */ 403 if ( RT_SUCCESS(rc) 404 || rc == VERR_INTERRUPTED 405 || rc == VERR_TIMEOUT /* paranoia */) 390 406 ifProcessInput(); 391 407 else … … 398 414 399 415 400 int VBoxNetDhcpd::ifWait(uint32_t cMillies)401 {402 AssertReturn(m_pSession != NIL_RTR0PTR, VERR_GENERAL_FAILURE);403 AssertReturn(m_hIf != INTNET_HANDLE_INVALID, VERR_GENERAL_FAILURE);404 405 INTNETIFWAITREQ WaitReq;406 int rc;407 408 WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;409 WaitReq.Hdr.cbReq = sizeof(WaitReq);410 WaitReq.pSession = m_pSession;411 WaitReq.hIf = m_hIf;412 413 WaitReq.cMillies = cMillies;414 415 rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_WAIT, WaitReq);416 return rc;417 }418 419 420 416 int VBoxNetDhcpd::ifProcessInput() 421 417 { … … 424 420 AssertReturn(m_pIfBuf != NULL, VERR_GENERAL_FAILURE); 425 421 426 for (PCINTNETHDR pHdr; 427 (pHdr = IntNetRingGetNextFrameToRead(&m_pIfBuf->Recv)) != NULL; 428 IntNetRingSkipFrame(&m_pIfBuf->Recv)) 422 PCINTNETHDR pHdr = IntNetRingGetNextFrameToRead(&m_pIfBuf->Recv); 423 while (pHdr) 429 424 { 430 425 const uint8_t u8Type = pHdr->u8Type; … … 441 436 else if (u8Type == INTNETHDR_TYPE_GSO) 442 437 { 443 PCPDMNETWORKGSO pGso;444 438 size_t cbGso = pHdr->cbFrame; 445 439 size_t cbFrame = cbGso - sizeof(PDMNETWORKGSO); 446 440 447 pGso = IntNetHdrGetGsoContext(pHdr, m_pIfBuf); 448 if (!PDMNetGsoIsValid(pGso, cbGso, cbFrame)) 449 continue; 450 451 const uint32_t cSegs = PDMNetGsoCalcSegmentCount(pGso, cbFrame); 452 for (uint32_t i = 0; i < cSegs; ++i) 441 PCPDMNETWORKGSO pGso = IntNetHdrGetGsoContext(pHdr, m_pIfBuf); 442 if (PDMNetGsoIsValid(pGso, cbGso, cbFrame)) 453 443 { 454 uint8_t abHdrScratch[256]; 455 pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)(pGso + 1), cbFrame, 456 abHdrScratch, 457 i, cSegs, 458 &cbSegFrame); 459 ifInput(pvSegFrame, (uint32_t)cbFrame); 444 const uint32_t cSegs = PDMNetGsoCalcSegmentCount(pGso, cbFrame); 445 for (uint32_t i = 0; i < cSegs; ++i) 446 { 447 uint8_t abHdrScratch[256]; 448 pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)(pGso + 1), cbFrame, 449 abHdrScratch, 450 i, cSegs, 451 &cbSegFrame); 452 ifInput(pvSegFrame, (uint32_t)cbFrame); 453 } 460 454 } 461 455 } 456 457 /* Advance: */ 458 IntNetRingSkipFrame(&m_pIfBuf->Recv); 459 pHdr = IntNetRingGetNextFrameToRead(&m_pIfBuf->Recv); 462 460 } 463 461 … … 491 489 struct pbuf *q = p; 492 490 uint8_t *pbChunk = (uint8_t *)pvFrame; 493 do { 491 do 492 { 494 493 uint8_t *payload = (uint8_t *)q->payload; 495 494 size_t len = q->len; … … 517 516 err_t VBoxNetDhcpd::netifLinkOutput(pbuf *pPBuf) 518 517 { 518 if (pPBuf->tot_len < sizeof(struct eth_hdr)) /* includes ETH_PAD_SIZE */ 519 return ERR_ARG; 520 519 521 PINTNETHDR pHdr; 520 522 void *pvFrame; 521 u16_t cbFrame; 522 int rc; 523 524 if (pPBuf->tot_len < sizeof(struct eth_hdr)) /* includes ETH_PAD_SIZE */ 525 return ERR_ARG; 526 527 cbFrame = pPBuf->tot_len - ETH_PAD_SIZE; 528 rc = IntNetRingAllocateFrame(&m_pIfBuf->Send, cbFrame, &pHdr, &pvFrame); 523 u16_t cbFrame = pPBuf->tot_len - ETH_PAD_SIZE; 524 int rc = IntNetRingAllocateFrame(&m_pIfBuf->Send, cbFrame, &pHdr, &pvFrame); 529 525 if (RT_FAILURE(rc)) 530 526 return ERR_MEM; … … 541 537 { 542 538 INTNETIFSENDREQ SendReq; 543 int rc;544 539 545 540 SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; … … 549 544 SendReq.hIf = m_hIf; 550 545 551 rc = CALL_VMMR0(VMMR0_DO_INTNET_IF_SEND, SendReq); 552 return rc; 546 return CALL_VMMR0(VMMR0_DO_INTNET_IF_SEND, SendReq); 553 547 } 554 548
Note:
See TracChangeset
for help on using the changeset viewer.