Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 lib/gro/gro_tcp.h        | 4 ++--
 lib/gro/gro_tcp4.c       | 4 ++--
 lib/gro/gro_tcp6.c       | 4 ++--
 lib/gro/gro_udp4.c       | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h
index d926c4b8cc71..bbd2f9c16a00 100644
--- a/lib/gro/gro_tcp.h
+++ b/lib/gro/gro_tcp.h
@@ -150,8 +150,8 @@ check_seq_option(struct gro_tcp_item *item,
        struct rte_tcp_hdr *tcph_orig;
        uint16_t len, tcp_hl_orig;
 
-       iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-                       l2_offset + pkt_orig->l2_len);
+       iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *,
+                                          l2_offset + pkt_orig->l2_len);
        tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len);
        tcp_hl_orig = pkt_orig->l4_len;
 
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 6645de592b63..d6c0f9182d45 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -223,8 +223,8 @@ update_header(struct gro_tcp_item *item)
        struct rte_ipv4_hdr *ipv4_hdr;
        struct rte_mbuf *pkt = item->firstseg;
 
-       ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-                       pkt->l2_len);
+       ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+                                          pkt->l2_len);
        ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
                        pkt->l2_len);
 }
diff --git a/lib/gro/gro_tcp6.c b/lib/gro/gro_tcp6.c
index 5aa39801e132..6edfb6045cf6 100644
--- a/lib/gro/gro_tcp6.c
+++ b/lib/gro/gro_tcp6.c
@@ -118,8 +118,8 @@ update_header(struct gro_tcp_item *item)
        struct rte_ipv6_hdr *ipv6_hdr;
        struct rte_mbuf *pkt = item->firstseg;
 
-       ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-                       pkt->l2_len);
+       ipv6_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv6_hdr *,
+                                          pkt->l2_len);
        ipv6_hdr->payload_len = rte_cpu_to_be_16(pkt->pkt_len -
                        pkt->l2_len - pkt->l3_len);
 }
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
        struct rte_mbuf *pkt = item->firstseg;
        uint16_t frag_offset;
 
-       ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-                       pkt->l2_len);
+       ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+                                          pkt->l2_len);
        ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
                        pkt->l2_len);
 
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 6ab700192261..2752650389a4 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
        /* Update the outer IPv4 header. */
        len = pkt->pkt_len - pkt->outer_l2_len;
-       ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-                       pkt->outer_l2_len);
+       ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+                                          pkt->outer_l2_len);
        ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
        /* Update the outer UDP header. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
        /* Update the outer IPv4 header. */
        len = pkt->pkt_len - pkt->outer_l2_len;
-       ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-                       pkt->outer_l2_len);
+       ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+                                          pkt->outer_l2_len);
        ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
        /* Update the outer UDP header. */
-- 
2.39.2

Reply via email to