[v6,1/3] ip_frag: ensure minimum v4 fragmentation length
diff mbox series

Message ID 20200420192523.2546909-2-aconole@redhat.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • ip_frag: add a unit test for fragmentation
Related show

Checks

Context Check Description
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Aaron Conole April 20, 2020, 7:25 p.m. UTC
Do a formal parameter check of mtu length, as well as
checking the the various inputs for validity.  If any
aren't acceptable, we bail.

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Lukasz Wojciechowski April 21, 2020, 11:04 a.m. UTC | #1
W dniu 20.04.2020 o 21:25, Aaron Conole pisze:
> Do a formal parameter check of mtu length, as well as
> checking the the various inputs for validity.  If any
> aren't acceptable, we bail.
>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>   lib/librte_ip_frag/rte_ipv4_fragmentation.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/lib/librte_ip_frag/rte_ipv4_fragmentation.c b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
> index 9e9f986cc5..e9de335ae2 100644
> --- a/lib/librte_ip_frag/rte_ipv4_fragmentation.c
> +++ b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
> @@ -8,6 +8,7 @@
>   #include <rte_memcpy.h>
>   #include <rte_mempool.h>
>   #include <rte_debug.h>
> +#include <rte_ether.h>
>   
>   #include "ip_frag_common.h"
>   
> @@ -76,6 +77,15 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
>   	uint16_t fragment_offset, flag_offset, frag_size;
>   	uint16_t frag_bytes_remaining;
>   
> +	/*
> +	 * Formal parameter checking.
> +	 */
> +	if (unlikely(pkt_in == NULL) || unlikely(pkts_out == NULL) ||
> +	    unlikely(nb_pkts_out == 0) ||
> +	    unlikely(pool_direct == NULL) || unlikely(pool_indirect == NULL) ||
> +	    unlikely(mtu_size < RTE_ETHER_MIN_MTU))
> +		return -EINVAL;
> +
>   	/*
>   	 * Ensure the IP payload length of all fragments is aligned to a
>   	 * multiple of 8 bytes as per RFC791 section 2.3.
Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>

Patch
diff mbox series

diff --git a/lib/librte_ip_frag/rte_ipv4_fragmentation.c b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
index 9e9f986cc5..e9de335ae2 100644
--- a/lib/librte_ip_frag/rte_ipv4_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
@@ -8,6 +8,7 @@ 
 #include <rte_memcpy.h>
 #include <rte_mempool.h>
 #include <rte_debug.h>
+#include <rte_ether.h>
 
 #include "ip_frag_common.h"
 
@@ -76,6 +77,15 @@  rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
 	uint16_t fragment_offset, flag_offset, frag_size;
 	uint16_t frag_bytes_remaining;
 
+	/*
+	 * Formal parameter checking.
+	 */
+	if (unlikely(pkt_in == NULL) || unlikely(pkts_out == NULL) ||
+	    unlikely(nb_pkts_out == 0) ||
+	    unlikely(pool_direct == NULL) || unlikely(pool_indirect == NULL) ||
+	    unlikely(mtu_size < RTE_ETHER_MIN_MTU))
+		return -EINVAL;
+
 	/*
 	 * Ensure the IP payload length of all fragments is aligned to a
 	 * multiple of 8 bytes as per RFC791 section 2.3.