From 0adabfc5e50d1367ec3bbcf2faaed0e1955fa1d4 Mon Sep 17 00:00:00 2001 From: Thiery Ouattara Date: Thu, 3 Dec 2020 17:44:30 +0000 Subject: [PATCH] tests: fix packets bug in vtep tests Signed-off-by: Thiery Ouattara --- src/packets.c | 16 ++++++++++++++++ src/packets.h | 4 ++++ tests/vtep/tests.c | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/packets.c b/src/packets.c index 936c67a17..c0dbadae7 100644 --- a/src/packets.c +++ b/src/packets.c @@ -59,6 +59,22 @@ struct rte_mbuf **pg_packets_append_blank(struct rte_mbuf **pkts, return pkts; } +struct rte_mbuf **pg_packets_prepend_blank(struct rte_mbuf **pkts, + uint64_t pkts_mask, + uint16_t len) +{ + char *tmp; + + PG_FOREACH_BIT(pkts_mask, j) { + if (!pkts[j]) + continue; + tmp = rte_pktmbuf_append(pkts[j], len); + if (!tmp) + return NULL; + } + return pkts; +} + #define PG_PACKETS_OPS_BUF(pkts, pkts_mask, buf, len, ops) \ void *tmp; \ PG_FOREACH_BIT(pkts_mask, j) { \ diff --git a/src/packets.h b/src/packets.h index 443257400..2cdeb6c93 100644 --- a/src/packets.h +++ b/src/packets.h @@ -60,6 +60,10 @@ struct rte_mbuf **pg_packets_append_blank(struct rte_mbuf **pkts, uint64_t pkts_mask, uint16_t len); +struct rte_mbuf **pg_packets_prepend_blank(struct rte_mbuf **pkts, + uint64_t pkts_mask, + uint16_t len); + struct rte_mbuf **pg_packets_append_buf(struct rte_mbuf **pkts, uint64_t pkts_mask, const void *buf, diff --git a/tests/vtep/tests.c b/tests/vtep/tests.c index 8ab9a7387..19d8854c9 100644 --- a/tests/vtep/tests.c +++ b/tests/vtep/tests.c @@ -787,6 +787,8 @@ static void test_vtep_vnis(int flag) i % NB_VNIS); pg_packets_prepend_vxlan(pkts, mask & 0xff0000, (i + 1) % NB_VNIS); + pg_packets_prepend_blank(pkts, mask & (~0xffffff), + sizeof(struct vxlan_hdr)); pg_packets_prepend_udp(pkts, mask, 1000, PG_VTEP_DST_PORT, 1400);