From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on072c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe42::72c]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C5E5C1A1E60 for ; Wed, 14 Sep 2016 08:04:55 -0700 (PDT) Received: from DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM (10.162.192.143) by DF4PR84MB0043.NAMPRD84.PROD.OUTLOOK.COM (10.162.192.145) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10; Wed, 14 Sep 2016 15:04:53 +0000 Received: from DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM ([10.162.192.143]) by DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM ([10.162.192.143]) with mapi id 15.01.0619.011; Wed, 14 Sep 2016 15:04:53 +0000 From: "Subramanian, Sriram (EG Servers Platform SW)" To: Jiaxin Wu , "edk2-devel@lists.01.org" CC: Ye Ting , Fu Siyuan Thread-Topic: [edk2] [Patch] NetworkPkg: Correct the DNS token return status by RCODE Thread-Index: AQHSDlO4S5YhEAi6OkW3f0TX7OzTn6B5DgQA Date: Wed, 14 Sep 2016 15:04:53 +0000 Message-ID: References: <1473835550-58760-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1473835550-58760-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sriram-s@hpe.com; x-originating-ip: [106.51.19.237] x-ms-office365-filtering-correlation-id: b1c81f0d-d017-4ee4-2795-08d3dcb07bbe x-microsoft-exchange-diagnostics: 1; DF4PR84MB0043; 6:3ypCK2EUSFDa76uPl+MQagU7Xb4mgaicL9mGhbpnSDyCGZZPuz9GSB4kl4l9h/d6FaurZSZVDrQCNYEfKF0XVEeYmxs6ysHQh3mucXQctPBP5gE9Jp3z3pN4clNyNUNJcxrLfo9DSq5zceEhTdsRqVQpOCyWYs6k+OtYqIf8Bnf3X3R/hj0P9cYDzcJlyx7NuzKLqSfdvvLgb1gCNqO4XCGV98xUcsM3n11wqnAgI3dbNGNHoDa9vkm6YKAlwUE5kSt6lDSwqCwgb+I6zxx003FQ++8ZsroKUc1Lr1w4nWvWHzEq4xO/4Q1H7/fwAVTmc1dOqcsgY5HgcQJdtVVeQQ==; 5:wSQvh5IhN3seuDKDXqZ4F6eq3nISPDbHaqMXKsJ5B+dbbmwcjMxNeLV0eM3Ep5rwaZp04vXl6AyLIIc/JHBh3hs924upUYXEggCtF3cL3agOc2svLu5m+6L3C7MbD7K47/19z8pPVzWQH0NBb7LyIg==; 24:xRNACzqdJ4tM1EHhG8eWf/24Xn4AosznnOIVyAAcwVUp+cxagCpUef9GjbhQ4QkgsvqIoIw5HGkIHil7YZ1DhNLisucH5nI34wkmbmGU2Y4=; 7:CZ71hqOXoYmKrtjC+jpRFJY88we5lbIcIhFlJqV49FXl6P9Be91jSlKRHg2EF0iQRAb+8NLBarGNq9kDr67aICCkwyDKbQvWQ+nAVV9bj7M/Wu4UIewjE0D3JxA78UTIFNBT1kikFLVsZ3cbSuF6F0VgvuXuTNLUfn+6kutROXMN2tDbnrXxVJ7+p6RZty9j4mJJI8Aq1xWqRP1C4bQG9peNJKqNg4eCC4VeYfoT7N3Q5skoIyBFk9CP/J39RsEA x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DF4PR84MB0043; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(150554046322364)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:DF4PR84MB0043; BCL:0; PCL:0; RULEID:; SRVR:DF4PR84MB0043; x-forefront-prvs: 006546F32A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(377454003)(199003)(13464003)(189002)(7846002)(102836003)(99286002)(106356001)(586003)(86362001)(68736007)(50986999)(81156014)(7736002)(19580405001)(74316002)(19580395003)(6116002)(4326007)(3846002)(54356999)(97736004)(11100500001)(2950100001)(5002640100001)(2501003)(8676002)(15975445007)(305945005)(2900100001)(2906002)(81166006)(5001770100001)(77096005)(101416001)(105586002)(76176999)(106116001)(189998001)(10400500002)(3660700001)(3280700002)(92566002)(9456002)(7696004)(122556002)(8936002)(5660300001)(66066001)(33656002)(9686002)(87936001); DIR:OUT; SFP:1102; SCL:1; SRVR:DF4PR84MB0043; H:DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Sep 2016 15:04:53.5294 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0043 Subject: Re: [Patch] NetworkPkg: Correct the DNS token return status by RCODE X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2016 15:04:56 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jiaxin, - Status =3D EFI_ABORTED; - goto ON_EXIT; + // + // The domain name referenced in the query does not exist. + // + if (DnsHeader->Flags.Bits.RCode =3D=3D DNS_FLAGS_RCODE_NAME_ERROR) { + Status =3D EFI_NOT_FOUND;=20 + } else { + Status =3D EFI_DEVICE_ERROR; + } + =20 + goto ON_COMPLETE; This change looks good to me. Thanks for addressing this. Nagaraj is on vac= ation and will test it early next week and provide feedback. Reviewed-by: Sriram Subramanian Thanks, Sriram. -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jiax= in Wu Sent: Wednesday, September 14, 2016 12:16 PM To: edk2-devel@lists.01.org Cc: Ye Ting ; Fu Siyuan Subject: [edk2] [Patch] NetworkPkg: Correct the DNS token return status by = RCODE When HostNameToIp() and GeneralLookUp() are called with a invalid host name, RCODE (4 bit field is set as part of responses) error will returned in packet to identify the domain name referenced in the query does not exist. So, EFI_NOT_FOUND should be returned directly. Current implementation only check the RCODE in successful condition. Need update the code for more error check according to RFC 1035 4.1.1 section. Cc: Hegde Nagaraj P Cc: Fu Siyuan Cc: Ye Ting Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- NetworkPkg/DnsDxe/DnsImpl.c | 104 +++++++++++++++++-----------------------= ---- 1 file changed, 40 insertions(+), 64 deletions(-) diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c index cfaa4c7..3f3b756 100644 --- a/NetworkPkg/DnsDxe/DnsImpl.c +++ b/NetworkPkg/DnsDxe/DnsImpl.c @@ -1230,12 +1230,20 @@ ParseDnsResponse ( // // Continue Check Some Errors. // if (DnsHeader->Flags.Bits.RCode !=3D DNS_FLAGS_RCODE_NO_ERROR || DnsHead= er->AnswersNum < 1 || \ DnsHeader->Flags.Bits.QR !=3D DNS_FLAGS_QR_RESPONSE) { - Status =3D EFI_ABORTED; - goto ON_EXIT; + // + // The domain name referenced in the query does not exist. + // + if (DnsHeader->Flags.Bits.RCode =3D=3D DNS_FLAGS_RCODE_NAME_ERROR) { + Status =3D EFI_NOT_FOUND;=20 + } else { + Status =3D EFI_DEVICE_ERROR; + } + =20 + goto ON_COMPLETE; } =20 // // Do some buffer allocations. // @@ -1404,27 +1412,12 @@ ParseDnsResponse ( =20 HostAddr4 =3D Dns4TokenEntry->Token->RspData.H2AData->IpList; AnswerData =3D (UINT8 *) AnswerSection + sizeof (*AnswerSection); CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS= )); =20 - // - // Update DNS cache dynamically. - // - if (Dns4CacheEntry !=3D NULL) { - if (Dns4CacheEntry->HostName !=3D NULL) { - FreePool (Dns4CacheEntry->HostName); - } - - if (Dns4CacheEntry->IpAddress !=3D NULL) { - FreePool (Dns4CacheEntry->IpAddress); - } - =20 - FreePool (Dns4CacheEntry); - } - //=20 - // Allocate new CacheEntry pool. + // Allocate new CacheEntry pool to update DNS cache dynamically. // Dns4CacheEntry =3D AllocateZeroPool (sizeof (EFI_DNS4_CACHE_ENTRY)= ); if (Dns4CacheEntry =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto ON_EXIT; @@ -1446,11 +1439,23 @@ ParseDnsResponse ( Dns4CacheEntry->Timeout =3D MIN (CNameTtl, AnswerSection->Ttl); } else { Dns4CacheEntry->Timeout =3D MAX (CNameTtl, AnswerSection->Ttl); } =20 - UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4Ca= cheEntry); =20 + UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4Ca= cheEntry); + + //=20 + // Free allocated CacheEntry pool. + // + FreePool (Dns4CacheEntry->HostName); + Dns4CacheEntry->HostName =3D NULL; + =20 + FreePool (Dns4CacheEntry->IpAddress); + Dns4CacheEntry->IpAddress =3D NULL; + + FreePool (Dns4CacheEntry); + Dns4CacheEntry =3D NULL; =20 IpCount ++; Status =3D EFI_SUCCESS; break; case DNS_TYPE_AAAA: @@ -1461,27 +1466,12 @@ ParseDnsResponse ( =20 HostAddr6 =3D Dns6TokenEntry->Token->RspData.H2AData->IpList; AnswerData =3D (UINT8 *) AnswerSection + sizeof (*AnswerSection); CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS= )); =20 - // - // Update DNS cache dynamically. - // - if (Dns6CacheEntry !=3D NULL) { - if (Dns6CacheEntry->HostName !=3D NULL) { - FreePool (Dns6CacheEntry->HostName); - } - - if (Dns6CacheEntry->IpAddress !=3D NULL) { - FreePool (Dns6CacheEntry->IpAddress); - } - =20 - FreePool (Dns6CacheEntry); - } - //=20 - // Allocate new CacheEntry pool. + // Allocate new CacheEntry pool to update DNS cache dynamically. // Dns6CacheEntry =3D AllocateZeroPool (sizeof (EFI_DNS6_CACHE_ENTRY)= ); if (Dns6CacheEntry =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto ON_EXIT; @@ -1503,11 +1493,23 @@ ParseDnsResponse ( Dns6CacheEntry->Timeout =3D MIN (CNameTtl, AnswerSection->Ttl); } else { Dns6CacheEntry->Timeout =3D MAX (CNameTtl, AnswerSection->Ttl); } =20 - UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6Ca= cheEntry); =20 + UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6Ca= cheEntry); + + //=20 + // Free allocated CacheEntry pool. + // + FreePool (Dns6CacheEntry->HostName); + Dns6CacheEntry->HostName =3D NULL; + =20 + FreePool (Dns6CacheEntry->IpAddress); + Dns6CacheEntry->IpAddress =3D NULL; + + FreePool (Dns6CacheEntry); + Dns6CacheEntry =3D NULL; =20 IpCount ++; Status =3D EFI_SUCCESS; break; case DNS_TYPE_CNAME: @@ -1556,11 +1558,12 @@ ParseDnsResponse ( Status =3D EFI_UNSUPPORTED; goto ON_EXIT; } } } - + =20 +ON_COMPLETE: // // Parsing is complete, free the sending packet and signal Event here. // if (Item !=3D NULL && Item->Value !=3D NULL) { NetbufFree ((NET_BUF *) (Item->Value)); @@ -1582,37 +1585,10 @@ ParseDnsResponse ( gBS->SignalEvent (Dns6TokenEntry->Token->Event); DispatchDpc (); } } =20 - //=20 - // Free allocated CacheEntry pool. - // - if (Dns4CacheEntry !=3D NULL) { - if (Dns4CacheEntry->HostName !=3D NULL) { - FreePool (Dns4CacheEntry->HostName); - } - - if (Dns4CacheEntry->IpAddress !=3D NULL) { - FreePool (Dns4CacheEntry->IpAddress); - } - - FreePool (Dns4CacheEntry); - } - =20 - if (Dns6CacheEntry !=3D NULL) { - if (Dns6CacheEntry->HostName !=3D NULL) { - FreePool (Dns6CacheEntry->HostName); - } - - if (Dns6CacheEntry->IpAddress !=3D NULL) { - FreePool (Dns6CacheEntry->IpAddress); - } - =20 - FreePool (Dns6CacheEntry); - } - ON_EXIT: gBS->RestoreTPL (OldTpl); return Status; } =20 --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel