[dpdk-dev] About the data payload of rte_mbuf?

bai bakari 912873551 at qq.com
Thu Dec 6 05:59:54 CET 2018


Hi, 


Thank your reply.


For your two question, 
1. I think it's right, because the definition of "rte_pktmbuf_mtod_offset" is:
#define rte_pktmbuf_mtod_offset(m, t, o)	\
	((t)((char *)(m)->buf_addr + (m)->data_off + (o)))



2. I set the packet type is IPv4 when i use dpdk-pktgen, that if can promise its type is IPv4?


------------------ Original ------------------
From:  "Varghese, Vipin"<vipin.varghese at intel.com>;
Date:  Thu, Dec 6, 2018 12:20 PM
To:  "bai bakari"<912873551 at qq.com>;"dev"<dev at dpdk.org>;

Subject:  RE: [dpdk-dev] About the data payload of rte_mbuf?



Hi,

A quick query from your email

Snipped

> ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, sizeof(struct
> ether_hdr)); 

Questions:
1. Should not be sizeof(struct ipv4_hdr) since you are passing second argument as ipv4_hdr?
2. you are getting packets which starts from ether or ipv4? If it is ethernet header would not you checking if ether type is ipv4 first? You can get arp, vlan, mpls right?

ip_len = ntohs(ipv4_hdr->total_length);
> 
> 
> 
> if (ipv4_hdr->next_proto_id == IPPROTO_TCP) {
>     tcp_hdr = (struct tcp_hdr *)((uint8_t *)ipv4_hdr + ((ipv4_hdr->version_ihl &
> 0xf) << 2));
>     payload = (uint8_t *)tcp_hdr + (tcp_hdr->data_off << 2);
>     payload_len = ip_len - (payload - (uint8_t *)ipv4_hdr);
> 
> }
> 
> 
> when i send packets using dpdk-pktgen, i found:
> ip_len = 46
> ip_header_len = 20
> but the tcp_header_len=(tcp_hdr->data_off << 2)=0, and (payload - (uint8_t
> *)ipv4_hdr) = 340 > ip_len.
> 
> 
> I'm confused, is there any errors about the code to compute the payload_len of
> rte_mbuf?
> I think maybe the dpdk-pktgen cannot send the packets with payload?
> 
> 
> I'm a beginner, anyone can help me how to compute the payload_len of
> rte_mbuf and test it?
> 
> 
> Thank you in advance!


More information about the dev mailing list