[edk2] [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.

Jiaxin Wu posted 2 patches 7 years ago
[edk2] [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.
Posted by Jiaxin Wu 7 years ago
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index 1db4c66..8780414 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -1,9 +1,9 @@
 /** @file
   This file implement the EFI_DHCP4_PROTOCOL interface.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
 
@@ -778,10 +778,11 @@ EfiDhcp4Start (
   IN EFI_EVENT              CompletionEvent   OPTIONAL
   )
 {
   DHCP_PROTOCOL             *Instance;
   DHCP_SERVICE              *DhcpSb;
+  BOOLEAN                   MediaPresent;
   EFI_STATUS                Status;
   EFI_TPL                   OldTpl;
 
   //
   // First validate the parameters
@@ -807,10 +808,20 @@ EfiDhcp4Start (
   if ((DhcpSb->DhcpState != Dhcp4Init) && (DhcpSb->DhcpState != Dhcp4InitReboot)) {
     Status = EFI_ALREADY_STARTED;
     goto ON_ERROR;
   }
 
+  //
+  // Check Media Satus.
+  //
+  MediaPresent = TRUE;
+  NetLibDetectMedia (DhcpSb->Controller, &MediaPresent);
+  if (!MediaPresent) {
+    Status = EFI_NO_MEDIA;
+    goto ON_ERROR;
+  }
+
   DhcpSb->IoStatus = EFI_ALREADY_STARTED;
 
   if (EFI_ERROR (Status = DhcpInitRequest (DhcpSb))) {
     goto ON_ERROR;
   }
-- 
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 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.
Posted by Ye, Ting 7 years ago
Hi Jiaxin,

I think the patch need be revised since it does not check the returned status of NetLibDetectMedia.  If NetLibDetectMedia failed to detect the media status due to some error conditions, MediaPresent is still TRUE and DHCP will be trigged later even no media is available.

Thanks,
Ting


-----Original Message-----
From: Wu, Jiaxin 
Sent: Friday, December 1, 2017 4:39 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Karunakar P <karunakarp@amiindia.co.in>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index 1db4c66..8780414 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -1,9 +1,9 @@
 /** @file
   This file implement the EFI_DHCP4_PROTOCOL interface.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
 
@@ -778,10 +778,11 @@ EfiDhcp4Start (
   IN EFI_EVENT              CompletionEvent   OPTIONAL
   )
 {
   DHCP_PROTOCOL             *Instance;
   DHCP_SERVICE              *DhcpSb;
+  BOOLEAN                   MediaPresent;
   EFI_STATUS                Status;
   EFI_TPL                   OldTpl;
 
   //
   // First validate the parameters
@@ -807,10 +808,20 @@ EfiDhcp4Start (
   if ((DhcpSb->DhcpState != Dhcp4Init) && (DhcpSb->DhcpState != Dhcp4InitReboot)) {
     Status = EFI_ALREADY_STARTED;
     goto ON_ERROR;
   }
 
+  //
+  // Check Media Satus.
+  //
+  MediaPresent = TRUE;
+  NetLibDetectMedia (DhcpSb->Controller, &MediaPresent);  if 
+ (!MediaPresent) {
+    Status = EFI_NO_MEDIA;
+    goto ON_ERROR;
+  }
+
   DhcpSb->IoStatus = EFI_ALREADY_STARTED;
 
   if (EFI_ERROR (Status = DhcpInitRequest (DhcpSb))) {
     goto ON_ERROR;
   }
--
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 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.
Posted by Wu, Jiaxin 7 years ago
Hi Ting,

In such a case, DHCP process should also be trigged since DHCP doesn't have the knowledge of media status. We can't return directly since the media may be available. what do you think?

Thanks,
Jiaxin



> -----Original Message-----
> From: Ye, Ting
> Sent: Wednesday, December 13, 2017 11:33 AM
> To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org
> Cc: Fu, Siyuan <siyuan.fu@intel.com>; Karunakar P
> <karunakarp@amiindia.co.in>
> Subject: RE: [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status
> before starting DHCP process.
> 
> Hi Jiaxin,
> 
> I think the patch need be revised since it does not check the returned status
> of NetLibDetectMedia.  If NetLibDetectMedia failed to detect the media
> status due to some error conditions, MediaPresent is still TRUE and DHCP
> will be trigged later even no media is available.
> 
> Thanks,
> Ting
> 
> 
> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Friday, December 1, 2017 4:39 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>;
> Karunakar P <karunakarp@amiindia.co.in>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before
> starting DHCP process.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13
> ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> index 1db4c66..8780414 100644
> --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> @@ -1,9 +1,9 @@
>  /** @file
>    This file implement the EFI_DHCP4_PROTOCOL interface.
> 
> -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 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
> 
> @@ -778,10 +778,11 @@ EfiDhcp4Start (
>    IN EFI_EVENT              CompletionEvent   OPTIONAL
>    )
>  {
>    DHCP_PROTOCOL             *Instance;
>    DHCP_SERVICE              *DhcpSb;
> +  BOOLEAN                   MediaPresent;
>    EFI_STATUS                Status;
>    EFI_TPL                   OldTpl;
> 
>    //
>    // First validate the parameters
> @@ -807,10 +808,20 @@ EfiDhcp4Start (
>    if ((DhcpSb->DhcpState != Dhcp4Init) && (DhcpSb->DhcpState !=
> Dhcp4InitReboot)) {
>      Status = EFI_ALREADY_STARTED;
>      goto ON_ERROR;
>    }
> 
> +  //
> +  // Check Media Satus.
> +  //
> +  MediaPresent = TRUE;
> +  NetLibDetectMedia (DhcpSb->Controller, &MediaPresent);  if
> + (!MediaPresent) {
> +    Status = EFI_NO_MEDIA;
> +    goto ON_ERROR;
> +  }
> +
>    DhcpSb->IoStatus = EFI_ALREADY_STARTED;
> 
>    if (EFI_ERROR (Status = DhcpInitRequest (DhcpSb))) {
>      goto ON_ERROR;
>    }
> --
> 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 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.
Posted by Ye, Ting 7 years ago
Hi Jiaxin,

Thanks for the clarification. I agree with your solution to try DHCP process when upper layer don't know the media status. However, we might need add some comments there to indicate such case, that MediaPresent is TRUE does not mean media is available. 
Others are good to me. Reviewed-by: Ye Ting <ting.ye@intel.com> 

Thanks,
Ting

-----Original Message-----
From: Wu, Jiaxin 
Sent: Wednesday, December 13, 2017 1:16 PM
To: Ye, Ting <ting.ye@intel.com>; edk2-devel@lists.01.org
Cc: Fu, Siyuan <siyuan.fu@intel.com>; Karunakar P <karunakarp@amiindia.co.in>
Subject: RE: [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.

Hi Ting,

In such a case, DHCP process should also be trigged since DHCP doesn't have the knowledge of media status. We can't return directly since the media may be available. what do you think?

Thanks,
Jiaxin



> -----Original Message-----
> From: Ye, Ting
> Sent: Wednesday, December 13, 2017 11:33 AM
> To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org
> Cc: Fu, Siyuan <siyuan.fu@intel.com>; Karunakar P 
> <karunakarp@amiindia.co.in>
> Subject: RE: [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status 
> before starting DHCP process.
> 
> Hi Jiaxin,
> 
> I think the patch need be revised since it does not check the returned 
> status of NetLibDetectMedia.  If NetLibDetectMedia failed to detect 
> the media status due to some error conditions, MediaPresent is still 
> TRUE and DHCP will be trigged later even no media is available.
> 
> Thanks,
> Ting
> 
> 
> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Friday, December 1, 2017 4:39 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; 
> Karunakar P <karunakarp@amiindia.co.in>; Wu, Jiaxin 
> <jiaxin.wu@intel.com>
> Subject: [Patch 1/2] MdeModulePkg/Dhcp4Dxe: Check Media status before 
> starting DHCP process.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13
> ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> index 1db4c66..8780414 100644
> --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
> @@ -1,9 +1,9 @@
>  /** @file
>    This file implement the EFI_DHCP4_PROTOCOL interface.
> 
> -Copyright (c) 2006 - 2016, Intel Corporation. All rights 
> reserved.<BR>
> +Copyright (c) 2006 - 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
> 
> @@ -778,10 +778,11 @@ EfiDhcp4Start (
>    IN EFI_EVENT              CompletionEvent   OPTIONAL
>    )
>  {
>    DHCP_PROTOCOL             *Instance;
>    DHCP_SERVICE              *DhcpSb;
> +  BOOLEAN                   MediaPresent;
>    EFI_STATUS                Status;
>    EFI_TPL                   OldTpl;
> 
>    //
>    // First validate the parameters
> @@ -807,10 +808,20 @@ EfiDhcp4Start (
>    if ((DhcpSb->DhcpState != Dhcp4Init) && (DhcpSb->DhcpState !=
> Dhcp4InitReboot)) {
>      Status = EFI_ALREADY_STARTED;
>      goto ON_ERROR;
>    }
> 
> +  //
> +  // Check Media Satus.
> +  //
> +  MediaPresent = TRUE;
> +  NetLibDetectMedia (DhcpSb->Controller, &MediaPresent);  if
> + (!MediaPresent) {
> +    Status = EFI_NO_MEDIA;
> +    goto ON_ERROR;
> +  }
> +
>    DhcpSb->IoStatus = EFI_ALREADY_STARTED;
> 
>    if (EFI_ERROR (Status = DhcpInitRequest (DhcpSb))) {
>      goto ON_ERROR;
>    }
> --
> 1.9.5.msysgit.1

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