PERFORCE change 133211 for review
Andre Oppermann
andre at FreeBSD.org
Sun Jan 13 17:56:06 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=133211
Change 133211 by andre at andre_flirtbox on 2008/01/14 01:55:13
When missing segment prepend to first block instead of creating a new one
Fix segment prepending
Add KASSERT
Update comments
Affected files ...
.. //depot/projects/tcp_reass/netinet/tcp_reass.c#3 edit
Differences ...
==== //depot/projects/tcp_reass/netinet/tcp_reass.c#3 (text+ko) ====
@@ -182,7 +182,7 @@
/* Accounting. */
tcpstat.tcps_rcvoopack++;
tcpstat.tcps_rcvoobyte += *tlenp;
- /* NB: m_adj(m, -i) may free mbufs at the tail of a chain. */
+ /* NB: m_adj(m, -i) may free mbufs at the tail of a chain. */
for (n = m; n; n = n->m_next)
segs++;
tp->t_trqlen += segs;
@@ -206,11 +206,14 @@
tqe = TAILQ_FIRST(&tp->t_trq);
KASSERT(tqe != NULL,
("%s: missing segment but nothing in queue", __func__));
+ KASSERT(SEQ_GT(tqe->trq_seq, th->th_seq),
+ ("%s: first block already contains missing segment", __func__));
if (SEQ_LT(tqe->trq_seq, th->th_seq + *tlenp)) {
- /* Trim tail. */
+ /* Trim tail of segment. */
if ((i = tqe->trq_seq - (th->th_seq + *tlenp))) {
m_adj(m, i);
*tlenp -= i;
+ /* tcpstat */
/* Update accounting. */
if (segs > 1) {
for (n = m; n; n = n->m_next)
@@ -219,18 +222,26 @@
tcp_reass_qsize -= segs;
}
}
+ /* Segment prepends first block. */
+ tqe->trq_len += *tlenp;
+ tqe->trq_segs += segs;
+ tqe->trq_seq = th->th_seq;
+ n = m_last(m);
+ n->m_next = tqe->trq_m;
+ tqe->trq_m = m;
+ goto present;
}
goto insert;
}
/* See where it fits. */
TAILQ_FOREACH(tqe, &tp->t_trq, trq_q) {
- /* Segment is after our coverage. */
+ /* Segment is after this blocks coverage. */
if (SEQ_LT(tqe->trq_seq + tqe->trq_len, th->th_seq))
continue;
- /* Segment is after the previous one but before us. */
+ /* Segment is after the previous one but before this one. */
if (SEQ_GT(tqe->trq_seq, th->th_seq + *tlenp))
- break;
+ break; /* Insert as new block. */
/* Segment is already fully covered. */
if (SEQ_LEQ(tqe->trq_seq, th->th_seq) &&
SEQ_GEQ(tqe->trq_seq + tqe->trq_len, th->th_seq + *tlenp)) {
@@ -242,25 +253,28 @@
*tlenp = 0;
return (0);
}
- /* Segment appends. */
+ /* Segment appends to this block. */
if (SEQ_LEQ(tqe->trq_seq + tqe->trq_len, th->th_seq)) {
- /* Trim head. */
+ /* Trim head of segment. */
if ((i = tqe->trq_seq + tqe->trq_len - th->th_seq)) {
m_adj(m, i);
*tlenp -= i;
+ /* tcpstat */
}
tqe->trq_len += *tlenp;
tqe->trq_segs += segs;
tqe->trq_ml->m_next = m;
tqe->trq_ml = m_last(m);
- /* Check for next block to merge. */
+ /* Check if segment bridges two blocks to merge. */
if ((tqen = TAILQ_NEXT(tqe, trq_q)) &&
SEQ_GEQ(tqe->trq_seq + tqe->trq_len, tqen->trq_seq)) {
- /* Trim head. */
+ /* Trim head of next block. */
+ /* XXXAO: Should trim tail of segment instead. */
if ((i = tqe->trq_seq + tqe->trq_len -
tqen->trq_seq)) {
m_adj(tqen->trq_m, i);
tqen->trq_len -= i;
+ /* tcpstat */
}
tqe->trq_len += tqen->trq_len;
tqe->trq_segs += tqen->trq_segs;
@@ -273,7 +287,7 @@
}
/* Segment prepends. */
if (SEQ_GT(tqe->trq_seq, th->th_seq)) {
- /* Trim tail. */
+ /* Trim tail of segment. */
if ((i = tqe->trq_seq - (th->th_seq + *tlenp))) {
m_adj(m, i);
*tlenp -= i;
@@ -287,9 +301,10 @@
}
tqe->trq_len += *tlenp;
tqe->trq_segs += segs;
- tqe->trq_m = m;
+ tqe->trq_seq = th->th_seq;
n = m_last(m);
n->m_next = tqe->trq_m;
+ tqe->trq_m = m;
return (0);
}
}
More information about the p4-projects
mailing list