Lines 1472-1500
tcp_autorcvbuf(struct mbuf *m, struct tcphdr *th, stru
Link Here
|
1472 |
} |
1472 |
} |
1473 |
|
1473 |
|
1474 |
void |
1474 |
void |
1475 |
tcp_handle_wakeup(struct tcpcb *tp, struct socket *so) |
|
|
1476 |
{ |
1477 |
/* |
1478 |
* Since tp might be gone if the session entered |
1479 |
* the TIME_WAIT state before coming here, we need |
1480 |
* to check if the socket is still connected. |
1481 |
*/ |
1482 |
if ((so->so_state & SS_ISCONNECTED) == 0) |
1483 |
return; |
1484 |
INP_LOCK_ASSERT(tp->t_inpcb); |
1485 |
if (tp->t_flags & TF_WAKESOR) { |
1486 |
tp->t_flags &= ~TF_WAKESOR; |
1487 |
SOCKBUF_UNLOCK_ASSERT(&so->so_rcv); |
1488 |
sorwakeup(so); |
1489 |
} |
1490 |
if (tp->t_flags & TF_WAKESOW) { |
1491 |
tp->t_flags &= ~TF_WAKESOW; |
1492 |
SOCKBUF_UNLOCK_ASSERT(&so->so_snd); |
1493 |
sowwakeup(so); |
1494 |
} |
1495 |
} |
1496 |
|
1497 |
void |
1498 |
tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, |
1475 |
tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, |
1499 |
struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos) |
1476 |
struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos) |
1500 |
{ |
1477 |
{ |
Lines 1863-1869
tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru
Link Here
|
1863 |
else if (!tcp_timer_active(tp, TT_PERSIST)) |
1840 |
else if (!tcp_timer_active(tp, TT_PERSIST)) |
1864 |
tcp_timer_activate(tp, TT_REXMT, |
1841 |
tcp_timer_activate(tp, TT_REXMT, |
1865 |
tp->t_rxtcur); |
1842 |
tp->t_rxtcur); |
1866 |
tp->t_flags |= TF_WAKESOW; |
1843 |
sowwakeup(so); |
1867 |
if (sbavail(&so->so_snd)) |
1844 |
if (sbavail(&so->so_snd)) |
1868 |
(void) tp->t_fb->tfb_tcp_output(tp); |
1845 |
(void) tp->t_fb->tfb_tcp_output(tp); |
1869 |
goto check_delack; |
1846 |
goto check_delack; |
Lines 1928-1935
tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru
Link Here
|
1928 |
m_adj(m, drop_hdrlen); /* delayed header drop */ |
1905 |
m_adj(m, drop_hdrlen); /* delayed header drop */ |
1929 |
sbappendstream_locked(&so->so_rcv, m, 0); |
1906 |
sbappendstream_locked(&so->so_rcv, m, 0); |
1930 |
} |
1907 |
} |
1931 |
SOCKBUF_UNLOCK(&so->so_rcv); |
1908 |
/* NB: sorwakeup_locked() does an implicit unlock. */ |
1932 |
tp->t_flags |= TF_WAKESOR; |
1909 |
sorwakeup_locked(so); |
1933 |
if (DELAY_ACK(tp, tlen)) { |
1910 |
if (DELAY_ACK(tp, tlen)) { |
1934 |
tp->t_flags |= TF_DELACK; |
1911 |
tp->t_flags |= TF_DELACK; |
1935 |
} else { |
1912 |
} else { |
Lines 2925-2932
process_ACK:
Link Here
|
2925 |
tp->snd_wnd = 0; |
2902 |
tp->snd_wnd = 0; |
2926 |
ourfinisacked = 0; |
2903 |
ourfinisacked = 0; |
2927 |
} |
2904 |
} |
2928 |
SOCKBUF_UNLOCK(&so->so_snd); |
2905 |
/* NB: sowwakeup_locked() does an implicit unlock. */ |
2929 |
tp->t_flags |= TF_WAKESOW; |
2906 |
sowwakeup_locked(so); |
2930 |
m_freem(mfree); |
2907 |
m_freem(mfree); |
2931 |
/* Detect una wraparound. */ |
2908 |
/* Detect una wraparound. */ |
2932 |
if (!IN_RECOVERY(tp->t_flags) && |
2909 |
if (!IN_RECOVERY(tp->t_flags) && |
Lines 3147-3154
dodata: /* XXX */
Link Here
|
3147 |
m_freem(m); |
3124 |
m_freem(m); |
3148 |
else |
3125 |
else |
3149 |
sbappendstream_locked(&so->so_rcv, m, 0); |
3126 |
sbappendstream_locked(&so->so_rcv, m, 0); |
3150 |
SOCKBUF_UNLOCK(&so->so_rcv); |
3127 |
/* NB: sorwakeup_locked() does an implicit unlock. */ |
3151 |
tp->t_flags |= TF_WAKESOR; |
3128 |
sorwakeup_locked(so); |
3152 |
} else { |
3129 |
} else { |
3153 |
/* |
3130 |
/* |
3154 |
* XXX: Due to the header drop above "th" is |
3131 |
* XXX: Due to the header drop above "th" is |
Lines 3215-3222
dodata: /* XXX */
Link Here
|
3215 |
if (thflags & TH_FIN) { |
3192 |
if (thflags & TH_FIN) { |
3216 |
if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { |
3193 |
if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { |
3217 |
socantrcvmore(so); |
3194 |
socantrcvmore(so); |
3218 |
/* The socket upcall is handled by socantrcvmore. */ |
|
|
3219 |
tp->t_flags &= ~TF_WAKESOR; |
3220 |
/* |
3195 |
/* |
3221 |
* If connection is half-synchronized |
3196 |
* If connection is half-synchronized |
3222 |
* (ie NEEDSYN flag on) then delay ACK, |
3197 |
* (ie NEEDSYN flag on) then delay ACK, |
Lines 3280-3286
check_delack:
Link Here
|
3280 |
tp->t_flags &= ~TF_DELACK; |
3255 |
tp->t_flags &= ~TF_DELACK; |
3281 |
tcp_timer_activate(tp, TT_DELACK, tcp_delacktime); |
3256 |
tcp_timer_activate(tp, TT_DELACK, tcp_delacktime); |
3282 |
} |
3257 |
} |
3283 |
tcp_handle_wakeup(tp, so); |
|
|
3284 |
INP_WUNLOCK(tp->t_inpcb); |
3258 |
INP_WUNLOCK(tp->t_inpcb); |
3285 |
return; |
3259 |
return; |
3286 |
|
3260 |
|
Lines 3314-3320
dropafterack:
Link Here
|
3314 |
TCP_PROBE3(debug__input, tp, th, m); |
3288 |
TCP_PROBE3(debug__input, tp, th, m); |
3315 |
tp->t_flags |= TF_ACKNOW; |
3289 |
tp->t_flags |= TF_ACKNOW; |
3316 |
(void) tp->t_fb->tfb_tcp_output(tp); |
3290 |
(void) tp->t_fb->tfb_tcp_output(tp); |
3317 |
tcp_handle_wakeup(tp, so); |
|
|
3318 |
INP_WUNLOCK(tp->t_inpcb); |
3291 |
INP_WUNLOCK(tp->t_inpcb); |
3319 |
m_freem(m); |
3292 |
m_freem(m); |
3320 |
return; |
3293 |
return; |
Lines 3322-3328
dropafterack:
Link Here
|
3322 |
dropwithreset: |
3295 |
dropwithreset: |
3323 |
if (tp != NULL) { |
3296 |
if (tp != NULL) { |
3324 |
tcp_dropwithreset(m, th, tp, tlen, rstreason); |
3297 |
tcp_dropwithreset(m, th, tp, tlen, rstreason); |
3325 |
tcp_handle_wakeup(tp, so); |
|
|
3326 |
INP_WUNLOCK(tp->t_inpcb); |
3298 |
INP_WUNLOCK(tp->t_inpcb); |
3327 |
} else |
3299 |
} else |
3328 |
tcp_dropwithreset(m, th, NULL, tlen, rstreason); |
3300 |
tcp_dropwithreset(m, th, NULL, tlen, rstreason); |
Lines 3338-3347
drop:
Link Here
|
3338 |
&tcp_savetcp, 0); |
3310 |
&tcp_savetcp, 0); |
3339 |
#endif |
3311 |
#endif |
3340 |
TCP_PROBE3(debug__input, tp, th, m); |
3312 |
TCP_PROBE3(debug__input, tp, th, m); |
3341 |
if (tp != NULL) { |
3313 |
if (tp != NULL) |
3342 |
tcp_handle_wakeup(tp, so); |
|
|
3343 |
INP_WUNLOCK(tp->t_inpcb); |
3314 |
INP_WUNLOCK(tp->t_inpcb); |
3344 |
} |
|
|
3345 |
m_freem(m); |
3315 |
m_freem(m); |
3346 |
} |
3316 |
} |
3347 |
|
3317 |
|