public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] NetworkPkg: Recycle the ICMP error message in PXE driver.
@ 2017-12-21  7:46 Fu Siyuan
  2017-12-21  7:46 ` [Patch] NetworkPkg: Remove redundant check " Fu Siyuan
  2017-12-22  7:33 ` [Patch] NetworkPkg: Recycle the ICMP error message " Wu, Jiaxin
  0 siblings, 2 replies; 4+ messages in thread
From: Fu Siyuan @ 2017-12-21  7:46 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Wu Jiaxin, Wang Fan

This patch updates PxeBcIcmpErrorDpcHandle() and PxeBcIcmp6ErrorDpcHandle() to
recycle the ICMP packet after copy it to PXE mode data.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 36 +++++++++++++++-------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index dfc79a067b..1e77929364 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -257,8 +257,7 @@ PxeBcIcmpErrorDpcHandle (
     //
     // The return status should be recognized as EFI_ICMP_ERROR.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&
@@ -268,24 +267,21 @@ PxeBcIcmpErrorDpcHandle (
     //
     // The source address of the received packet should be a valid unicast address.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   if (!EFI_IP4_EQUAL (&RxData->Header->DestinationAddress, &Mode->StationIp.v4)) {
     //
     // The destination address of the received packet should be equal to the host address.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   if (RxData->Header->Protocol != EFI_IP_PROTO_ICMP) {
     //
     // The protocol value in the header of the receveid packet should be EFI_IP_PROTO_ICMP.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
@@ -298,8 +294,7 @@ PxeBcIcmpErrorDpcHandle (
     //
     // The type of the receveid ICMP message should be ICMP_ERROR_MESSAGE.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   //
@@ -326,6 +321,9 @@ PxeBcIcmpErrorDpcHandle (
     IcmpError += CopiedLen;
   }
 
+ON_RECYCLE:
+  gBS->SignalEvent (RxData->RecycleSignal);
+
 ON_EXIT:
   Private->IcmpToken.Status = EFI_NOT_READY;
   Ip4->Receive (Ip4, &Private->IcmpToken);
@@ -395,16 +393,14 @@ PxeBcIcmp6ErrorDpcHandle (
     //
     // The return status should be recognized as EFI_ICMP_ERROR.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   if (!NetIp6IsValidUnicast (&RxData->Header->SourceAddress)) {
     //
     // The source address of the received packet should be a valid unicast address.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   if (!NetIp6IsUnspecifiedAddr (&Mode->StationIp.v6) &&
@@ -412,16 +408,14 @@ PxeBcIcmp6ErrorDpcHandle (
     //
     // The destination address of the received packet should be equal to the host address.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   if (RxData->Header->NextHeader != IP6_ICMP) {
     //
     // The nextheader in the header of the receveid packet should be IP6_ICMP.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
@@ -433,8 +427,7 @@ PxeBcIcmp6ErrorDpcHandle (
     //
     // The type of the receveid packet should be an ICMP6 error message.
     //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
+    goto ON_RECYCLE;
   }
 
   //
@@ -461,6 +454,9 @@ PxeBcIcmp6ErrorDpcHandle (
     Icmp6Error += CopiedLen;
   }
 
+ON_RECYCLE:
+  gBS->SignalEvent (RxData->RecycleSignal);
+  
 ON_EXIT:
   Private->Icmp6Token.Status = EFI_NOT_READY;
   Ip6->Receive (Ip6, &Private->Icmp6Token);
-- 
2.13.0.windows.1



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

* [Patch] NetworkPkg: Remove redundant check in PXE driver.
  2017-12-21  7:46 [Patch] NetworkPkg: Recycle the ICMP error message in PXE driver Fu Siyuan
@ 2017-12-21  7:46 ` Fu Siyuan
  2017-12-22  7:26   ` Wu, Jiaxin
  2017-12-22  7:33 ` [Patch] NetworkPkg: Recycle the ICMP error message " Wu, Jiaxin
  1 sibling, 1 reply; 4+ messages in thread
From: Fu Siyuan @ 2017-12-21  7:46 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Wu Jiaxin, Wang Fan

The IP protocol has been configured to only receive ICMP packet in PXE driver.
So this patch removes the unnecessary check for NextHeader field and replace it
with ASSERT.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index dfc79a067b..720287583e 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -279,14 +279,11 @@ PxeBcIcmpErrorDpcHandle (
     gBS->SignalEvent (RxData->RecycleSignal);
     goto ON_EXIT;
   }
-
-  if (RxData->Header->Protocol != EFI_IP_PROTO_ICMP) {
-    //
-    // The protocol value in the header of the receveid packet should be EFI_IP_PROTO_ICMP.
-    //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
-  }
+  
+  //
+  // The protocol has been configured to only receive ICMP packet.
+  //
+  ASSERT (RxData->Header->Protocol == EFI_IP_PROTO_ICMP);
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
 
@@ -416,13 +413,10 @@ PxeBcIcmp6ErrorDpcHandle (
     goto ON_EXIT;
   }
 
-  if (RxData->Header->NextHeader != IP6_ICMP) {
-    //
-    // The nextheader in the header of the receveid packet should be IP6_ICMP.
-    //
-    gBS->SignalEvent (RxData->RecycleSignal);
-    goto ON_EXIT;
-  }
+  //
+  // The protocol has been configured to only receive ICMP packet.
+  //
+  ASSERT (RxData->Header->NextHeader == IP6_ICMP);
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
 
-- 
2.13.0.windows.1



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

* Re: [Patch] NetworkPkg: Remove redundant check in PXE driver.
  2017-12-21  7:46 ` [Patch] NetworkPkg: Remove redundant check " Fu Siyuan
@ 2017-12-22  7:26   ` Wu, Jiaxin
  0 siblings, 0 replies; 4+ messages in thread
From: Wu, Jiaxin @ 2017-12-22  7:26 UTC (permalink / raw)
  To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wang, Fan


Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fu,
> Siyuan
> Sent: Thursday, December 21, 2017 3:46 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Wang, Fan <fan.wang@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch] NetworkPkg: Remove redundant check in PXE driver.
> 
> The IP protocol has been configured to only receive ICMP packet in PXE
> driver.
> So this patch removes the unnecessary check for NextHeader field and
> replace it
> with ASSERT.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Cc: Wang Fan <fan.wang@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
> ---
>  NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> index dfc79a067b..720287583e 100644
> --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> @@ -279,14 +279,11 @@ PxeBcIcmpErrorDpcHandle (
>      gBS->SignalEvent (RxData->RecycleSignal);
>      goto ON_EXIT;
>    }
> -
> -  if (RxData->Header->Protocol != EFI_IP_PROTO_ICMP) {
> -    //
> -    // The protocol value in the header of the receveid packet should be
> EFI_IP_PROTO_ICMP.
> -    //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> -  }
> +
> +  //
> +  // The protocol has been configured to only receive ICMP packet.
> +  //
> +  ASSERT (RxData->Header->Protocol == EFI_IP_PROTO_ICMP);
> 
>    Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
> 
> @@ -416,13 +413,10 @@ PxeBcIcmp6ErrorDpcHandle (
>      goto ON_EXIT;
>    }
> 
> -  if (RxData->Header->NextHeader != IP6_ICMP) {
> -    //
> -    // The nextheader in the header of the receveid packet should be
> IP6_ICMP.
> -    //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> -  }
> +  //
> +  // The protocol has been configured to only receive ICMP packet.
> +  //
> +  ASSERT (RxData->Header->NextHeader == IP6_ICMP);
> 
>    Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
> 
> --
> 2.13.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [Patch] NetworkPkg: Recycle the ICMP error message in PXE driver.
  2017-12-21  7:46 [Patch] NetworkPkg: Recycle the ICMP error message in PXE driver Fu Siyuan
  2017-12-21  7:46 ` [Patch] NetworkPkg: Remove redundant check " Fu Siyuan
@ 2017-12-22  7:33 ` Wu, Jiaxin
  1 sibling, 0 replies; 4+ messages in thread
From: Wu, Jiaxin @ 2017-12-22  7:33 UTC (permalink / raw)
  To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wang, Fan

Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fu,
> Siyuan
> Sent: Thursday, December 21, 2017 3:46 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Wang, Fan <fan.wang@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch] NetworkPkg: Recycle the ICMP error message in PXE
> driver.
> 
> This patch updates PxeBcIcmpErrorDpcHandle() and
> PxeBcIcmp6ErrorDpcHandle() to
> recycle the ICMP packet after copy it to PXE mode data.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Cc: Wang Fan <fan.wang@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
> ---
>  NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 36 +++++++++++++++---------
> ----------
>  1 file changed, 16 insertions(+), 20 deletions(-)
> 
> diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> index dfc79a067b..1e77929364 100644
> --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
> @@ -257,8 +257,7 @@ PxeBcIcmpErrorDpcHandle (
>      //
>      // The return status should be recognized as EFI_ICMP_ERROR.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&
> @@ -268,24 +267,21 @@ PxeBcIcmpErrorDpcHandle (
>      //
>      // The source address of the received packet should be a valid unicast
> address.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    if (!EFI_IP4_EQUAL (&RxData->Header->DestinationAddress, &Mode-
> >StationIp.v4)) {
>      //
>      // The destination address of the received packet should be equal to the
> host address.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    if (RxData->Header->Protocol != EFI_IP_PROTO_ICMP) {
>      //
>      // The protocol value in the header of the receveid packet should be
> EFI_IP_PROTO_ICMP.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
> @@ -298,8 +294,7 @@ PxeBcIcmpErrorDpcHandle (
>      //
>      // The type of the receveid ICMP message should be
> ICMP_ERROR_MESSAGE.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    //
> @@ -326,6 +321,9 @@ PxeBcIcmpErrorDpcHandle (
>      IcmpError += CopiedLen;
>    }
> 
> +ON_RECYCLE:
> +  gBS->SignalEvent (RxData->RecycleSignal);
> +
>  ON_EXIT:
>    Private->IcmpToken.Status = EFI_NOT_READY;
>    Ip4->Receive (Ip4, &Private->IcmpToken);
> @@ -395,16 +393,14 @@ PxeBcIcmp6ErrorDpcHandle (
>      //
>      // The return status should be recognized as EFI_ICMP_ERROR.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    if (!NetIp6IsValidUnicast (&RxData->Header->SourceAddress)) {
>      //
>      // The source address of the received packet should be a valid unicast
> address.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    if (!NetIp6IsUnspecifiedAddr (&Mode->StationIp.v6) &&
> @@ -412,16 +408,14 @@ PxeBcIcmp6ErrorDpcHandle (
>      //
>      // The destination address of the received packet should be equal to the
> host address.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    if (RxData->Header->NextHeader != IP6_ICMP) {
>      //
>      // The nextheader in the header of the receveid packet should be
> IP6_ICMP.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
> @@ -433,8 +427,7 @@ PxeBcIcmp6ErrorDpcHandle (
>      //
>      // The type of the receveid packet should be an ICMP6 error message.
>      //
> -    gBS->SignalEvent (RxData->RecycleSignal);
> -    goto ON_EXIT;
> +    goto ON_RECYCLE;
>    }
> 
>    //
> @@ -461,6 +454,9 @@ PxeBcIcmp6ErrorDpcHandle (
>      Icmp6Error += CopiedLen;
>    }
> 
> +ON_RECYCLE:
> +  gBS->SignalEvent (RxData->RecycleSignal);
> +
>  ON_EXIT:
>    Private->Icmp6Token.Status = EFI_NOT_READY;
>    Ip6->Receive (Ip6, &Private->Icmp6Token);
> --
> 2.13.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2017-12-22  7:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-21  7:46 [Patch] NetworkPkg: Recycle the ICMP error message in PXE driver Fu Siyuan
2017-12-21  7:46 ` [Patch] NetworkPkg: Remove redundant check " Fu Siyuan
2017-12-22  7:26   ` Wu, Jiaxin
2017-12-22  7:33 ` [Patch] NetworkPkg: Recycle the ICMP error message " Wu, Jiaxin

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