| 2782 | } |
| 2783 | |
| 2784 | static void |
| 2785 | sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, |
| 2786 | struct sctp_tcb *stcb, struct sctp_nets *net) |
| 2787 | { |
| 2788 | /* cp must not be used, others call this without a c-ack :-) */ |
| 2789 | struct sctp_association *asoc; |
| 2790 | struct sctp_tmit_chunk *chk; |
| 2791 | |
| 2792 | SCTPDBG(SCTP_DEBUG_INPUT2, |
| 2793 | "sctp_handle_cookie_ack: handling COOKIE-ACK\n"); |
| 2794 | if ((stcb == NULL) || (net == NULL)) { |
| 2795 | return; |
| 2796 | } |
| 2797 | |
| 2798 | asoc = &stcb->asoc; |
| 2799 | if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { |
| 2800 | sctp_misc_ints(SCTP_THRESHOLD_CLEAR, |
| 2801 | asoc->overall_error_count, |
| 2802 | 0, |
| 2803 | SCTP_FROM_SCTP_INPUT, |
| 2804 | __LINE__); |
| 2805 | } |
| 2806 | asoc->overall_error_count = 0; |
| 2807 | sctp_stop_all_cookie_timers(stcb); |
| 2808 | /* process according to association state */ |
| 2809 | if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) { |
| 2810 | /* state change only needed when I am in right state */ |
| 2811 | SCTPDBG(SCTP_DEBUG_INPUT2, "moving to OPEN state\n"); |
| 2812 | SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); |
| 2813 | sctp_start_net_timers(stcb); |
| 2814 | if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { |
| 2815 | sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, |
| 2816 | stcb->sctp_ep, stcb, NULL); |
| 2817 | } |
| 2818 | /* update RTO */ |
| 2819 | SCTP_STAT_INCR_COUNTER32(sctps_activeestab); |
| 2820 | SCTP_STAT_INCR_GAUGE32(sctps_currestab); |
| 2821 | if (asoc->overall_error_count == 0) { |
| 2822 | sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered, |
| 2823 | SCTP_RTT_FROM_NON_DATA); |
| 2824 | } |
| 2825 | (void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered); |
| 2826 | sctp_ulp_notify(SCTP_NOTIFY_ASSOC_UP, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); |
| 2827 | if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || |
| 2828 | (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { |
| 2829 | stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; |
| 2830 | if ((stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) == 0) { |
| 2831 | soisconnected(stcb->sctp_socket); |
| 2832 | } |
| 2833 | } |
| 2834 | /* |
| 2835 | * since we did not send a HB make sure we don't double |
| 2836 | * things |
| 2837 | */ |
| 2838 | net->hb_responded = 1; |
| 2839 | |
| 2840 | if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) { |
| 2841 | /* |
no test coverage detected