[dpdk-dev] [PATCH v2] mbuf/ip_frag: Move mbuf chaining to common code

Simon Kågström simon.kagstrom at netinsight.net
Mon Sep 7 14:41:15 CEST 2015


On 2015-09-07 14:32, Ananyev, Konstantin wrote:
>> +static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail)
>> +{
>> +	struct rte_mbuf *cur_tail;
>> +
>> +	/* Check for number-of-segments-overflow */
>> +	if (head->nb_segs + tail->nb_segs >= sizeof(head->nb_segs) << 8)
>> +		return -EOVERFLOW;
> 
> Would probably be better 'sizeof(head->nb_segs) << CHAR_BIT', or even just: '  > UINT8_MAX'.
> Konstantin

Thanks. I got it wrong anyway, what I wanted was to be able to handle
the day when nb_segs changes to a 16-bit number, but then it should
really be

  ... >= 1 << (sizeof(head->nb_segs) * 8)

anyway. I'll fix that and also add a warning that the implementation
will do a linear search to find the tail entry.

// Simon



More information about the dev mailing list