public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6
@ 2017-03-24  6:00 Jiaxin Wu
  2017-03-30  1:28 ` Zhang, Lubo
  0 siblings, 1 reply; 2+ messages in thread
From: Jiaxin Wu @ 2017-03-24  6:00 UTC (permalink / raw)
  To: edk2-devel; +Cc: Zhang Lubo, Ye Ting, Fu Siyuan, Wu Jiaxin

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6
  2017-03-24  6:00 [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6 Jiaxin Wu
@ 2017-03-30  1:28 ` Zhang, Lubo
  0 siblings, 0 replies; 2+ messages in thread
From: Zhang, Lubo @ 2017-03-30  1:28 UTC (permalink / raw)
  To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Fu, Siyuan

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-30  1:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-24  6:00 [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6 Jiaxin Wu
2017-03-30  1:28 ` Zhang, Lubo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox