Page MenuHomeFreeBSD

D4994.diff
No OneTemporary

D4994.diff

Index: sys/netinet/tcp_lro.c
===================================================================
--- sys/netinet/tcp_lro.c
+++ sys/netinet/tcp_lro.c
@@ -41,6 +41,7 @@
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_var.h>
@@ -53,6 +54,7 @@
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
#include <netinet/tcp_lro.h>
#include <netinet6/ip6_var.h>
@@ -66,6 +68,13 @@
#define TCP_LRO_INVALID_CSUM 0x0000
#endif
+static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, lro,
+ CTLFLAG_RW, 0, "LRO parameters");
+
+static int tcp_lro_use_qsort;
+SYSCTL_INT(_net_inet_tcp_lro, OID_AUTO, use_qsort, CTLFLAG_RWTUN,
+ &tcp_lro_use_qsort, 0, "Set to use QuickSort else MergeSort is used");
+
int
tcp_lro_init(struct lro_ctrl *lc)
{
@@ -92,7 +101,7 @@
SLIST_INIT(&lc->lro_active);
/* compute size to allocate */
- size = (lro_mbufs * sizeof(struct mbuf *)) +
+ size = (2 * lro_mbufs * sizeof(struct mbuf *)) +
(lro_entries * sizeof(*le));
lc->lro_mbuf_data = (struct mbuf **)
malloc(size, M_LRO, M_NOWAIT | M_ZERO);
@@ -104,7 +113,7 @@
}
/* compute offset for LRO entries */
le = (struct lro_entry *)
- (lc->lro_mbuf_data + lro_mbufs);
+ (lc->lro_mbuf_data + 2 * lro_mbufs);
/* setup linked list */
for (i = 0; i != lro_entries; i++)
@@ -340,19 +349,28 @@
{
const struct mbuf *ma = *((const struct mbuf * const *)ppa);
const struct mbuf *mb = *((const struct mbuf * const *)ppb);
- int ret;
+ int64_t ret;
- ret = M_HASHTYPE_GET(ma) - M_HASHTYPE_GET(mb);
+ ret = ((uint64_t)(uint32_t)M_HASHTYPE_GET(ma)) -
+ ((uint64_t)(uint32_t)M_HASHTYPE_GET(mb));
if (ret != 0)
goto done;
- ret = ma->m_pkthdr.flowid - mb->m_pkthdr.flowid;
+ ret = ((uint64_t)(uint32_t)ma->m_pkthdr.flowid) -
+ ((uint64_t)(uint32_t)mb->m_pkthdr.flowid);
if (ret != 0)
goto done;
- ret = TCP_LRO_SEQUENCE(ma) - TCP_LRO_SEQUENCE(mb);
+ ret = ((uint64_t)(uint32_t)TCP_LRO_SEQUENCE(ma)) -
+ ((uint64_t)(uint32_t)TCP_LRO_SEQUENCE(mb));
+ if (ret != 0)
+ goto done;
+ return (0);
done:
- return (ret);
+ if (ret < 0)
+ return (-1);
+ else
+ return (1);
}
void
@@ -367,9 +385,14 @@
if (__predict_false(lc->lro_mbuf_count == 0))
goto done;
- /* sort all mbufs according to stream */
- qsort(lc->lro_mbuf_data, lc->lro_mbuf_count, sizeof(struct mbuf *),
- &tcp_lro_mbuf_compare_header);
+ if (__predict_false(tcp_lro_use_qsort)) {
+ qsort(lc->lro_mbuf_data, lc->lro_mbuf_count,
+ sizeof(struct mbuf *), &tcp_lro_mbuf_compare_header);
+ } else {
+ mergesort_by_pointer((void **)lc->lro_mbuf_data,
+ (void **)(lc->lro_mbuf_data + lc->lro_mbuf_count),
+ lc->lro_mbuf_count, &tcp_lro_mbuf_compare_header);
+ }
/* input data into LRO engine, stream by stream */
flowid = 0;
@@ -391,10 +414,6 @@
tcp_lro_flush(lc, le);
}
}
-#ifdef TCP_LRO_RESET_SEQUENCE
- /* reset sequence number */
- TCP_LRO_SEQUENCE(mb) = 0;
-#endif
/* add packet to LRO engine */
if (tcp_lro_rx(lc, mb, 0) != 0) {
/* input packet to network layer */

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 13, 4:17 PM (5 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40760530
Default Alt Text
D4994.diff (3 KB)

Event Timeline