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

Message ID 20200420192523.2546909-3-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/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Aaron Conole April 20, 2020, 7:25 p.m. UTC
In addition, do a formal parameter check.

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_ipv6_fragmentation.c | 9 +++++++++
 lib/librte_net/rte_ip.h                     | 2 ++
 2 files changed, 11 insertions(+)

Comments

Lukasz Wojciechowski April 21, 2020, 11:04 a.m. UTC | #1
W dniu 20.04.2020 o 21:25, Aaron Conole pisze:
> In addition, do a formal parameter check.
>
> 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_ipv6_fragmentation.c | 9 +++++++++
>   lib/librte_net/rte_ip.h                     | 2 ++
>   2 files changed, 11 insertions(+)
>
> diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> index 43449970e5..5d67336f2d 100644
> --- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> +++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> @@ -79,6 +79,15 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
>   	uint16_t fragment_offset, frag_size;
>   	uint64_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_IPV6_MIN_MTU))
> +		return -EINVAL;
> +
>   	/*
>   	 * Ensure the IP payload length of all fragments (except the
>   	 * the last fragment) are a multiple of 8 bytes per RFC2460.
> diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
> index 1ceb7b7931..d50edec572 100644
> --- a/lib/librte_net/rte_ip.h
> +++ b/lib/librte_net/rte_ip.h
> @@ -371,6 +371,8 @@ struct rte_ipv6_hdr {
>   #define RTE_IPV6_HDR_ECN_MASK	(0x03 << RTE_IPV6_HDR_TC_SHIFT)
>   #define RTE_IPV6_HDR_ECN_CE	RTE_IPV6_HDR_ECN_MASK
>   
> +#define RTE_IPV6_MIN_MTU 1280 /**< Minimum MTU for IPv6, see RFC 8200. */
> +
>   /**
>    * Process the pseudo-header checksum of an IPv6 header.
>    *
Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>

Patch
diff mbox series

diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
index 43449970e5..5d67336f2d 100644
--- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
@@ -79,6 +79,15 @@  rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
 	uint16_t fragment_offset, frag_size;
 	uint64_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_IPV6_MIN_MTU))
+		return -EINVAL;
+
 	/*
 	 * Ensure the IP payload length of all fragments (except the
 	 * the last fragment) are a multiple of 8 bytes per RFC2460.
diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index 1ceb7b7931..d50edec572 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -371,6 +371,8 @@  struct rte_ipv6_hdr {
 #define RTE_IPV6_HDR_ECN_MASK	(0x03 << RTE_IPV6_HDR_TC_SHIFT)
 #define RTE_IPV6_HDR_ECN_CE	RTE_IPV6_HDR_ECN_MASK
 
+#define RTE_IPV6_MIN_MTU 1280 /**< Minimum MTU for IPv6, see RFC 8200. */
+
 /**
  * Process the pseudo-header checksum of an IPv6 header.
  *