Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Driver.c
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Driver.c
r48674 r58459 2 2 The driver binding and service binding protocol for IP6 driver. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 95 95 the resource allocated by the instance. The instance may be 96 96 partly initialized, or partly destroyed. If a resource is 97 destroyed, it is marked as that in case the dest ory failed and97 destroyed, it is marked as that in case the destroy failed and 98 98 being called again later. 99 99 … … 115 115 Ip6ConfigCleanInstance (&IpSb->Ip6ConfigInstance); 116 116 117 // 118 // Leave link-scope all-nodes multicast address (FF02::1) 119 // 120 Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes); 121 122 Status = Ip6LeaveGroup (IpSb, &AllNodes); 123 if (EFI_ERROR (Status)) { 124 return Status; 117 if (!IpSb->LinkLocalDadFail) { 118 // 119 // Leave link-scope all-nodes multicast address (FF02::1) 120 // 121 Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes); 122 123 Status = Ip6LeaveGroup (IpSb, &AllNodes); 124 if (EFI_ERROR (Status)) { 125 return Status; 126 } 125 127 } 126 128 … … 245 247 IpSb->ServiceBinding.DestroyChild = Ip6ServiceBindingDestroyChild; 246 248 IpSb->State = IP6_SERVICE_UNSTARTED; 247 IpSb->InDestroy = FALSE;248 249 249 250 IpSb->NumChildren = 0; … … 412 413 } 413 414 414 // 415 // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds. 416 // 417 Status = gBS->SetTimer (IpSb->FasterTimer, TimerPeriodic, TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS); 418 if (EFI_ERROR (Status)) { 419 goto ON_ERROR; 420 } 421 422 // 423 // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds. 424 // 425 Status = gBS->SetTimer (IpSb->Timer, TimerPeriodic, TICKS_PER_MS * IP6_ONE_SECOND_IN_MS); 426 if (EFI_ERROR (Status)) { 427 goto ON_ERROR; 428 } 429 415 Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString); 416 if (EFI_ERROR (Status)) { 417 goto ON_ERROR; 418 } 419 420 Status = Ip6ConfigInitInstance (&IpSb->Ip6ConfigInstance); 421 if (EFI_ERROR (Status)) { 422 goto ON_ERROR; 423 } 424 425 IpSb->DefaultInterface = Ip6CreateInterface (IpSb, TRUE); 426 if (IpSb->DefaultInterface == NULL) { 427 Status = EFI_DEVICE_ERROR; 428 goto ON_ERROR; 429 } 430 430 431 431 Status = gBS->CreateEvent ( … … 440 440 } 441 441 442 Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);443 if (EFI_ERROR (Status)) {444 goto ON_ERROR;445 }446 447 Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);448 if (EFI_ERROR (Status)) {449 goto ON_ERROR;450 }451 452 Status = Ip6ConfigInitInstance (&IpSb->Ip6ConfigInstance);453 if (EFI_ERROR (Status)) {454 goto ON_ERROR;455 }456 457 IpSb->DefaultInterface = Ip6CreateInterface (IpSb, TRUE);458 if (IpSb->DefaultInterface == NULL) {459 Status = EFI_DEVICE_ERROR;460 goto ON_ERROR;461 }462 463 442 // 464 443 // If there is any manual address, set it. 465 444 // 466 445 DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeManualAddress]; 446 if (DataItem->Data.Ptr != NULL) { 447 DataItem->SetData ( 448 &IpSb->Ip6ConfigInstance, 449 DataItem->DataSize, 450 DataItem->Data.Ptr 451 ); 452 } 453 454 // 455 // If there is any gateway address, set it. 456 // 457 DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway]; 467 458 if (DataItem->Data.Ptr != NULL) { 468 459 DataItem->SetData ( … … 545 536 ); 546 537 547 if (EFI_ERROR (Status)) { 548 549 Ip6CleanService (IpSb); 550 FreePool (IpSb); 551 } else { 538 if (!EFI_ERROR (Status)) { 539 // 540 // ready to go: start the receiving and timer 541 // 542 Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb); 543 if (EFI_ERROR (Status)) { 544 goto ON_ERROR; 545 } 546 547 // 548 // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds. 549 // 550 Status = gBS->SetTimer ( 551 IpSb->FasterTimer, 552 TimerPeriodic, 553 TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS 554 ); 555 if (EFI_ERROR (Status)) { 556 goto ON_ERROR; 557 } 558 559 // 560 // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds. 561 // 562 Status = gBS->SetTimer ( 563 IpSb->Timer, 564 TimerPeriodic, 565 TICKS_PER_MS * IP6_ONE_SECOND_IN_MS 566 ); 567 if (EFI_ERROR (Status)) { 568 goto ON_ERROR; 569 } 570 552 571 // 553 572 // Initialize the IP6 ID … … 555 574 mIp6Id = NET_RANDOM (NetRandomInitSeed ()); 556 575 557 Ip6SetVariableData (IpSb); 558 } 559 576 return EFI_SUCCESS; 577 } 578 579 ON_ERROR: 580 Ip6CleanService (IpSb); 581 FreePool (IpSb); 560 582 return Status; 583 } 584 585 /** 586 Callback function which provided by user to remove one node in NetDestroyLinkList process. 587 588 @param[in] Entry The entry to be removed. 589 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 590 591 @retval EFI_SUCCESS The entry has been removed successfully. 592 @retval Others Fail to remove the entry. 593 594 **/ 595 EFI_STATUS 596 EFIAPI 597 Ip6DestroyChildEntryInHandleBuffer ( 598 IN LIST_ENTRY *Entry, 599 IN VOID *Context 600 ) 601 { 602 IP6_PROTOCOL *IpInstance; 603 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 604 UINTN NumberOfChildren; 605 EFI_HANDLE *ChildHandleBuffer; 606 607 if (Entry == NULL || Context == NULL) { 608 return EFI_INVALID_PARAMETER; 609 } 610 611 IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE); 612 ServiceBinding = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; 613 NumberOfChildren = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; 614 ChildHandleBuffer = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; 615 616 if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) { 617 return EFI_SUCCESS; 618 } 619 620 return ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle); 561 621 } 562 622 … … 584 644 ) 585 645 { 586 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;587 IP6_SERVICE *IpSb;588 IP6_PROTOCOL *IpInstance;589 EFI_ HANDLE NicHandle;590 EFI_STATUS Status;591 BOOLEAN IsDhcp6;592 EFI_TPL OldTpl;593 I NTN State;646 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 647 IP6_SERVICE *IpSb; 648 EFI_HANDLE NicHandle; 649 EFI_STATUS Status; 650 LIST_ENTRY *List; 651 INTN State; 652 BOOLEAN IsDhcp6; 653 IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; 594 654 595 655 IsDhcp6 = FALSE; 596 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid); 597 598 if (NicHandle != NULL) { 599 // 600 // DriverBindingStop is triggered by the uninstallation of the EFI DHCPv6 601 // Protocol used by Ip6Config. 602 // 603 IsDhcp6 = TRUE; 604 } else { 605 606 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); 607 608 if (NicHandle == NULL) { 609 return EFI_DEVICE_ERROR; 656 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); 657 if (NicHandle == NULL) { 658 NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid); 659 if (NicHandle != NULL) { 660 IsDhcp6 = TRUE; 661 } else { 662 return EFI_SUCCESS; 610 663 } 611 664 } … … 625 678 IpSb = IP6_SERVICE_FROM_PROTOCOL (ServiceBinding); 626 679 627 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);628 629 if (IpSb->InDestroy) {630 Status = EFI_SUCCESS;631 goto Exit;632 }633 634 680 if (IsDhcp6) { 635 636 681 Status = Ip6ConfigDestroyDhcp6 (&IpSb->Ip6ConfigInstance); 637 682 gBS->CloseEvent (IpSb->Ip6ConfigInstance.Dhcp6Event); 638 683 IpSb->Ip6ConfigInstance.Dhcp6Event = NULL; 639 } else if (NumberOfChildren == 0) { 640 641 IpSb->InDestroy = TRUE; 684 } else if (NumberOfChildren != 0) { 685 // 686 // NumberOfChildren is not zero, destroy the IP6 children instances in ChildHandleBuffer. 687 // 688 List = &IpSb->Children; 689 Context.ServiceBinding = ServiceBinding; 690 Context.NumberOfChildren = NumberOfChildren; 691 Context.ChildHandleBuffer = ChildHandleBuffer; 692 Status = NetDestroyLinkList ( 693 List, 694 Ip6DestroyChildEntryInHandleBuffer, 695 &Context, 696 NULL 697 ); 698 } else if (IsListEmpty (&IpSb->Children)) { 642 699 State = IpSb->State; 643 700 IpSb->State = IP6_SERVICE_DESTROY; 644 645 //646 // Clear the variable data.647 //648 Ip6ClearVariableData (IpSb);649 701 650 702 Status = Ip6CleanService (IpSb); … … 664 716 ASSERT_EFI_ERROR (Status); 665 717 FreePool (IpSb); 666 } else { 667 // 668 // NumberOfChildren is not zero, destroy all IP6 children instances. 669 // 670 while (!IsListEmpty (&IpSb->Children)) { 671 IpInstance = NET_LIST_HEAD (&IpSb->Children, IP6_PROTOCOL, Link); 672 ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle); 673 } 674 675 if (IpSb->NumChildren != 0) { 676 Status = EFI_DEVICE_ERROR; 677 } 678 } 679 718 Status = EFI_SUCCESS; 719 } 720 680 721 Exit: 681 682 gBS->RestoreTPL (OldTpl);683 684 722 return Status; 685 723 } … … 819 857 EFI_IP6_PROTOCOL *Ip6; 820 858 EFI_TPL OldTpl; 821 INTN State;822 859 823 860 if ((This == NULL) || (ChildHandle == NULL)) { … … 853 890 // 854 891 // A child can be destroyed more than once. For example, 855 // Ip6DriverBindingStop will dest ory all of its children.856 // when UDP driver is being stopped, it will dest ory all892 // Ip6DriverBindingStop will destroy all of its children. 893 // when UDP driver is being stopped, it will destroy all 857 894 // the IP child it opens. 858 895 // 859 if (IpInstance-> State == IP6_STATE_DESTROY) {896 if (IpInstance->InDestroy) { 860 897 gBS->RestoreTPL (OldTpl); 861 898 return EFI_SUCCESS; 862 899 } 863 900 864 State = IpInstance->State; 865 IpInstance->State = IP6_STATE_DESTROY; 901 IpInstance->InDestroy = TRUE; 866 902 867 903 // … … 889 925 // that means there is a resource leak. 890 926 // 927 gBS->RestoreTPL (OldTpl); 891 928 Status = gBS->UninstallProtocolInterface ( 892 929 ChildHandle, … … 894 931 &IpInstance->Ip6Proto 895 932 ); 896 933 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 897 934 if (EFI_ERROR (Status)) { 898 935 goto ON_ERROR; … … 900 937 901 938 Status = Ip6CleanProtocol (IpInstance); 902 903 Ip6SetVariableData (IpSb);904 905 939 if (EFI_ERROR (Status)) { 906 940 gBS->InstallMultipleProtocolInterfaces ( … … 924 958 925 959 ON_ERROR: 926 IpInstance->State = State;927 960 gBS->RestoreTPL (OldTpl); 928 961
Note:
See TracChangeset
for help on using the changeset viewer.