~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to slirp/tcp_input.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-22 10:13:17 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090322101317-iigjtnu5qil35dtb
Tags: 0.10.1-1
[ Aurelien Jarno ]
* New upstream stable release:
  - patches/80_stable-branch.patch: remove.
* debian/control: 
  - Remove depends on proll.
  - Move depends on device-tree-compiler to build-depends.
  - Bump Standards-Version to 3.8.1 (no changes).
* patches/82_qemu-img_decimal.patch: new patch from upstream to make
  qemu-img accept sizes with decimal values (closes: bug#501400).

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
11
 *    notice, this list of conditions and the following disclaimer in the
12
12
 *    documentation and/or other materials provided with the distribution.
13
 
 * 3. All advertising materials mentioning features or use of this software
14
 
 *    must display the following acknowledgement:
15
 
 *      This product includes software developed by the University of
16
 
 *      California, Berkeley and its contributors.
17
 
 * 4. Neither the name of the University nor the names of its contributors
 
13
 * 3. Neither the name of the University nor the names of its contributors
18
14
 *    may be used to endorse or promote products derived from this software
19
15
 *    without specific prior written permission.
20
16
 *
71
67
#ifdef TCP_ACK_HACK
72
68
#define TCP_REASS(tp, ti, m, so, flags) {\
73
69
       if ((ti)->ti_seq == (tp)->rcv_nxt && \
74
 
           (tp)->seg_next == (tcpiphdrp_32)(tp) && \
 
70
           tcpfrag_list_empty(tp) && \
75
71
           (tp)->t_state == TCPS_ESTABLISHED) {\
76
72
               if (ti->ti_flags & TH_PUSH) \
77
73
                       tp->t_flags |= TF_ACKNOW; \
94
90
#else
95
91
#define TCP_REASS(tp, ti, m, so, flags) { \
96
92
        if ((ti)->ti_seq == (tp)->rcv_nxt && \
97
 
            (tp)->seg_next == (tcpiphdrp_32)(tp) && \
 
93
        tcpfrag_list_empty(tp) && \
98
94
            (tp)->t_state == TCPS_ESTABLISHED) { \
99
95
                tp->t_flags |= TF_DELACK; \
100
96
                (tp)->rcv_nxt += (ti)->ti_len; \
134
130
        /*
135
131
         * Find a segment which begins after this one does.
136
132
         */
137
 
        for (q = (struct tcpiphdr *)tp->seg_next; q != (struct tcpiphdr *)tp;
138
 
            q = (struct tcpiphdr *)q->ti_next)
 
133
        for (q = tcpfrag_list_first(tp); !tcpfrag_list_end(q, tp);
 
134
            q = tcpiphdr_next(q))
139
135
                if (SEQ_GT(q->ti_seq, ti->ti_seq))
140
136
                        break;
141
137
 
144
140
         * our data already.  If so, drop the data from the incoming
145
141
         * segment.  If it provides all of our data, drop us.
146
142
         */
147
 
        if ((struct tcpiphdr *)q->ti_prev != (struct tcpiphdr *)tp) {
 
143
        if (!tcpfrag_list_end(tcpiphdr_prev(q), tp)) {
148
144
                register int i;
149
 
                q = (struct tcpiphdr *)q->ti_prev;
 
145
                q = tcpiphdr_prev(q);
150
146
                /* conversion to int (in i) handles seq wraparound */
151
147
                i = q->ti_seq + q->ti_len - ti->ti_seq;
152
148
                if (i > 0) {
166
162
                        ti->ti_len -= i;
167
163
                        ti->ti_seq += i;
168
164
                }
169
 
                q = (struct tcpiphdr *)(q->ti_next);
 
165
                q = tcpiphdr_next(q);
170
166
        }
171
167
        STAT(tcpstat.tcps_rcvoopack++);
172
168
        STAT(tcpstat.tcps_rcvoobyte += ti->ti_len);
173
 
        REASS_MBUF(ti) = (mbufp_32) m;          /* XXX */
 
169
        ti->ti_mbuf = m;
174
170
 
175
171
        /*
176
172
         * While we overlap succeeding segments trim them or,
177
173
         * if they are completely covered, dequeue them.
178
174
         */
179
 
        while (q != (struct tcpiphdr *)tp) {
 
175
        while (!tcpfrag_list_end(q, tp)) {
180
176
                register int i = (ti->ti_seq + ti->ti_len) - q->ti_seq;
181
177
                if (i <= 0)
182
178
                        break;
183
179
                if (i < q->ti_len) {
184
180
                        q->ti_seq += i;
185
181
                        q->ti_len -= i;
186
 
                        m_adj((struct mbuf *) REASS_MBUF(q), i);
 
182
                        m_adj(q->ti_mbuf, i);
187
183
                        break;
188
184
                }
189
 
                q = (struct tcpiphdr *)q->ti_next;
190
 
                m = (struct mbuf *) REASS_MBUF((struct tcpiphdr *)q->ti_prev);
191
 
                remque_32((void *)(q->ti_prev));
 
185
                q = tcpiphdr_next(q);
 
186
                m = tcpiphdr_prev(q)->ti_mbuf;
 
187
                remque(tcpiphdr2qlink(tcpiphdr_prev(q)));
192
188
                m_freem(m);
193
189
        }
194
190
 
195
191
        /*
196
192
         * Stick new segment in its place.
197
193
         */
198
 
        insque_32(ti, (void *)(q->ti_prev));
 
194
        insque(tcpiphdr2qlink(ti), tcpiphdr2qlink(tcpiphdr_prev(q)));
199
195
 
200
196
present:
201
197
        /*
204
200
         */
205
201
        if (!TCPS_HAVEESTABLISHED(tp->t_state))
206
202
                return (0);
207
 
        ti = (struct tcpiphdr *) tp->seg_next;
208
 
        if (ti == (struct tcpiphdr *)tp || ti->ti_seq != tp->rcv_nxt)
 
203
        ti = tcpfrag_list_first(tp);
 
204
        if (tcpfrag_list_end(ti, tp) || ti->ti_seq != tp->rcv_nxt)
209
205
                return (0);
210
206
        if (tp->t_state == TCPS_SYN_RECEIVED && ti->ti_len)
211
207
                return (0);
212
208
        do {
213
209
                tp->rcv_nxt += ti->ti_len;
214
210
                flags = ti->ti_flags & TH_FIN;
215
 
                remque_32(ti);
216
 
                m = (struct mbuf *) REASS_MBUF(ti); /* XXX */
217
 
                ti = (struct tcpiphdr *)ti->ti_next;
 
211
                remque(tcpiphdr2qlink(ti));
 
212
                m = ti->ti_mbuf;
 
213
                ti = tcpiphdr_next(ti);
218
214
/*              if (so->so_state & SS_FCANTRCVMORE) */
219
215
                if (so->so_state & SS_FCANTSENDMORE)
220
216
                        m_freem(m);
253
249
        u_long tiwin;
254
250
        int ret;
255
251
/*      int ts_present = 0; */
 
252
    struct ex_list *ex_ptr;
256
253
 
257
254
        DEBUG_CALL("tcp_input");
258
255
        DEBUG_ARGS((dfd," m = %8lx  iphlen = %2d  inso = %lx\n",
301
298
         * Checksum extended TCP header and data.
302
299
         */
303
300
        tlen = ((struct ip *)ti)->ip_len;
304
 
        ti->ti_next = ti->ti_prev = 0;
 
301
        tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = 0;
 
302
    memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));
305
303
        ti->ti_x1 = 0;
306
304
        ti->ti_len = htons((u_int16_t)tlen);
307
305
        len = sizeof(struct ip ) + tlen;
363
361
        m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
364
362
        m->m_len  -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
365
363
 
 
364
    if (slirp_restrict) {
 
365
        for (ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next)
 
366
            if (ex_ptr->ex_fport == ti->ti_dport &&
 
367
                    (ntohl(ti->ti_dst.s_addr) & 0xff) == ex_ptr->ex_addr)
 
368
                break;
 
369
 
 
370
        if (!ex_ptr)
 
371
            goto drop;
 
372
    }
366
373
        /*
367
374
         * Locate pcb for segment.
368
375
         */
550
557
                                return;
551
558
                        }
552
559
                } else if (ti->ti_ack == tp->snd_una &&
553
 
                    tp->seg_next == (tcpiphdrp_32)tp &&
 
560
                    tcpfrag_list_empty(tp) &&
554
561
                    ti->ti_len <= sbspace(&so->so_rcv)) {
555
562
                        /*
556
563
                         * this is a pure, in-sequence data packet
646
653
#endif
647
654
              {
648
655
                /* May be an add exec */
649
 
                struct ex_list *ex_ptr;
650
656
                for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
651
657
                  if(ex_ptr->ex_fport == so->so_fport &&
652
658
                     lastbyte == ex_ptr->ex_addr) {