[dpdk-dev] [PATCH v2 12/12] virtio: add Tso support

Stephen Hemminger stephen at networkplumber.org
Fri Oct 14 01:33:30 CEST 2016


On Thu, 13 Oct 2016 16:18:39 +0800
Yuanhan Liu <yuanhan.liu at linux.intel.com> wrote:

> On Mon, Oct 03, 2016 at 11:00:23AM +0200, Olivier Matz wrote:
> > +/* When doing TSO, the IP length is not included in the pseudo header
> > + * checksum of the packet given to the PMD, but for virtio it is
> > + * expected.
> > + */
> > +static void
> > +virtio_tso_fix_cksum(struct rte_mbuf *m)
> > +{
> > +	/* common case: header is not fragmented */
> > +	if (likely(rte_pktmbuf_data_len(m) >= m->l2_len + m->l3_len +
> > +			m->l4_len)) {  
> ...
> > +		/* replace it in the packet */
> > +		th->cksum = new_cksum;
> > +	} else {  
> ...
> > +		/* replace it in the packet */
> > +		*rte_pktmbuf_mtod_offset(m, uint8_t *,
> > +			m->l2_len + m->l3_len + 16) = new_cksum.u8[0];
> > +		*rte_pktmbuf_mtod_offset(m, uint8_t *,
> > +			m->l2_len + m->l3_len + 17) = new_cksum.u8[1];
> > +	}  
> 
> The tcp header will always be in the mbuf, right? Otherwise, you can't
> update the cksum field here. What's the point of introducing the "else
> clause" then?
> 
> 	--yliu

You need to check the reference count before updating any data in mbuf.


More information about the dev mailing list