[dpdk-dev] [PATCH v3 4/4] ipfrag: add unit test case
Pavan Nikhilesh Bhagavatula
pbhagavatula at marvell.com
Sat Apr 4 17:58:03 CEST 2020
>Subject: [dpdk-dev] [PATCH v3 4/4] ipfrag: add unit test case
>
>Initial IP fragmentation unit test.
>
>Signed-off-by: Aaron Conole <aconole at redhat.com>
>---
> MAINTAINERS | 1 +
> app/test/meson.build | 2 +
> app/test/test_ipfrag.c | 277
>+++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 280 insertions(+)
> create mode 100644 app/test/test_ipfrag.c
>
<snip>
>+static int
>+v4_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, int df,
>+ uint8_t ttl, uint8_t proto, uint16_t pktid)
>+{
>+ /* Create a packet, 2k bytes long */
>+ b->data_off = 0;
>+ char *data = rte_pktmbuf_mtod(b, char *);
>+
>+ memset(data, fill, sizeof(struct rte_ipv4_hdr) + s);
>+
>+ struct rte_ipv4_hdr *hdr = (struct rte_ipv4_hdr *)data;
>+
>+ hdr->version_ihl = 0x45; /* standard IP header... */
>+ hdr->type_of_service = 0;
>+ b->pkt_len = s + sizeof(struct rte_ipv4_hdr);
>+ b->data_len = b->pkt_len;
>+ hdr->total_length = htonl(b->pkt_len);
Minor nit, please use rte_cpu_to_be_xx() for byte order conversion across the file.
>+ hdr->packet_id = htons(pktid);
>+ hdr->fragment_offset = 0;
>+ if (df)
>+ hdr->fragment_offset = htons(0x4000);
>+
>+ if (!ttl)
>+ ttl = 64; /* default to 64 */
>+
>+ if (!proto)
>+ proto = 1; /* icmp */
>+
>+ hdr->time_to_live = ttl;
>+ hdr->next_proto_id = proto;
>+ hdr->hdr_checksum = 0;
>+ hdr->src_addr = htonl(0x8080808);
>+ hdr->dst_addr = htonl(0x8080404);
>+
>+ return 0;
>+}
>+
More information about the dev
mailing list