Page MenuHomeFreeBSD

D62516.1796619239.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D62516.1796619239.diff

diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c
--- a/sys/netinet/tcp_lro.c
+++ b/sys/netinet/tcp_lro.c
@@ -81,6 +81,7 @@
static MALLOC_DEFINE(M_LRO, "LRO", "LRO control structures");
static void tcp_lro_rx_done(struct lro_ctrl *lc);
+static bool tcp_lro_csum_ok(const struct mbuf *m);
static int tcp_lro_rx_common(struct lro_ctrl *lc, struct mbuf *m,
uint32_t csum, bool use_hash);
static void tcp_lro_flush(struct lro_ctrl *lc, struct lro_entry *le);
@@ -1260,7 +1261,8 @@
}
/* add packet to LRO engine */
- if (tcp_lro_rx_common(lc, mb, 0, false) != 0) {
+ if (!tcp_lro_csum_ok(mb) ||
+ tcp_lro_rx_common(lc, mb, 0, false) != 0) {
/* Flush anything we have acummulated */
tcp_lro_flush_active(lc);
/* input packet to network layer */
@@ -1418,6 +1420,19 @@
return (0);
}
+/*
+ * We can only LRO a packet whose checksum the hardware has verified: it
+ * has either no checksum offload or a bad checksum otherwise.
+ */
+static bool
+tcp_lro_csum_ok(const struct mbuf *m)
+{
+
+ return ((m->m_pkthdr.csum_flags & (CSUM_DATA_VALID |
+ CSUM_PSEUDO_HDR)) == (CSUM_DATA_VALID | CSUM_PSEUDO_HDR) &&
+ m->m_pkthdr.csum_data == 0xffff);
+}
+
int
tcp_lro_rx(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum)
{
@@ -1439,14 +1454,7 @@
}
#endif
- if (((m->m_pkthdr.csum_flags & (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) !=
- ((CSUM_DATA_VALID | CSUM_PSEUDO_HDR))) ||
- (m->m_pkthdr.csum_data != 0xffff)) {
- /*
- * The checksum either did not have hardware offload
- * or it was a bad checksum. We can't LRO such
- * a packet.
- */
+ if (!tcp_lro_csum_ok(m)) {
counter_u64_add(tcp_bad_csums, 1);
CURVNET_RESTORE();
return (TCP_LRO_CANNOT);
@@ -1507,17 +1515,27 @@
return;
}
- if (((mb->m_pkthdr.csum_flags & (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) !=
- ((CSUM_DATA_VALID | CSUM_PSEUDO_HDR))) ||
- (mb->m_pkthdr.csum_data != 0xffff)) {
+ if (!tcp_lro_csum_ok(mb)) {
+ counter_u64_add(tcp_bad_csums, 1);
/*
- * The checksum either did not have hardware offload
- * or it was a bad checksum. We can't LRO such
- * a packet.
+ * A packet that cannot be LRO'ed is passed on at once,
+ * unless that would put it ahead of queued packets of its
+ * flow: the IP fragments of a UDP flow, for one, have no
+ * checksum offload while its other datagrams do. With a
+ * hash it keeps its place in its flow in the queue, and
+ * tcp_lro_flush_all() passes it on from there. Without
+ * one it has no place there, so flush the queue first.
*/
- counter_u64_add(tcp_bad_csums, 1);
- (*lc->ifp->if_input) (lc->ifp, mb);
- return;
+ if (lc->lro_mbuf_count == 0) {
+ (*lc->ifp->if_input) (lc->ifp, mb);
+ return;
+ }
+ if (!M_HASHTYPE_ISHASH(mb)) {
+ tcp_lro_flush_all(lc);
+ (*lc->ifp->if_input) (lc->ifp, mb);
+ return;
+ }
+ goto queue;
}
/* If no hardware or arrival stamp on the packet add timestamp */
@@ -1530,6 +1548,7 @@
mb->m_flags |= M_TSTMP_LRO;
}
+queue:
/* create sequence number */
lc->lro_mbuf_data[lc->lro_mbuf_count].seq = lc->lro_mbuf_count;
if (M_HASHTYPE_ISHASH(mb))

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 7, 4:53 AM (14 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42270598
Default Alt Text
D62516.1796619239.diff (3 KB)

Event Timeline