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
Implementation of the Socket.
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -717,16 +717,8 @@ SockDestroy (
IN OUT SOCKET *Sock
)
{
VOID *SockProtocol;
EFI_GUID *ProtocolGuid;
EFI_STATUS Status;
ASSERT (SockStream == Sock->Type);
if (Sock->DestroyCallback != NULL) {
Sock->DestroyCallback (Sock, Sock->Context);
}
//
// Flush the completion token buffered
// by sock and rcv, snd buffer
@@ -762,44 +754,6 @@ SockDestroy (
Sock->Parent = NULL;
}
//
// Set the protocol guid and driver binding handle
// in the light of Sock->SockType
//
ProtocolGuid = &gEfiTcp4ProtocolGuid;
//
// Retrieve the protocol installed on this sock
//
Status = gBS->OpenProtocol (
Sock->SockHandle,
ProtocolGuid,
&SockProtocol,
Sock->DriverBinding,
Sock->SockHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "SockDestroy: Open protocol installed "
"on socket failed with %r\n", Status));
goto FreeSock;
}
//
// Uninstall the protocol installed on this sock
// in the light of Sock->SockType
//
gBS->UninstallMultipleProtocolInterfaces (
Sock->SockHandle,
ProtocolGuid,
SockProtocol,
NULL
);
FreeSock:
FreePool (Sock);
return ;
}