From nobody Sat May 4 22:36:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521508190364742.0290525465871; Mon, 19 Mar 2018 18:09:50 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5810920954B97; Mon, 19 Mar 2018 18:03:14 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BE673225B0286 for ; Mon, 19 Mar 2018 18:03:12 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2018 18:09:40 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.39]) by orsmga005.jf.intel.com with ESMTP; 19 Mar 2018 18:09:39 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,332,1517904000"; d="scan'208";a="209642492" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 09:09:37 +0800 Message-Id: <20180320010937.11272-1-jiaxin.wu@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [edk2] [Patch] NetworkPkg/UefiPxeBcDxe: Configure the ARP Instance/RouteTable with new address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" After completed a DHCP D.O.R.A process and got the new address, the ARP Ins= tance and RouteTable should be configured so as to avoid the later Pxe.Arp failur= e. Cc: Fu Siyuan Cc: Ye Ting Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu Reviewed-by: Fu Siyuan --- NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 26 +++----------- NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 66 ++++++++++++++++++++++++------= ---- 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/= PxeBcImpl.c index d3146c3a7e..b828d24288 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c @@ -2001,11 +2001,10 @@ EfiPxeBcSetStationIP ( ) { EFI_STATUS Status; PXEBC_PRIVATE_DATA *Private; EFI_PXE_BASE_CODE_MODE *Mode; - EFI_ARP_CONFIG_DATA ArpConfigData; =20 if (This =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 @@ -2041,31 +2040,10 @@ EfiPxeBcSetStationIP ( // Status =3D PxeBcRegisterIp6Address (Private, &NewStationIp->v6); if (EFI_ERROR (Status)) { goto ON_EXIT; } - } else if (!Mode->UsingIpv6 && NewStationIp !=3D NULL) { - // - // Configure the corresponding ARP with the IPv4 address. - // - ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA)); - - ArpConfigData.SwAddressType =3D 0x0800; - ArpConfigData.SwAddressLength =3D (UINT8) sizeof (EFI_IPv4_ADDRESS); - ArpConfigData.StationAddress =3D &NewStationIp->v4; - - Private->Arp->Configure (Private->Arp, NULL); - Private->Arp->Configure (Private->Arp, &ArpConfigData); - - if (NewSubnetMask !=3D NULL) { - Mode->RouteTableEntries =3D 1; - Mode->RouteTable[0].IpAddr.Addr[0] =3D NewStationIp->Addr[0] & N= ewSubnetMask->Addr[0]; - Mode->RouteTable[0].SubnetMask.Addr[0] =3D NewSubnetMask->Addr[0]; - Mode->RouteTable[0].GwAddr.Addr[0] =3D 0; - } - - Private->IsAddressOk =3D TRUE; } =20 if (NewStationIp !=3D NULL) { CopyMem (&Mode->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS)); CopyMem (&Private->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS)); @@ -2075,10 +2053,14 @@ EfiPxeBcSetStationIP ( CopyMem (&Mode->SubnetMask, NewSubnetMask, sizeof (EFI_IP_ADDRESS)); CopyMem (&Private->SubnetMask ,NewSubnetMask, sizeof (EFI_IP_ADDRESS)); } =20 Status =3D PxeBcFlushStationIp (Private, NewStationIp, NewSubnetMask); + if (!EFI_ERROR (Status)) { + Private->IsAddressOk =3D TRUE; + } + =20 ON_EXIT: return Status; } =20 =20 diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c b/NetworkPkg/UefiPxeBcD= xe/PxeBcSupport.c index 47bb7c5dbb..4b6f8c9c7f 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c @@ -1,9 +1,9 @@ /** @file Support functions implementation for UefiPxeBc Driver. =20 - Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -34,21 +34,23 @@ PxeBcFlushStationIp ( EFI_IP_ADDRESS *SubnetMask OPTIONAL ) { EFI_PXE_BASE_CODE_MODE *Mode; EFI_STATUS Status; + EFI_ARP_CONFIG_DATA ArpConfigData; =20 Mode =3D Private->PxeBc.Mode; Status =3D EFI_SUCCESS; + ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA)); =20 - if (Mode->UsingIpv6) { - - if (StationIp !=3D NULL) { - CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EF= I_IPv6_ADDRESS)); - CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI= _IPv6_ADDRESS)); - } - + if (Mode->UsingIpv6 && StationIp !=3D NULL) { + // + // Overwrite Udp6CfgData/Ip6CfgData StationAddress. + // + CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_= IPv6_ADDRESS)); + CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_I= Pv6_ADDRESS)); + =20 // // Reconfigure the Ip6 instance to capture background ICMP6 packets wi= th new station Ip address. // Private->Ip6->Cancel (Private->Ip6, &Private->Icmp6Token); Private->Ip6->Configure (Private->Ip6, NULL); @@ -59,31 +61,59 @@ PxeBcFlushStationIp ( } =20 Status =3D Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token); } else { if (StationIp !=3D NULL) { + // + // Reconfigure the ARP instance with station Ip address. + // + ArpConfigData.SwAddressType =3D 0x0800; + ArpConfigData.SwAddressLength =3D (UINT8) sizeof (EFI_IPv4_ADDRESS); + ArpConfigData.StationAddress =3D StationIp; + + Private->Arp->Configure (Private->Arp, NULL); + Private->Arp->Configure (Private->Arp, &ArpConfigData); + + // + // Overwrite Udp4CfgData/Ip4CfgData StationAddress. + // CopyMem (&Private->Udp4CfgData.StationAddress, StationIp, sizeof (EF= I_IPv4_ADDRESS)); CopyMem (&Private->Ip4CfgData.StationAddress, StationIp, sizeof (EFI= _IPv4_ADDRESS)); } =20 if (SubnetMask !=3D NULL) { + // + // Overwrite Udp4CfgData/Ip4CfgData SubnetMask. + // CopyMem (&Private->Udp4CfgData.SubnetMask, SubnetMask, sizeof (EFI_I= Pv4_ADDRESS)); CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IP= v4_ADDRESS)); } =20 - // - // Reconfigure the Ip4 instance to capture background ICMP packets wit= h new station Ip address. - // - Private->Ip4->Cancel (Private->Ip4, &Private->IcmpToken); - Private->Ip4->Configure (Private->Ip4, NULL); - - Status =3D Private->Ip4->Configure (Private->Ip4, &Private->Ip4CfgData= ); - if (EFI_ERROR (Status)) { - goto ON_EXIT; + if (StationIp !=3D NULL && SubnetMask !=3D NULL) { + // + // Updated the route table. + // + Mode->RouteTableEntries =3D 1; + Mode->RouteTable[0].IpAddr.Addr[0] =3D StationIp->Addr[0] & Subn= etMask->Addr[0]; + Mode->RouteTable[0].SubnetMask.Addr[0] =3D SubnetMask->Addr[0]; + Mode->RouteTable[0].GwAddr.Addr[0] =3D 0; } + =20 + if (StationIp !=3D NULL || SubnetMask !=3D NULL) { + // + // Reconfigure the Ip4 instance to capture background ICMP packets w= ith new station Ip address. + // + Private->Ip4->Cancel (Private->Ip4, &Private->IcmpToken); + Private->Ip4->Configure (Private->Ip4, NULL); =20 - Status =3D Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken); + Status =3D Private->Ip4->Configure (Private->Ip4, &Private->Ip4CfgDa= ta); + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } + + Status =3D Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken); + } } =20 ON_EXIT: return Status; } --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel