Use a pair of ifs when comparing the 32-bit flowid integers so that

the sign bit doesn't cause an overflow. The overflow manifests itself
as a sorting index wrap around in the middle of the sorted array,
which is not a problem for the LRO code, but might be a problem for
the logic inside qsort().

Reviewed by:		gnn @
Sponsored by:		Mellanox Technologies
Differential Revision:	https://reviews.freebsd.org/D5239
This commit is contained in:
Hans Petter Selasky 2016-02-11 10:03:50 +00:00
parent c7fc655f3f
commit 3e9470b721
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295506

View File

@ -347,9 +347,10 @@ tcp_lro_mbuf_compare_header(const void *ppa, const void *ppb)
if (ret != 0)
goto done;
ret = ma->m_pkthdr.flowid - mb->m_pkthdr.flowid;
if (ret != 0)
goto done;
if (ma->m_pkthdr.flowid > mb->m_pkthdr.flowid)
return (1);
else if (ma->m_pkthdr.flowid < mb->m_pkthdr.flowid)
return (-1);
ret = TCP_LRO_SEQUENCE(ma) - TCP_LRO_SEQUENCE(mb);
done: