Re: [PATCH v4 4/4] net/af_packet: add software checksum offload support

Stephen Hemminger
2026-02-02T17:00:52Z

On Mon, 2 Feb 2026 00:14:56 -0800
scott.k.mitch1@gmail.com wrote:

> + if (copy) {
> + /*
> + * Copy headers to new segment to handle indirect mbufs.
> + * This ensures we can safely modify checksums without
> + * corrupting shared/read-only data.
> + */
> + struct rte_mbuf *seg = rte_pktmbuf_copy(mbuf, mbuf->pool, 0, hdrlens);
> + if (!seg)
> + return NULL;
> +
> + rte_pktmbuf_adj(mbuf, hdrlens);
> + rte_pktmbuf_chain(seg, mbuf);
> + mbuf = seg;
> + } else if (unlikely(!RTE_MBUF_DIRECT(mbuf) || rte_mbuf_refcnt_read(mbuf) > 1))
> + return NULL;

Maybe just rte_pkmbuf_read() helper that already handles the case of getting
the header if needed.