MdeModulePkg: Fix service binding issue in TCP4 and Ip4 dxe.

v2: Handle error case in SockCreateChild and fix typo issue

when we destroy the socket Sock and its associated
protocol control block, we need to first close the
parent protocol, then remove the protocol from childHandle
and last to free any data structures that allocated in
CreateChild. But currently, we free the socket data
(Socket ConfigureState) before removing the protocol
form  the childhandle. So if the up layer want to send the
tcp reset packet in it's driver binding stop function, it will failed.

The IpInstance destroy state is redundant and may cause
ip transmit failed if up layer want to send ip packet.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
Zhang Lubo
2017-03-16 18:03:36 +08:00
committed by Jiaxin Wu
parent 962e62bcd8
commit 4bb89650f5
7 changed files with 96 additions and 77 deletions

View File

@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for IP4 driver.
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
@@ -922,7 +922,6 @@ Ip4ServiceBindingDestroyChild (
IP4_PROTOCOL *IpInstance;
EFI_IP4_PROTOCOL *Ip4;
EFI_TPL OldTpl;
INTN State;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -960,13 +959,12 @@ Ip4ServiceBindingDestroyChild (
// when UDP driver is being stopped, it will destroy all
// the IP child it opens.
//
if (IpInstance->State == IP4_STATE_DESTROY) {
if (IpInstance->InDestroy) {
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
State = IpInstance->State;
IpInstance->State = IP4_STATE_DESTROY;
IpInstance->InDestroy = TRUE;
//
// Close the Managed Network protocol.
@@ -1009,6 +1007,7 @@ Ip4ServiceBindingDestroyChild (
);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (EFI_ERROR (Status)) {
IpInstance->InDestroy = FALSE;
goto ON_ERROR;
}
@@ -1033,7 +1032,6 @@ Ip4ServiceBindingDestroyChild (
return EFI_SUCCESS;
ON_ERROR:
IpInstance->State = State;
gBS->RestoreTPL (OldTpl);
return Status;

View File

@@ -550,6 +550,7 @@ Ip4InitProtocol (
IpInstance->Signature = IP4_PROTOCOL_SIGNATURE;
CopyMem (&IpInstance->Ip4Proto, &mEfiIp4ProtocolTemplete, sizeof (IpInstance->Ip4Proto));
IpInstance->State = IP4_STATE_UNCONFIGED;
IpInstance->InDestroy = FALSE;
IpInstance->Service = IpSb;
InitializeListHead (&IpInstance->Link);
@@ -936,8 +937,7 @@ EfiIp4Configure (
Status = Ip4CleanProtocol (IpInstance);
//
// Don't change the state if it is DESTROY, consider the following
// valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
// Consider the following valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
// Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,
// the unload fails miserably.
//

View File

@@ -1,7 +1,7 @@
/** @file
Ip4 internal functions and type defintions.
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
@@ -64,12 +64,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// The state of IP4 protocol. It starts from UNCONFIGED. if it is
// successfully configured, it goes to CONFIGED. if configure NULL
// is called, it becomes UNCONFIGED again. If (partly) destroyed, it
// becomes DESTROY.
// is called, it becomes UNCONFIGED again.
//
#define IP4_STATE_UNCONFIGED 0
#define IP4_STATE_CONFIGED 1
#define IP4_STATE_DESTROY 2
//
// The state of IP4 service. It starts from UNSTARTED. It transits
@@ -136,6 +134,8 @@ struct _IP4_PROTOCOL {
EFI_HANDLE Handle;
INTN State;
BOOLEAN InDestroy;
IP4_SERVICE *Service;
LIST_ENTRY Link; // Link to all the IP protocol from the service