nfsd4: set shorter timeout
[safe/jmp/linux-2.6] / net / dccp / input.c
index b1e38bf..7648f31 100644 (file)
@@ -159,15 +159,13 @@ static void dccp_rcv_reset(struct sock *sk, struct sk_buff *skb)
        dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
 }
 
-static void dccp_handle_ackvec_processing(struct sock *sk, struct sk_buff *skb)
+static void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb)
 {
-       struct dccp_ackvec *av = dccp_sk(sk)->dccps_hc_rx_ackvec;
+       struct dccp_sock *dp = dccp_sk(sk);
 
-       if (av == NULL)
-               return;
-       if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
-               dccp_ackvec_clear_state(av, DCCP_SKB_CB(skb)->dccpd_ack_seq);
-       dccp_ackvec_input(av, skb);
+       if (dp->dccps_hc_rx_ackvec != NULL)
+               dccp_ackvec_check_rcv_ackno(dp->dccps_hc_rx_ackvec, sk,
+                                           DCCP_SKB_CB(skb)->dccpd_ack_seq);
 }
 
 static void dccp_deliver_input_to_ccids(struct sock *sk, struct sk_buff *skb)
@@ -366,13 +364,22 @@ discard:
 int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
                         const struct dccp_hdr *dh, const unsigned len)
 {
+       struct dccp_sock *dp = dccp_sk(sk);
+
        if (dccp_check_seqno(sk, skb))
                goto discard;
 
        if (dccp_parse_options(sk, NULL, skb))
                return 1;
 
-       dccp_handle_ackvec_processing(sk, skb);
+       if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
+               dccp_event_ack_recv(sk, skb);
+
+       if (dp->dccps_hc_rx_ackvec != NULL &&
+           dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
+                           DCCP_SKB_CB(skb)->dccpd_seq,
+                           DCCP_ACKVEC_STATE_RECEIVED))
+               goto discard;
        dccp_deliver_input_to_ccids(sk, skb);
 
        return __dccp_rcv_established(sk, skb, dh, len);
@@ -433,14 +440,20 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
                kfree_skb(sk->sk_send_head);
                sk->sk_send_head = NULL;
 
+               dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
+               dccp_update_gsr(sk, dp->dccps_isr);
                /*
-                * Set ISR, GSR from packet. ISS was set in dccp_v{4,6}_connect
-                * and GSS in dccp_transmit_skb(). Setting AWL/AWH and SWL/SWH
-                * is done as part of activating the feature values below, since
-                * these settings depend on the local/remote Sequence Window
-                * features, which were undefined or not confirmed until now.
+                * SWL and AWL are initially adjusted so that they are not less than
+                * the initial Sequence Numbers received and sent, respectively:
+                *      SWL := max(GSR + 1 - floor(W/4), ISR),
+                *      AWL := max(GSS - W' + 1, ISS).
+                * These adjustments MUST be applied only at the beginning of the
+                * connection.
+                *
+                * AWL was adjusted in dccp_v4_connect -acme
                 */
-               dp->dccps_gsr = dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
+               dccp_set_seqno(&dp->dccps_swl,
+                              max48(dp->dccps_swl, dp->dccps_isr));
 
                dccp_sync_mss(sk, icsk->icsk_pmtu_cookie);
 
@@ -603,35 +616,29 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                /* Caller (dccp_v4_do_rcv) will send Reset */
                dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
                return 1;
-       } else if (sk->sk_state == DCCP_CLOSED) {
-               dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
-               return 1;
        }
 
-       /* Step 6: Check sequence numbers (omitted in LISTEN/REQUEST state) */
-       if (sk->sk_state != DCCP_REQUESTING && dccp_check_seqno(sk, skb))
-               goto discard;
+       if (sk->sk_state != DCCP_REQUESTING && sk->sk_state != DCCP_RESPOND) {
+               if (dccp_check_seqno(sk, skb))
+                       goto discard;
 
-       /*
-        *   Step 7: Check for unexpected packet types
-        *      If (S.is_server and P.type == Response)
-        *          or (S.is_client and P.type == Request)
-        *          or (S.state == RESPOND and P.type == Data),
-        *        Send Sync packet acknowledging P.seqno
-        *        Drop packet and return
-        */
-       if ((dp->dccps_role != DCCP_ROLE_CLIENT &&
-            dh->dccph_type == DCCP_PKT_RESPONSE) ||
-           (dp->dccps_role == DCCP_ROLE_CLIENT &&
-            dh->dccph_type == DCCP_PKT_REQUEST) ||
-           (sk->sk_state == DCCP_RESPOND && dh->dccph_type == DCCP_PKT_DATA)) {
-               dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC);
-               goto discard;
-       }
+               /*
+                * Step 8: Process options and mark acknowledgeable
+                */
+               if (dccp_parse_options(sk, NULL, skb))
+                       return 1;
 
-       /*  Step 8: Process options */
-       if (dccp_parse_options(sk, NULL, skb))
-               return 1;
+               if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
+                       dccp_event_ack_recv(sk, skb);
+
+               if (dp->dccps_hc_rx_ackvec != NULL &&
+                   dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
+                                   DCCP_SKB_CB(skb)->dccpd_seq,
+                                   DCCP_ACKVEC_STATE_RECEIVED))
+                       goto discard;
+
+               dccp_deliver_input_to_ccids(sk, skb);
+       }
 
        /*
         *  Step 9: Process Reset
@@ -640,21 +647,41 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
         *              S.state := TIMEWAIT
         *              Set TIMEWAIT timer
         *              Drop packet and return
-        */
+       */
        if (dh->dccph_type == DCCP_PKT_RESET) {
                dccp_rcv_reset(sk, skb);
                return 0;
-       } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) {       /* Step 13 */
+               /*
+                *   Step 7: Check for unexpected packet types
+                *      If (S.is_server and P.type == Response)
+                *          or (S.is_client and P.type == Request)
+                *          or (S.state == RESPOND and P.type == Data),
+                *        Send Sync packet acknowledging P.seqno
+                *        Drop packet and return
+                */
+       } else if ((dp->dccps_role != DCCP_ROLE_CLIENT &&
+                   dh->dccph_type == DCCP_PKT_RESPONSE) ||
+                   (dp->dccps_role == DCCP_ROLE_CLIENT &&
+                    dh->dccph_type == DCCP_PKT_REQUEST) ||
+                   (sk->sk_state == DCCP_RESPOND &&
+                    dh->dccph_type == DCCP_PKT_DATA)) {
+               dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC);
+               goto discard;
+       } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) {
                if (dccp_rcv_closereq(sk, skb))
                        return 0;
                goto discard;
-       } else if (dh->dccph_type == DCCP_PKT_CLOSE) {          /* Step 14 */
+       } else if (dh->dccph_type == DCCP_PKT_CLOSE) {
                if (dccp_rcv_close(sk, skb))
                        return 0;
                goto discard;
        }
 
        switch (sk->sk_state) {
+       case DCCP_CLOSED:
+               dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
+               return 1;
+
        case DCCP_REQUESTING:
                queued = dccp_rcv_request_sent_state_process(sk, skb, dh, len);
                if (queued >= 0)
@@ -663,12 +690,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                __kfree_skb(skb);
                return 0;
 
-       case DCCP_PARTOPEN:
-               /* Step 8: if using Ack Vectors, mark packet acknowledgeable */
-               dccp_handle_ackvec_processing(sk, skb);
-               dccp_deliver_input_to_ccids(sk, skb);
-               /* fall through */
        case DCCP_RESPOND:
+       case DCCP_PARTOPEN:
                queued = dccp_rcv_respond_partopen_state_process(sk, skb,
                                                                 dh, len);
                break;
@@ -718,5 +741,3 @@ u32 dccp_sample_rtt(struct sock *sk, long delta)
 
        return delta;
 }
-
-EXPORT_SYMBOL_GPL(dccp_sample_rtt);