From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org 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 C8007225E9652 for ; Tue, 20 Mar 2018 18:12:03 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 18:18:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,338,1517904000"; d="scan'208";a="27470243" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga006.jf.intel.com with ESMTP; 20 Mar 2018 18:18:33 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 20 Mar 2018 18:18:32 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 20 Mar 2018 18:18:32 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0319.002; Wed, 21 Mar 2018 09:18:21 +0800 From: "Fu, Siyuan" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" Thread-Topic: [Patch] NetworkPkg/UefiPxeBcDxe: Configure the ARP Instance/RouteTable with new address Thread-Index: AQHTv+ggm3F6H1uVFkyYCJ4GygbQzaPZ5SUA Date: Wed, 21 Mar 2018 01:18:20 +0000 Message-ID: References: <20180320010937.11272-1-jiaxin.wu@intel.com> In-Reply-To: <20180320010937.11272-1-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjNjMmU5MzAtYjJhZi00YTU4LTlkYjItNGE3OGY3YjdhZjAwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJLNEFRd1wvcGpmd1BBaDBJT0h0ZklFZWFtQlRMcW82QnBUVFl6cFEyeWw3XC9TT0ZoS2Q3Vlo4R3dpNGtSXC9LMDdXIn0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Wed, 21 Mar 2018 01:12:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan > -----Original Message----- > From: Wu, Jiaxin > Sent: Tuesday, March 20, 2018 9:10 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan ; Ye, Ting > Subject: [Patch] NetworkPkg/UefiPxeBcDxe: Configure the ARP > Instance/RouteTable with new address >=20 > After completed a DHCP D.O.R.A process and got the new address, the ARP > Instance > and RouteTable should be configured so as to avoid the later Pxe.Arp > failure. >=20 > Cc: Fu Siyuan > Cc: Ye Ting > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiaxin Wu > --- > NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 26 +++----------- > NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 66 ++++++++++++++++++++++++----= - > ----- > 2 files changed, 52 insertions(+), 40 deletions(-) >=20 > 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] & > NewSubnetMask->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; > + } > + > ON_EXIT: > return Status; > } >=20 >=20 > diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c > b/NetworkPkg/UefiPxeBcDxe/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 > BSD License > which accompanies this distribution. The full text of the license may > be 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 > (EFI_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_IPv6_ADDRESS)); > + > // > // Reconfigure the Ip6 instance to capture background ICMP6 packets > with 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 > (EFI_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_IPv4_ADDRESS)); > CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof > (EFI_IPv4_ADDRESS)); > } >=20 > - // > - // Reconfigure the Ip4 instance to capture background ICMP packets > with 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->Ip4CfgDa= ta); > - 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] & > SubnetMask->Addr[0]; > + Mode->RouteTable[0].SubnetMask.Addr[0] =3D SubnetMask->Addr[0]; > + Mode->RouteTable[0].GwAddr.Addr[0] =3D 0; > } > + > + if (StationIp !=3D NULL || SubnetMask !=3D NULL) { > + // > + // Reconfigure the Ip4 instance to capture background ICMP packets > with 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- > >Ip4CfgData); > + if (EFI_ERROR (Status)) { > + goto ON_EXIT; > + } > + > + Status =3D Private->Ip4->Receive (Private->Ip4, &Private->IcmpToke= n); > + } > } >=20 > ON_EXIT: > return Status; > } > -- > 2.16.2.windows.1