[v3,2/4] ip_frag: ensure minimum v6 fragmentation length

Message ID 20200401183917.3620845-3-aconole@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series ip_frag: add a unit test for fragmentation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Aaron Conole April 1, 2020, 6:39 p.m. UTC
  Similar to v4, we should ensure that at least a minimum fragmentation
length can be achieved.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 lib/librte_ip_frag/rte_ipv6_fragmentation.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Ananyev, Konstantin April 7, 2020, 10:48 a.m. UTC | #1
> 
> Similar to v4, we should ensure that at least a minimum fragmentation
> length can be achieved.
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  lib/librte_ip_frag/rte_ipv6_fragmentation.c | 11 +++++++++++
>  1 file 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..820a5dc725 100644
> --- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> +++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> @@ -79,6 +79,17 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
>  	uint16_t fragment_offset, frag_size;
>  	uint64_t frag_bytes_remaining;
> 
> +	/*
> +	 * The rules on ipv6 fragmentation means we need at least to be
> +	 * greater than the smallest fragment possible - ipv6hdr + frag header
> +	 * + min octets.  We rely on the ipv6_extension_fragment header to
> +	 * include 'data' octets.
> +	 */
> +	if (unlikely(mtu_size <
> +		     (sizeof(struct rte_ipv6_hdr) +
> +		      sizeof(struct ipv6_extension_fragment))))
> +		return -EINVAL;
> +		

Don't know where it comes from.
Reading RFC 8200, it clearly states that min MTU for ipv6 is 1280B.
In fact, I don't see much point in these extra checking.

>  	/*
>  	 * Ensure the IP payload length of all fragments (except the
>  	 * the last fragment) are a multiple of 8 bytes per RFC2460.
> --
> 2.25.1
  

Patch

diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
index 43449970e5..820a5dc725 100644
--- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
@@ -79,6 +79,17 @@  rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
 	uint16_t fragment_offset, frag_size;
 	uint64_t frag_bytes_remaining;
 
+	/*
+	 * The rules on ipv6 fragmentation means we need at least to be
+	 * greater than the smallest fragment possible - ipv6hdr + frag header
+	 * + min octets.  We rely on the ipv6_extension_fragment header to
+	 * include 'data' octets.
+	 */
+	if (unlikely(mtu_size <
+		     (sizeof(struct rte_ipv6_hdr) +
+		      sizeof(struct ipv6_extension_fragment))))
+		return -EINVAL;
+
 	/*
 	 * Ensure the IP payload length of all fragments (except the
 	 * the last fragment) are a multiple of 8 bytes per RFC2460.