Skip to content

Commit

Permalink
examples/l2fwd-crypto: use mbuf API for offset addition
Browse files Browse the repository at this point in the history
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
  • Loading branch information
shemminger authored and tmonjalo committed Jan 24, 2024
1 parent cebcefb commit 2ecc673
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/l2fwd-crypto/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,

ipdata_offset = sizeof(struct rte_ether_hdr);

ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
ipdata_offset);
ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
ipdata_offset);

ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
Expand Down Expand Up @@ -479,8 +479,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->auth.digest.data = (uint8_t *)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
op->sym->auth.digest.data = rte_pktmbuf_mtod(m,
uint8_t *) + ipdata_offset + data_len;
op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
uint8_t *, ipdata_offset + data_len);
}

op->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m,
Expand Down Expand Up @@ -540,8 +540,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->aead.digest.data = (uint8_t *)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
op->sym->aead.digest.data = rte_pktmbuf_mtod(m,
uint8_t *) + ipdata_offset + data_len;
op->sym->aead.digest.data = rte_pktmbuf_mtod_offset(m,
uint8_t *, ipdata_offset + data_len);
}

op->sym->aead.digest.phys_addr = rte_pktmbuf_iova_offset(m,
Expand Down Expand Up @@ -631,7 +631,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
struct rte_ipv4_hdr *ip_hdr;
uint32_t ipdata_offset = sizeof(struct rte_ether_hdr);

ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
ipdata_offset);
dst_port = l2fwd_dst_ports[portid];

Expand Down

0 comments on commit 2ecc673

Please sign in to comment.