eal/windows: add missing SPDX license tag
[dpdk.git] / lib / librte_ip_frag / rte_ipv4_reassembly.c
index 97da607..69666c8 100644 (file)
@@ -66,16 +66,13 @@ ipv4_frag_reassemble(struct ip_frag_pkt *fp)
        m = fp->frags[IP_FIRST_FRAG_IDX].mb;
        fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-       /* update mbuf fields for reassembled packet. */
-       m->ol_flags |= PKT_TX_IP_CKSUM;
-
        /* update ipv4 header for the reassembled packet */
        ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, m->l2_len);
 
        ip_hdr->total_length = rte_cpu_to_be_16((uint16_t)(fp->total_size +
                m->l3_len));
        ip_hdr->fragment_offset = (uint16_t)(ip_hdr->fragment_offset &
-               rte_cpu_to_be_16(IPV4_HDR_DF_FLAG));
+               rte_cpu_to_be_16(RTE_IPV4_HDR_DF_FLAG));
        ip_hdr->hdr_checksum = 0;
 
        return m;
@@ -107,10 +104,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
        const unaligned_uint64_t *psd;
        uint16_t flag_offset, ip_ofs, ip_flag;
        int32_t ip_len;
+       int32_t trim;
 
        flag_offset = rte_be_to_cpu_16(ip_hdr->fragment_offset);
-       ip_ofs = (uint16_t)(flag_offset & IPV4_HDR_OFFSET_MASK);
-       ip_flag = (uint16_t)(flag_offset & IPV4_HDR_MF_FLAG);
+       ip_ofs = (uint16_t)(flag_offset & RTE_IPV4_HDR_OFFSET_MASK);
+       ip_flag = (uint16_t)(flag_offset & RTE_IPV4_HDR_MF_FLAG);
 
        psd = (unaligned_uint64_t *)&ip_hdr->src_addr;
        /* use first 8 bytes only */
@@ -118,16 +116,17 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
        key.id = ip_hdr->packet_id;
        key.key_len = IPV4_KEYLEN;
 
-       ip_ofs *= IPV4_HDR_OFFSET_UNITS;
+       ip_ofs *= RTE_IPV4_HDR_OFFSET_UNITS;
        ip_len = rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len;
+       trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len);
 
        IP_FRAG_LOG(DEBUG, "%s:%d:\n"
-               "mbuf: %p, tms: %" PRIu64
-               ", key: <%" PRIx64 ", %#x>, ofs: %u, len: %d, flags: %#x\n"
+               "mbuf: %p, tms: %" PRIu64 ", key: <%" PRIx64 ", %#x>"
+               "ofs: %u, len: %d, padding: %d, flags: %#x\n"
                "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, "
                "max_entries: %u, use_entries: %u\n\n",
                __func__, __LINE__,
-               mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, ip_flag,
+               mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, trim, ip_flag,
                tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries,
                tbl->use_entries);
 
@@ -137,6 +136,9 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
                return NULL;
        }
 
+       if (unlikely(trim > 0))
+               rte_pktmbuf_trim(mb, trim);
+
        /* try to find/add entry into the fragment's table. */
        if ((fp = ip_frag_find(tbl, dr, &key, tms)) == NULL) {
                IP_FRAG_MBUF2DR(dr, mb);