summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLu Qiuwen <[email protected]>2022-04-20 16:02:34 -0400
committerLu Qiuwen <[email protected]>2022-06-07 14:08:53 -0400
commit55f38ba0080600b9b65340696b9b7f2312cc62c6 (patch)
treeb0a8a527c545b8ad41de94e08b2c5eef063902b4 /examples
parent6ffddf81cf32bf823cd2d45bb44a30865c34f237 (diff)
为使用mlx6网卡规则去重配置,适配DPDK 21.11并增加部分日志信息和统计功能。
Diffstat (limited to 'examples')
-rw-r--r--examples/smartoffload.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/smartoffload.cc b/examples/smartoffload.cc
index 87d19f5..2a8b387 100644
--- a/examples/smartoffload.cc
+++ b/examples/smartoffload.cc
@@ -11,6 +11,7 @@ extern "C" {
#include <rte_ether.h>
#include <rte_ip.h>
#include <rte_udp.h>
+#include <rte_version.h>
}
#include <algorithm>
@@ -65,9 +66,16 @@ int __is_bfd_pkt_and_make_answer(char * pkt_ptr, unsigned int pkt_len, bool make
we need to swap the mac addresses and ipv4 addresses */
struct rte_ether_addr swap_tmp;
+
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ rte_ether_addr_copy(&eth_hdr->dst_addr, &swap_tmp);
+ rte_ether_addr_copy(&eth_hdr->src_addr, &eth_hdr->dst_addr);
+ rte_ether_addr_copy(&swap_tmp, &eth_hdr->src_addr);
+#else
rte_ether_addr_copy(&eth_hdr->d_addr, &swap_tmp);
rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&swap_tmp, &eth_hdr->s_addr);
+#endif
/* ipv4 src, dst and udp's ports must be swap */
rte_be32_t ipv4_addr_swap_tmp;
@@ -119,9 +127,16 @@ int __is_g_vxlan_and_make_inject(char * pkt_ptr, unsigned int pkt_len, bool do_i
if (do_inject)
{
struct rte_ether_addr swap_tmp;
+
+#if RTE_VERSION_NUM(21, 11, 0, 0) <= RTE_VERSION
+ rte_ether_addr_copy(&eth_hdr->dst_addr, &swap_tmp);
+ rte_ether_addr_copy(&eth_hdr->src_addr, &eth_hdr->dst_addr);
+ rte_ether_addr_copy(&swap_tmp, &eth_hdr->src_addr);
+#else
rte_ether_addr_copy(&eth_hdr->d_addr, &swap_tmp);
rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&swap_tmp, &eth_hdr->s_addr);
+#endif
rte_be32_t ipv4_addr_swap_tmp;
ipv4_addr_swap_tmp = ipv4_hdr->dst_addr;