Changeset 32aea9f4 in mainline


Ignore:
Timestamp:
2011-10-23T02:23:46Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f343a16
Parents:
8c7a054
Message:

Sort incoming segments by sequence order.

Location:
uspace/srv/net/tl/tcp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/iqueue.c

    r8c7a054 r32aea9f4  
    6565{
    6666        tcp_iqueue_entry_t *iqe;
     67        tcp_iqueue_entry_t *qe;
     68        link_t *link;
    6769        log_msg(LVL_DEBUG, "tcp_iqueue_insert_seg()");
    6870
     
    7577        iqe->seg = seg;
    7678
    77         /* XXX Sort by sequence number */
    78         list_append(&iqe->link, &iqueue->list);
     79        /* Sort by sequence number */
     80
     81        link = list_first(&iqueue->list);
     82        while (link != NULL) {
     83                qe = list_get_instance(link,
     84                    tcp_iqueue_entry_t, link);
     85
     86                if (seq_no_seg_cmp(iqueue->conn, iqe->seg, qe->seg) >= 0)
     87                        break;
     88        }
     89
     90        if (link != NULL)
     91                list_insert_before(&iqe->link, &qe->link);
     92        else
     93                list_append(&iqe->link, &iqueue->list);
    7994}
    8095
  • uspace/srv/net/tl/tcp/seq_no.c

    r8c7a054 r32aea9f4  
    178178
    179179/** Calculate the amount of trim needed to fit segment in receive window. */
    180 extern void seq_no_seg_trim_calc(tcp_conn_t *conn, tcp_segment_t *seg,
     180void seq_no_seg_trim_calc(tcp_conn_t *conn, tcp_segment_t *seg,
    181181    uint32_t *left, uint32_t *right)
    182182{
     
    207207}
    208208
     209/** Segment order comparison.
     210 *
     211 * Compare sequence order of two acceptable segments.
     212 *
     213 * @param conn          Connection
     214 * @param sa            Segment A
     215 * @param sb            Segment B
     216 *
     217 * @return              -1, 0, 1, resp. if A < B, A == B, A > B in terms
     218 *                      of sequence order of the beginning of the segment.
     219 */
     220int seq_no_seg_cmp(tcp_conn_t *conn, tcp_segment_t *sa, tcp_segment_t *sb)
     221{
     222        assert(seq_no_segment_acceptable(conn, sa));
     223        assert(seq_no_segment_acceptable(conn, sb));
     224
     225        if (seq_no_lt_le(sa->seq, sb->seq, conn->rcv_nxt + conn->rcv_wnd))
     226                return -1;
     227
     228        if (seq_no_lt_le(sb->seq, sa->seq, conn->rcv_nxt + conn->rcv_wnd))
     229                return +1;
     230
     231        assert(sa->seq == sb->seq);
     232        return 0;
     233}
     234
    209235/**
    210236 * @}
  • uspace/srv/net/tl/tcp/seq_no.h

    r8c7a054 r32aea9f4  
    4848extern void seq_no_seg_trim_calc(tcp_conn_t *, tcp_segment_t *, uint32_t *,
    4949    uint32_t *);
     50extern int seq_no_seg_cmp(tcp_conn_t *, tcp_segment_t *, tcp_segment_t *);
    5051
    5152extern uint32_t seq_no_control_len(tcp_control_t);
Note: See TracChangeset for help on using the changeset viewer.