From 75dce340624dba5e4a79b2e5b2dbe943bae0d0e9 Mon Sep 17 00:00:00 2001 From: sfu5 Date: Wed, 17 Oct 2012 08:23:41 +0000 Subject: =?UTF-8?q?1.=20Fix=20a=20bug=20in=20PXE=20driver=20that=20the=20P?= =?UTF-8?q?XE=20boot=20do=20not=20restart=20if=20a=20new=20boot=20option?= =?UTF-8?q?=20on=20the=20different=20IP=20stack=20is=20selected.=202.=20Re?= =?UTF-8?q?trieve=20the=20IP=20information=20after=20iSCSI=20TCPv6=20conne?= =?UTF-8?q?ction=20established=20and=20fill=20it=20into=20iBFT=20table.=20?= =?UTF-8?q?3.=20Generate=20a=20random=20IAID=20for=20each=20NIC=20port=20t?= =?UTF-8?q?o=20require=20different=20IPv6=20address=20in=20PXE=20driver.?= =?UTF-8?q?=204.=20Update=20function=20EfiMtftp6Configure()=20and=20Mtftp6?= =?UTF-8?q?RrqHandleOack()=20to=20allocate=20at=20most=20one=20UdpIo.=205.?= =?UTF-8?q?=20Fix=20a=20typo=20from=20=E2=80=9Cdestory=E2=80=9D=20to=20?= =?UTF-8?q?=E2=80=9Cdestroy=E2=80=9D=20in=20network=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Ouyang Qian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13859 6f19259b-4bc3-4df7-8a09-765794883524 --- NetworkPkg/IScsiDxe/IScsiIbft.c | 14 +++--- NetworkPkg/IScsiDxe/IScsiImpl.h | 3 +- NetworkPkg/IScsiDxe/IScsiMisc.h | 7 +-- NetworkPkg/IScsiDxe/IScsiProto.c | 96 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 11 deletions(-) (limited to 'NetworkPkg/IScsiDxe') diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c index e90c982bc2..879d310cc9 100644 --- a/NetworkPkg/IScsiDxe/IScsiIbft.c +++ b/NetworkPkg/IScsiDxe/IScsiIbft.c @@ -1,7 +1,7 @@ /** @file Implementation for iSCSI Boot Firmware Table publication. -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
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 @@ -310,18 +310,18 @@ IScsiFillNICAndTargetSections ( // // Map the various v4 addresses into v6 addresses. // - IScsiMapV4ToV6Addr (&NvData->LocalIp, &Nic->Ip); - IScsiMapV4ToV6Addr (&NvData->Gateway, &Nic->Gateway); + IScsiMapV4ToV6Addr (&NvData->LocalIp.v4, &Nic->Ip); + IScsiMapV4ToV6Addr (&NvData->Gateway.v4, &Nic->Gateway); IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns); IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns); IScsiMapV4ToV6Addr (&Attempt->DhcpServer.v4, &Nic->DhcpServer); } else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) { - // - // TODO: The subnet mask/local ip/gateway/dhcpserver for iBFT-IPv6 needs to be - // confirmed with spec owner. - // + Nic->SubnetMaskPrefixLength = NvData->PrefixLength; + CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS)); + CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS)); + CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS)); // diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiImpl.h index ccb83edb84..7c8eb37842 100644 --- a/NetworkPkg/IScsiDxe/IScsiImpl.h +++ b/NetworkPkg/IScsiDxe/IScsiImpl.h @@ -1,7 +1,7 @@ /** @file The shared head file for iSCSI driver. -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
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 @@ -23,6 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include #include diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.h index 8646f666a4..c9ff96da6c 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.h +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h @@ -1,7 +1,7 @@ /** @file Miscellaneous definitions for iSCSI driver. -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
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 @@ -23,14 +23,15 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA { UINT8 Enabled; UINT8 IpMode; - EFI_IPv4_ADDRESS LocalIp; + EFI_IP_ADDRESS LocalIp; EFI_IPv4_ADDRESS SubnetMask; - EFI_IPv4_ADDRESS Gateway; + EFI_IP_ADDRESS Gateway; BOOLEAN InitiatorInfoFromDhcp; BOOLEAN TargetInfoFromDhcp; CHAR8 TargetName[ISCSI_NAME_MAX_SIZE]; EFI_IP_ADDRESS TargetIp; + UINT8 PrefixLength; UINT8 BootLun[8]; UINT16 ConnectTimeout; ///< timout value in milliseconds diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c index 72c90a7fe8..3dabb00d4a 100644 --- a/NetworkPkg/IScsiDxe/IScsiProto.c +++ b/NetworkPkg/IScsiDxe/IScsiProto.c @@ -308,6 +308,98 @@ IScsiDestroyConnection ( FreePool (Conn); } +/** + Retrieve the IPv6 Address/Prefix/Gateway from the established TCP connection, these informations + will be filled in the iSCSI Boot Firmware Table. + + @param[in] Conn The connection used in the iSCSI login phase. + + @retval EFI_SUCCESS Get the NIC information successfully. + @retval Others Other errors as indicated. + +**/ +EFI_STATUS +IScsiGetIp6NicInfo ( + IN ISCSI_CONNECTION *Conn + ) +{ + ISCSI_SESSION_CONFIG_NVDATA *NvData; + EFI_TCP6_PROTOCOL *Tcp6; + EFI_IP6_MODE_DATA Ip6ModeData; + EFI_STATUS Status; + EFI_IPv6_ADDRESS *TargetIp; + UINTN Index; + UINT8 SubnetPrefixLength; + UINTN RouteEntry; + + NvData = &Conn->Session->ConfigData->SessionConfigData; + TargetIp = &NvData->TargetIp.v6; + Tcp6 = Conn->TcpIo.Tcp.Tcp6; + + ZeroMem (&Ip6ModeData, sizeof (EFI_IP6_MODE_DATA)); + Status = Tcp6->GetModeData ( + Tcp6, + NULL, + NULL, + &Ip6ModeData, + NULL, + NULL + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (!Ip6ModeData.IsConfigured) { + Status = EFI_ABORTED; + goto ON_EXIT; + } + + IP6_COPY_ADDRESS (&NvData->LocalIp, &Ip6ModeData.ConfigData.StationAddress); + + NvData->PrefixLength = 0; + for (Index = 0; Index < Ip6ModeData.AddressCount; Index++) { + if (EFI_IP6_EQUAL (&NvData->LocalIp.v6, &Ip6ModeData.AddressList[Index].Address)) { + NvData->PrefixLength = Ip6ModeData.AddressList[Index].PrefixLength; + break; + } + } + + SubnetPrefixLength = 0; + RouteEntry = Ip6ModeData.RouteCount; + for (Index = 0; Index < Ip6ModeData.RouteCount; Index++) { + if (NetIp6IsNetEqual (TargetIp, &Ip6ModeData.RouteTable[Index].Destination, Ip6ModeData.RouteTable[Index].PrefixLength)) { + if (SubnetPrefixLength < Ip6ModeData.RouteTable[Index].PrefixLength) { + SubnetPrefixLength = Ip6ModeData.RouteTable[Index].PrefixLength; + RouteEntry = Index; + } + } + } + if (RouteEntry != Ip6ModeData.RouteCount) { + IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway); + } + +ON_EXIT: + if (Ip6ModeData.AddressList != NULL) { + FreePool (Ip6ModeData.AddressList); + } + if (Ip6ModeData.GroupTable!= NULL) { + FreePool (Ip6ModeData.GroupTable); + } + if (Ip6ModeData.RouteTable!= NULL) { + FreePool (Ip6ModeData.RouteTable); + } + if (Ip6ModeData.NeighborCache!= NULL) { + FreePool (Ip6ModeData.NeighborCache); + } + if (Ip6ModeData.PrefixTable!= NULL) { + FreePool (Ip6ModeData.PrefixTable); + } + if (Ip6ModeData.IcmpTypeList!= NULL) { + FreePool (Ip6ModeData.IcmpTypeList); + } + + return Status; +} /** Login the iSCSI session. @@ -395,6 +487,10 @@ IScsiSessionLogin ( ); ASSERT_EFI_ERROR (Status); + + if (mPrivate->Ipv6Flag) { + Status = IScsiGetIp6NicInfo (Conn); + } } return Status; -- cgit v1.2.3