ip_frag: ensure minimum v6 fragmentation length
authorAaron Conole <aconole@redhat.com>
Mon, 20 Apr 2020 19:25:22 +0000 (15:25 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 25 Apr 2020 13:15:27 +0000 (15:15 +0200)
In addition, do a formal parameter check.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
lib/librte_ip_frag/rte_ipv6_fragmentation.c
lib/librte_net/rte_ip.h

index 4344997..5d67336 100644 (file)
@@ -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.
index a69430f..4c4437a 100644 (file)
@@ -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.
  *