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

Message ID 20200417131410.1343135-3-aconole@redhat.com
State Superseded, 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 17, 2020, 1:14 p.m. UTC
In addition, do a formal parameter check.

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 +++++++++
 1 file changed, 9 insertions(+)

Comments

Ananyev, Konstantin April 20, 2020, 12:53 p.m. UTC | #1
> 
> In addition, do a formal parameter check.
> 
> 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 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> index 43449970e5..ee984aed82 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 < 1280))

Same as for ipv4 - LGTM in general, but please avoid hard-coded constants for MTU values.
Here I couldn't find an existing macro ro min ipv6 mtu, so probably worth to add a new one
in librte_net/.

With that nit fixed:
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> +		return -EINVAL;
> +
>  	/*
>  	 * Ensure the IP payload length of all fragments (except the
>  	 * the last fragment) are a multiple of 8 bytes per RFC2460.
> --
> 2.25.1
Aaron Conole April 20, 2020, 3:26 p.m. UTC | #2
"Ananyev, Konstantin" <konstantin.ananyev@intel.com> writes:

>> 
>> In addition, do a formal parameter check.
>> 
>> 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 +++++++++
>>  1 file changed, 9 insertions(+)
>> 
>> diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
>> index 43449970e5..ee984aed82 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 < 1280))
>
> Same as for ipv4 - LGTM in general, but please avoid hard-coded constants for MTU values.
> Here I couldn't find an existing macro ro min ipv6 mtu, so probably worth to add a new one
> in librte_net/.

I plan to add it in rte_ip.h as RTE_IPV6_MIN_MTU since it seems to fit
there.  I don't think it looks right to add RTE_ETHER_IPV6_MIN_MTU in
the rte_ether.h file (but if you think it looks better I will change to
that).

> With that nit fixed:
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Thanks!

>> +		return -EINVAL;
>> +
>>  	/*
>>  	 * Ensure the IP payload length of all fragments (except the
>>  	 * the last fragment) are a multiple of 8 bytes per RFC2460.
>> --
>> 2.25.1
Ananyev, Konstantin April 20, 2020, 3:43 p.m. UTC | #3
> >> In addition, do a formal parameter check.
> >>
> >> 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 +++++++++
> >>  1 file changed, 9 insertions(+)
> >>
> >> diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
> >> index 43449970e5..ee984aed82 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 < 1280))
> >
> > Same as for ipv4 - LGTM in general, but please avoid hard-coded constants for MTU values.
> > Here I couldn't find an existing macro ro min ipv6 mtu, so probably worth to add a new one
> > in librte_net/.
> 
> I plan to add it in rte_ip.h as RTE_IPV6_MIN_MTU since it seems to fit
> there.

Sounds ok to me.
Thanks
Konstantin

  I don't think it looks right to add RTE_ETHER_IPV6_MIN_MTU in
> the rte_ether.h file (but if you think it looks better I will change to
> that).
> 
> > With that nit fixed:
> > Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> Thanks!
> 
> >> +		return -EINVAL;
> >> +
> >>  	/*
> >>  	 * 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 mbox series

diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
index 43449970e5..ee984aed82 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 < 1280))
+		return -EINVAL;
+
 	/*
 	 * Ensure the IP payload length of all fragments (except the
 	 * the last fragment) are a multiple of 8 bytes per RFC2460.