[edk2] [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6

Jiaxin Wu posted 1 patch 7 years, 7 months ago
Failed in applying to current master (apply log)
NetworkPkg/DnsDxe/DnsDriver.c   | 24 +++++++++++-------------
NetworkPkg/DnsDxe/DnsImpl.c     |  8 +++++---
NetworkPkg/DnsDxe/DnsProtocol.c |  2 ++
3 files changed, 18 insertions(+), 16 deletions(-)
[edk2] [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6
Posted by Jiaxin Wu 7 years, 7 months ago
According UEFI Spec, set to zero StationIp means to let the underlying
IPv6 driver choose a source address. But currently, DNSv6 always return
EFI_NO_MAPPING. The issue is caused by below bugs in DnsDxe:
* Incorrect TPL(TPL_CALLBACK) usage during UDP configuration.
* Failed to create the timer used to get IPv6 mapping
* Doesn't check the Ip6Mode.IsStarted flag.

Cc: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/DnsDxe/DnsDriver.c   | 24 +++++++++++-------------
 NetworkPkg/DnsDxe/DnsImpl.c     |  8 +++++---
 NetworkPkg/DnsDxe/DnsProtocol.c |  2 ++
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsDriver.c b/NetworkPkg/DnsDxe/DnsDriver.c
index c000b5f..5dc9afe 100644
--- a/NetworkPkg/DnsDxe/DnsDriver.c
+++ b/NetworkPkg/DnsDxe/DnsDriver.c
@@ -1,9 +1,9 @@
 /** @file
 The driver binding and service binding protocol for DnsDxe driver.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 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
 http://opensource.org/licenses/bsd-license.php
 
@@ -277,22 +277,20 @@ DnsCreateService (
 
   //
   // Create the timer used to time out the procedure which is used to
   // get the default IP address.
   //
-  if (DnsSb->IpVersion == IP_VERSION_4) {
-    Status = gBS->CreateEvent (
-                    EVT_TIMER,
-                    TPL_CALLBACK,
-                    NULL,
-                    NULL,
-                    &DnsSb->TimerToGetMap
-                    );
-    if (EFI_ERROR (Status)) {
-      FreePool (DnsSb);
-      return Status;
-    }
+  Status = gBS->CreateEvent (
+                  EVT_TIMER,
+                  TPL_CALLBACK,
+                  NULL,
+                  NULL,
+                  &DnsSb->TimerToGetMap
+                  );
+  if (EFI_ERROR (Status)) {
+    FreePool (DnsSb);
+    return Status;
   }
   
   //
   // Create the timer to retransmit packets.
   //
diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c
index 794df1d..ea3d27d 100644
--- a/NetworkPkg/DnsDxe/DnsImpl.c
+++ b/NetworkPkg/DnsDxe/DnsImpl.c
@@ -1,9 +1,9 @@
 /** @file
 DnsDxe support functions implementation.
   
-Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 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
 http://opensource.org/licenses/bsd-license.php
 
@@ -641,13 +641,15 @@ Dns6GetMapping (
 
       if (Ip6Mode.IcmpTypeList != NULL) {
         FreePool (Ip6Mode.IcmpTypeList);
       }
 
-      if (Ip6Mode.IsConfigured) {
+      if (!Ip6Mode.IsStarted || Ip6Mode.IsConfigured) {
         Udp->Configure (Udp, NULL);
-        return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
+        if (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS) {
+          return TRUE;
+        }
       }
     }
   }
 
   return FALSE;
diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c
index 0e7ed34..bd189ae 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -1104,11 +1104,13 @@ Dns6Configure (
     }
 
     //
     // Config UDP
     //
+    gBS->RestoreTPL (OldTpl);
     Status = Dns6ConfigUdp (Instance, Instance->UdpIo);
+    OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
     if (EFI_ERROR (Status)) {
       if (Instance->Dns6CfgData.DnsServerList != NULL) {
         FreePool (Instance->Dns6CfgData.DnsServerList);
         Instance->Dns6CfgData.DnsServerList = NULL;
       }
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6
Posted by Zhang, Lubo 7 years, 7 months ago
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>

-----Original Message-----
From: Wu, Jiaxin 
Sent: Friday, March 24, 2017 2:00 PM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo <lubo.zhang@intel.com>; Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6

According UEFI Spec, set to zero StationIp means to let the underlying
IPv6 driver choose a source address. But currently, DNSv6 always return EFI_NO_MAPPING. The issue is caused by below bugs in DnsDxe:
* Incorrect TPL(TPL_CALLBACK) usage during UDP configuration.
* Failed to create the timer used to get IPv6 mapping
* Doesn't check the Ip6Mode.IsStarted flag.

Cc: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/DnsDxe/DnsDriver.c   | 24 +++++++++++-------------
 NetworkPkg/DnsDxe/DnsImpl.c     |  8 +++++---
 NetworkPkg/DnsDxe/DnsProtocol.c |  2 ++
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsDriver.c b/NetworkPkg/DnsDxe/DnsDriver.c index c000b5f..5dc9afe 100644
--- a/NetworkPkg/DnsDxe/DnsDriver.c
+++ b/NetworkPkg/DnsDxe/DnsDriver.c
@@ -1,9 +1,9 @@
 /** @file
 The driver binding and service binding protocol for DnsDxe driver.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 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  http://opensource.org/licenses/bsd-license.php
 
@@ -277,22 +277,20 @@ DnsCreateService (
 
   //
   // Create the timer used to time out the procedure which is used to
   // get the default IP address.
   //
-  if (DnsSb->IpVersion == IP_VERSION_4) {
-    Status = gBS->CreateEvent (
-                    EVT_TIMER,
-                    TPL_CALLBACK,
-                    NULL,
-                    NULL,
-                    &DnsSb->TimerToGetMap
-                    );
-    if (EFI_ERROR (Status)) {
-      FreePool (DnsSb);
-      return Status;
-    }
+  Status = gBS->CreateEvent (
+                  EVT_TIMER,
+                  TPL_CALLBACK,
+                  NULL,
+                  NULL,
+                  &DnsSb->TimerToGetMap
+                  );
+  if (EFI_ERROR (Status)) {
+    FreePool (DnsSb);
+    return Status;
   }
   
   //
   // Create the timer to retransmit packets.
   //
diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c index 794df1d..ea3d27d 100644
--- a/NetworkPkg/DnsDxe/DnsImpl.c
+++ b/NetworkPkg/DnsDxe/DnsImpl.c
@@ -1,9 +1,9 @@
 /** @file
 DnsDxe support functions implementation.
   
-Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 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  http://opensource.org/licenses/bsd-license.php
 
@@ -641,13 +641,15 @@ Dns6GetMapping (
 
       if (Ip6Mode.IcmpTypeList != NULL) {
         FreePool (Ip6Mode.IcmpTypeList);
       }
 
-      if (Ip6Mode.IsConfigured) {
+      if (!Ip6Mode.IsStarted || Ip6Mode.IsConfigured) {
         Udp->Configure (Udp, NULL);
-        return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
+        if (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS) {
+          return TRUE;
+        }
       }
     }
   }
 
   return FALSE;
diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c index 0e7ed34..bd189ae 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -1104,11 +1104,13 @@ Dns6Configure (
     }
 
     //
     // Config UDP
     //
+    gBS->RestoreTPL (OldTpl);
     Status = Dns6ConfigUdp (Instance, Instance->UdpIo);
+    OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
     if (EFI_ERROR (Status)) {
       if (Instance->Dns6CfgData.DnsServerList != NULL) {
         FreePool (Instance->Dns6CfgData.DnsServerList);
         Instance->Dns6CfgData.DnsServerList = NULL;
       }
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel