c - dpdk 18.08 中的 rte_mbuf 没有 struct rte_pktmbuf pkt

标签 c linux dpdk

升级到 dpdk 18.08 版本后出现以下编译错误。

error: ‘struct rte_mbuf’ has no member named ‘pkt’
  m->pkt.data = ((char*)m->pkt.data - (BTG_IP_VHL_HL(ip->version_ihl) << 2));
   ^

根据文档 rte_mbuf 结构不再有数据包消息缓冲区结构 rte_pktmbuf pkt 反过来保存 void* 数据,其中包含段缓冲区中数据的起始地址。

struct rte_mbuf {
.
.
.
union {
        struct rte_ctrlmbuf ctrl;
        struct rte_pktmbuf pkt;
    };
}
struct rte_pktmbuf {
    /* valid for any segment */
    struct rte_mbuf *next; 
    void* data;  /**< Start address of data in segment buffer. */

请告诉我 rte_mbuf 结构的其他哪些字段可以与 dpdk 18.08 版本一起使用,这意味着数据包消息缓冲区中数据的起始地址,以解决此编译错误。提前致谢。

最佳答案

它是 rte_pktmbuf_mtod(m, t) 宏。

A macro that points to the start of the data in the mbuf.

The returned pointer is cast to type t. Before using this function, the user must ensure that the first segment is large enough to accommodate its data.

来源:DPDK API

更新:

要在数据包缓冲区中添加一些数据,有一个专用函数:rte_pktmbuf_prepend()(这里是 DPDK documentation)

如果没有旧代码的上下文,很难 100% 确定,但看起来必须将此片段重写为:

rte_pktmbuf_prepend(m,
        BTG_IP_VHL_HL(ip->version_ihl) << 2);

关于c - dpdk 18.08 中的 rte_mbuf 没有 struct rte_pktmbuf pkt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53923097/

相关文章:

c - 数字三角形的反转[c]

linux - 请帮助我使用 linux 终端检查主机文件中的重复项

linux - 从另一个 shell 脚本执行 shell 脚本并传递关键字作为参数

dpdk - rte_eal_init 的完整有效参数集是否记录在任何地方?

ubuntu - 使用大数据包时性能下降

有效网络掩码的 c 代码

c - 标记字符串

c - pthread_t 数组初始化的段错误

linux - 将文件从服务器A复制到服务器B的shell脚本

dpdk - DPDK中Reorder Library和IP分片的目的