DPDK new mbuf 사용 주의사항
Page content
l2_len, l3_len, l4_len 등을 사용하는 라이브러리가 존재함
- reassembly
- Tx checksum offload
Reassembly
rte_ipv6_frag_reassemble_packet(), rte_ipv4_frag_reassemble_packet()
Incoming mbuf should have its l2_len and l3_len fields setup correctly.
L4 checksum HW offloading
To use hardware L4 checksum offload, the user needs to
- fill
l2_lenandl3_lenin mbuf - set the flags
PKT_TX_TCP_CKSUM,PKT_TX_SCTP_CKSUMorPKT_TX_UDP_CKSUM - set the flag
PKT_TX_IPV4orPKT_TX_IPV6 - calculate the pseudo header checksum and set it in the L4 header (only for TCP or UDP). See
rte_ipv4_phdr_cksum()andrte_ipv6_phdr_cksum(). For SCTP, set the crc field to 0.
L3 checksum HW offloading
- set the flag
PKT_TX_IPV4(IP checksum은 IPv4에만 존재) - set the IP checksum field in the packet to 0
- fill the mbuf offload information:
l2_len,l3_len PKT_TX_IP_CKSUM
IP checksum offloading
example from prog_guide/mbuf_lib.rst
This is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM.
mb->l2_len = len(out_eth)
mb->l3_len = len(out_ip)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM
set out_ip checksum to 0 in the packet
IP, UDP checksum offloading
This is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM and DEV_TX_OFFLOAD_UDP_CKSUM.
mb->l2_len = len(out_eth)
mb->l3_len = len(out_ip)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM | PKT_TX_UDP_CKSUM
set out_ip checksum to 0 in the packet
set out_udp checksum to pseudo header using rte_ipv4_phdr_cksum()
Outer IP, inner IP and inner TCP checksum offloading
This is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM, DEV_TX_OFFLOAD_UDP_CKSUM and DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM.
mb->outer_l2_len = len(out_eth)
mb->outer_l3_len = len(out_ip)
mb->l2_len = len(out_udp + vxlan + in_eth)
mb->l3_len = len(in_ip)
mb->ol_flags |= PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IP_CKSUM | \
PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM;
set out_ip checksum to 0 in the packet
set in_ip checksum to 0 in the packet
set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum()