tcp_reass.c (131079) | tcp_reass.c (131151) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95 | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95 |
30 * $FreeBSD: head/sys/netinet/tcp_reass.c 131079 2004-06-25 04:11:26Z ps $ | 30 * $FreeBSD: head/sys/netinet/tcp_reass.c 131151 2004-06-26 19:10:39Z rwatson $ |
31 */ 32 33#include "opt_ipfw.h" /* for ipfw_fwd */ 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_ipsec.h" 37#include "opt_mac.h" 38#include "opt_tcpdebug.h" --- 309 unchanged lines hidden (view full) --- 348 * Present data to user, advancing rcv_nxt through 349 * completed sequence space. 350 */ 351 if (!TCPS_HAVEESTABLISHED(tp->t_state)) 352 return (0); 353 q = LIST_FIRST(&tp->t_segq); 354 if (!q || q->tqe_th->th_seq != tp->rcv_nxt) 355 return (0); | 31 */ 32 33#include "opt_ipfw.h" /* for ipfw_fwd */ 34#include "opt_inet.h" 35#include "opt_inet6.h" 36#include "opt_ipsec.h" 37#include "opt_mac.h" 38#include "opt_tcpdebug.h" --- 309 unchanged lines hidden (view full) --- 348 * Present data to user, advancing rcv_nxt through 349 * completed sequence space. 350 */ 351 if (!TCPS_HAVEESTABLISHED(tp->t_state)) 352 return (0); 353 q = LIST_FIRST(&tp->t_segq); 354 if (!q || q->tqe_th->th_seq != tp->rcv_nxt) 355 return (0); |
356 SOCKBUF_LOCK(&so->so_rcv); |
|
356 do { 357 tp->rcv_nxt += q->tqe_len; 358 flags = q->tqe_th->th_flags & TH_FIN; 359 nq = LIST_NEXT(q, tqe_q); 360 LIST_REMOVE(q, tqe_q); | 357 do { 358 tp->rcv_nxt += q->tqe_len; 359 flags = q->tqe_th->th_flags & TH_FIN; 360 nq = LIST_NEXT(q, tqe_q); 361 LIST_REMOVE(q, tqe_q); |
362 /* Unlocked read. */ |
|
361 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) 362 m_freem(q->tqe_m); 363 else | 363 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) 364 m_freem(q->tqe_m); 365 else |
364 sbappendstream(&so->so_rcv, q->tqe_m); | 366 sbappendstream_locked(&so->so_rcv, q->tqe_m); |
365 uma_zfree(tcp_reass_zone, q); 366 tp->t_segqlen--; 367 tcp_reass_qsize--; 368 q = nq; 369 } while (q && q->tqe_th->th_seq == tp->rcv_nxt); 370 ND6_HINT(tp); | 367 uma_zfree(tcp_reass_zone, q); 368 tp->t_segqlen--; 369 tcp_reass_qsize--; 370 q = nq; 371 } while (q && q->tqe_th->th_seq == tp->rcv_nxt); 372 ND6_HINT(tp); |
371 sorwakeup(so); | 373 sorwakeup_locked(so); |
372 return (flags); 373} 374 375/* 376 * TCP input routine, follows pages 65-76 of the 377 * protocol specification dated September, 1981 very closely. 378 */ 379#ifdef INET6 --- 877 unchanged lines hidden (view full) --- 1257 /* 1258#ifdef TCPDEBUG 1259 if (so->so_options & SO_DEBUG) 1260 tcp_trace(TA_INPUT, ostate, tp, 1261 (void *)tcp_saveipgen, &tcp_savetcp, 0); 1262#endif 1263 * Add data to socket buffer. 1264 */ | 374 return (flags); 375} 376 377/* 378 * TCP input routine, follows pages 65-76 of the 379 * protocol specification dated September, 1981 very closely. 380 */ 381#ifdef INET6 --- 877 unchanged lines hidden (view full) --- 1259 /* 1260#ifdef TCPDEBUG 1261 if (so->so_options & SO_DEBUG) 1262 tcp_trace(TA_INPUT, ostate, tp, 1263 (void *)tcp_saveipgen, &tcp_savetcp, 0); 1264#endif 1265 * Add data to socket buffer. 1266 */ |
1267 /* Unlocked read. */ 1268 SOCKBUF_LOCK(&so->so_rcv); |
|
1265 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { 1266 m_freem(m); 1267 } else { 1268 m_adj(m, drop_hdrlen); /* delayed header drop */ | 1269 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { 1270 m_freem(m); 1271 } else { 1272 m_adj(m, drop_hdrlen); /* delayed header drop */ |
1269 sbappendstream(&so->so_rcv, m); | 1273 sbappendstream_locked(&so->so_rcv, m); |
1270 } | 1274 } |
1271 sorwakeup(so); | 1275 sorwakeup_locked(so); |
1272 if (DELAY_ACK(tp)) { 1273 tp->t_flags |= TF_DELACK; 1274 } else { 1275 tp->t_flags |= TF_ACKNOW; 1276 tcp_output(tp); 1277 } 1278 goto check_delack; 1279 } --- 868 unchanged lines hidden (view full) --- 2148 tp->snd_wnd -= so->so_snd.sb_cc; 2149 sbdrop_locked(&so->so_snd, (int)so->so_snd.sb_cc); 2150 ourfinisacked = 1; 2151 } else { 2152 sbdrop_locked(&so->so_snd, acked); 2153 tp->snd_wnd -= acked; 2154 ourfinisacked = 0; 2155 } | 1276 if (DELAY_ACK(tp)) { 1277 tp->t_flags |= TF_DELACK; 1278 } else { 1279 tp->t_flags |= TF_ACKNOW; 1280 tcp_output(tp); 1281 } 1282 goto check_delack; 1283 } --- 868 unchanged lines hidden (view full) --- 2152 tp->snd_wnd -= so->so_snd.sb_cc; 2153 sbdrop_locked(&so->so_snd, (int)so->so_snd.sb_cc); 2154 ourfinisacked = 1; 2155 } else { 2156 sbdrop_locked(&so->so_snd, acked); 2157 tp->snd_wnd -= acked; 2158 ourfinisacked = 0; 2159 } |
2156 SOCKBUF_UNLOCK(&so->so_snd); 2157 sowwakeup(so); | 2160 sowwakeup_locked(so); |
2158 /* detect una wraparound */ 2159 if ((tcp_do_newreno || tp->sack_enable) && 2160 !IN_FASTRECOVERY(tp) && 2161 SEQ_GT(tp->snd_una, tp->snd_recover) && 2162 SEQ_LEQ(th->th_ack, tp->snd_recover)) 2163 tp->snd_recover = th->th_ack - 1; 2164 if ((tcp_do_newreno || tp->sack_enable) && 2165 IN_FASTRECOVERY(tp) && --- 192 unchanged lines hidden (view full) --- 2358 tp->t_flags |= TF_DELACK; 2359 else 2360 tp->t_flags |= TF_ACKNOW; 2361 tp->rcv_nxt += tlen; 2362 thflags = th->th_flags & TH_FIN; 2363 tcpstat.tcps_rcvpack++; 2364 tcpstat.tcps_rcvbyte += tlen; 2365 ND6_HINT(tp); | 2161 /* detect una wraparound */ 2162 if ((tcp_do_newreno || tp->sack_enable) && 2163 !IN_FASTRECOVERY(tp) && 2164 SEQ_GT(tp->snd_una, tp->snd_recover) && 2165 SEQ_LEQ(th->th_ack, tp->snd_recover)) 2166 tp->snd_recover = th->th_ack - 1; 2167 if ((tcp_do_newreno || tp->sack_enable) && 2168 IN_FASTRECOVERY(tp) && --- 192 unchanged lines hidden (view full) --- 2361 tp->t_flags |= TF_DELACK; 2362 else 2363 tp->t_flags |= TF_ACKNOW; 2364 tp->rcv_nxt += tlen; 2365 thflags = th->th_flags & TH_FIN; 2366 tcpstat.tcps_rcvpack++; 2367 tcpstat.tcps_rcvbyte += tlen; 2368 ND6_HINT(tp); |
2369 /* Unlocked read. */ 2370 SOCKBUF_LOCK(&so->so_rcv); |
|
2366 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) 2367 m_freem(m); 2368 else | 2371 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) 2372 m_freem(m); 2373 else |
2369 sbappendstream(&so->so_rcv, m); 2370 sorwakeup(so); | 2374 sbappendstream_locked(&so->so_rcv, m); 2375 sorwakeup_locked(so); |
2371 } else { 2372 thflags = tcp_reass(tp, th, &tlen, m); 2373 tp->t_flags |= TF_ACKNOW; 2374 } 2375 if (tp->sack_enable) 2376 tcp_update_sack_list(tp); 2377 /* 2378 * Note the amount of data that peer has sent into --- 937 unchanged lines hidden --- | 2376 } else { 2377 thflags = tcp_reass(tp, th, &tlen, m); 2378 tp->t_flags |= TF_ACKNOW; 2379 } 2380 if (tp->sack_enable) 2381 tcp_update_sack_list(tp); 2382 /* 2383 * Note the amount of data that peer has sent into --- 937 unchanged lines hidden --- |