Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * net/dccp/input.c |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 3 | * |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 4 | * An implementation of the DCCP protocol |
| 5 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | */ |
| 12 | |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 13 | #include <linux/dccp.h> |
| 14 | #include <linux/skbuff.h> |
| 15 | |
| 16 | #include <net/sock.h> |
| 17 | |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 18 | #include "ackvec.h" |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 19 | #include "ccid.h" |
| 20 | #include "dccp.h" |
| 21 | |
| 22 | static void dccp_fin(struct sock *sk, struct sk_buff *skb) |
| 23 | { |
| 24 | sk->sk_shutdown |= RCV_SHUTDOWN; |
| 25 | sock_set_flag(sk, SOCK_DONE); |
| 26 | __skb_pull(skb, dccp_hdr(skb)->dccph_doff * 4); |
| 27 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
| 28 | skb_set_owner_r(skb, sk); |
| 29 | sk->sk_data_ready(sk, 0); |
| 30 | } |
| 31 | |
| 32 | static void dccp_rcv_close(struct sock *sk, struct sk_buff *skb) |
| 33 | { |
Arnaldo Carvalho de Melo | 017487d | 2006-03-20 19:25:24 -0800 | [diff] [blame] | 34 | dccp_send_reset(sk, DCCP_RESET_CODE_CLOSED); |
Arnaldo Carvalho de Melo | 7ad07e7 | 2005-08-23 21:50:06 -0700 | [diff] [blame] | 35 | dccp_fin(sk, skb); |
| 36 | dccp_set_state(sk, DCCP_CLOSED); |
Arnaldo Carvalho de Melo | 331968b | 2005-08-23 21:54:23 -0700 | [diff] [blame] | 37 | sk_wake_async(sk, 1, POLL_HUP); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | static void dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb) |
| 41 | { |
| 42 | /* |
| 43 | * Step 7: Check for unexpected packet types |
| 44 | * If (S.is_server and P.type == CloseReq) |
| 45 | * Send Sync packet acknowledging P.seqno |
| 46 | * Drop packet and return |
| 47 | */ |
| 48 | if (dccp_sk(sk)->dccps_role != DCCP_ROLE_CLIENT) { |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 49 | dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_PKT_SYNC); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 50 | return; |
| 51 | } |
| 52 | |
Arnaldo Carvalho de Melo | 811265b | 2005-09-13 19:03:15 -0300 | [diff] [blame] | 53 | if (sk->sk_state != DCCP_CLOSING) |
| 54 | dccp_set_state(sk, DCCP_CLOSING); |
Arnaldo Carvalho de Melo | 7ad07e7 | 2005-08-23 21:50:06 -0700 | [diff] [blame] | 55 | dccp_send_close(sk, 0); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Arnaldo Carvalho de Melo | c25a18b | 2006-03-20 21:58:56 -0800 | [diff] [blame] | 58 | static void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb) |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 59 | { |
| 60 | struct dccp_sock *dp = dccp_sk(sk); |
| 61 | |
Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 62 | if (dccp_msk(sk)->dccpms_send_ack_vector) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 63 | dccp_ackvec_check_rcv_ackno(dp->dccps_hc_rx_ackvec, sk, |
| 64 | DCCP_SKB_CB(skb)->dccpd_ack_seq); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) |
| 68 | { |
| 69 | const struct dccp_hdr *dh = dccp_hdr(skb); |
| 70 | struct dccp_sock *dp = dccp_sk(sk); |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 71 | u64 lswl, lawl, seqno = DCCP_SKB_CB(skb)->dccpd_seq, |
| 72 | ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 73 | |
| 74 | /* |
| 75 | * Step 5: Prepare sequence numbers for Sync |
| 76 | * If P.type == Sync or P.type == SyncAck, |
| 77 | * If S.AWL <= P.ackno <= S.AWH and P.seqno >= S.SWL, |
| 78 | * / * P is valid, so update sequence number variables |
| 79 | * accordingly. After this update, P will pass the tests |
| 80 | * in Step 6. A SyncAck is generated if necessary in |
| 81 | * Step 15 * / |
| 82 | * Update S.GSR, S.SWL, S.SWH |
| 83 | * Otherwise, |
| 84 | * Drop packet and return |
| 85 | */ |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 86 | if (dh->dccph_type == DCCP_PKT_SYNC || |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 87 | dh->dccph_type == DCCP_PKT_SYNCACK) { |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 88 | if (between48(ackno, dp->dccps_awl, dp->dccps_awh) && |
| 89 | dccp_delta_seqno(dp->dccps_swl, seqno) >= 0) |
| 90 | dccp_update_gsr(sk, seqno); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 91 | else |
| 92 | return -1; |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 93 | } |
YOSHIFUJI Hideaki | c9eaf17 | 2007-02-09 23:24:38 +0900 | [diff] [blame] | 94 | |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 95 | /* |
| 96 | * Step 6: Check sequence numbers |
| 97 | * Let LSWL = S.SWL and LAWL = S.AWL |
| 98 | * If P.type == CloseReq or P.type == Close or P.type == Reset, |
| 99 | * LSWL := S.GSR + 1, LAWL := S.GAR |
| 100 | * If LSWL <= P.seqno <= S.SWH |
| 101 | * and (P.ackno does not exist or LAWL <= P.ackno <= S.AWH), |
| 102 | * Update S.GSR, S.SWL, S.SWH |
| 103 | * If P.type != Sync, |
| 104 | * Update S.GAR |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 105 | */ |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 106 | lswl = dp->dccps_swl; |
| 107 | lawl = dp->dccps_awl; |
| 108 | |
| 109 | if (dh->dccph_type == DCCP_PKT_CLOSEREQ || |
Arnaldo Carvalho de Melo | c59eab4 | 2005-08-18 21:12:02 -0300 | [diff] [blame] | 110 | dh->dccph_type == DCCP_PKT_CLOSE || |
| 111 | dh->dccph_type == DCCP_PKT_RESET) { |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 112 | lswl = ADD48(dp->dccps_gsr, 1); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 113 | lawl = dp->dccps_gar; |
| 114 | } |
| 115 | |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 116 | if (between48(seqno, lswl, dp->dccps_swh) && |
| 117 | (ackno == DCCP_PKT_WITHOUT_ACK_SEQ || |
| 118 | between48(ackno, lawl, dp->dccps_awh))) { |
| 119 | dccp_update_gsr(sk, seqno); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 120 | |
| 121 | if (dh->dccph_type != DCCP_PKT_SYNC && |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 122 | (ackno != DCCP_PKT_WITHOUT_ACK_SEQ)) |
| 123 | dp->dccps_gar = ackno; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 124 | } else { |
Gerrit Renker | a94f0f9 | 2007-09-26 11:31:49 -0300 | [diff] [blame] | 125 | unsigned long now = jiffies; |
| 126 | /* |
| 127 | * Step 6: Check sequence numbers |
| 128 | * Otherwise, |
| 129 | * If P.type == Reset, |
| 130 | * Send Sync packet acknowledging S.GSR |
| 131 | * Otherwise, |
| 132 | * Send Sync packet acknowledging P.seqno |
| 133 | * Drop packet and return |
| 134 | * |
| 135 | * These Syncs are rate-limited as per RFC 4340, 7.5.4: |
| 136 | * at most 1 / (dccp_sync_rate_limit * HZ) Syncs per second. |
| 137 | */ |
| 138 | if (time_before(now, (dp->dccps_rate_last + |
| 139 | sysctl_dccp_sync_ratelimit))) |
| 140 | return 0; |
| 141 | |
Gerrit Renker | 59348b1 | 2006-11-20 18:39:23 -0200 | [diff] [blame] | 142 | DCCP_WARN("DCCP: Step 6 failed for %s packet, " |
| 143 | "(LSWL(%llu) <= P.seqno(%llu) <= S.SWH(%llu)) and " |
| 144 | "(P.ackno %s or LAWL(%llu) <= P.ackno(%llu) <= S.AWH(%llu), " |
| 145 | "sending SYNC...\n", dccp_packet_name(dh->dccph_type), |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 146 | (unsigned long long) lswl, (unsigned long long) seqno, |
Gerrit Renker | 59348b1 | 2006-11-20 18:39:23 -0200 | [diff] [blame] | 147 | (unsigned long long) dp->dccps_swh, |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 148 | (ackno == DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist" |
| 149 | : "exists", |
| 150 | (unsigned long long) lawl, (unsigned long long) ackno, |
Gerrit Renker | 59348b1 | 2006-11-20 18:39:23 -0200 | [diff] [blame] | 151 | (unsigned long long) dp->dccps_awh); |
Gerrit Renker | a94f0f9 | 2007-09-26 11:31:49 -0300 | [diff] [blame] | 152 | |
| 153 | dp->dccps_rate_last = now; |
| 154 | |
Gerrit Renker | e155d76 | 2007-09-25 22:41:56 -0700 | [diff] [blame] | 155 | if (dh->dccph_type == DCCP_PKT_RESET) |
| 156 | seqno = dp->dccps_gsr; |
Gerrit Renker | cbe1f5f | 2007-09-25 22:41:19 -0700 | [diff] [blame] | 157 | dccp_send_sync(sk, seqno, DCCP_PKT_SYNC); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 158 | return -1; |
| 159 | } |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
Arnaldo Carvalho de Melo | c25a18b | 2006-03-20 21:58:56 -0800 | [diff] [blame] | 164 | static int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb, |
| 165 | const struct dccp_hdr *dh, const unsigned len) |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 166 | { |
| 167 | struct dccp_sock *dp = dccp_sk(sk); |
| 168 | |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 169 | switch (dccp_hdr(skb)->dccph_type) { |
| 170 | case DCCP_PKT_DATAACK: |
| 171 | case DCCP_PKT_DATA: |
| 172 | /* |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 173 | * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED |
| 174 | * option if it is. |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 175 | */ |
| 176 | __skb_pull(skb, dh->dccph_doff * 4); |
| 177 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
| 178 | skb_set_owner_r(skb, sk); |
| 179 | sk->sk_data_ready(sk, 0); |
| 180 | return 0; |
| 181 | case DCCP_PKT_ACK: |
| 182 | goto discard; |
| 183 | case DCCP_PKT_RESET: |
| 184 | /* |
| 185 | * Step 9: Process Reset |
| 186 | * If P.type == Reset, |
| 187 | * Tear down connection |
| 188 | * S.state := TIMEWAIT |
| 189 | * Set TIMEWAIT timer |
| 190 | * Drop packet and return |
| 191 | */ |
| 192 | dccp_fin(sk, skb); |
| 193 | dccp_time_wait(sk, DCCP_TIME_WAIT, 0); |
| 194 | return 0; |
| 195 | case DCCP_PKT_CLOSEREQ: |
| 196 | dccp_rcv_closereq(sk, skb); |
| 197 | goto discard; |
| 198 | case DCCP_PKT_CLOSE: |
| 199 | dccp_rcv_close(sk, skb); |
| 200 | return 0; |
| 201 | case DCCP_PKT_REQUEST: |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 202 | /* Step 7 |
| 203 | * or (S.is_server and P.type == Response) |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 204 | * or (S.is_client and P.type == Request) |
| 205 | * or (S.state >= OPEN and P.type == Request |
| 206 | * and P.seqno >= S.OSR) |
| 207 | * or (S.state >= OPEN and P.type == Response |
| 208 | * and P.seqno >= S.OSR) |
| 209 | * or (S.state == RESPOND and P.type == Data), |
| 210 | * Send Sync packet acknowledging P.seqno |
| 211 | * Drop packet and return |
| 212 | */ |
| 213 | if (dp->dccps_role != DCCP_ROLE_LISTEN) |
| 214 | goto send_sync; |
| 215 | goto check_seq; |
| 216 | case DCCP_PKT_RESPONSE: |
| 217 | if (dp->dccps_role != DCCP_ROLE_CLIENT) |
| 218 | goto send_sync; |
| 219 | check_seq: |
Gerrit Renker | 8d13bf9 | 2007-03-20 13:08:19 -0300 | [diff] [blame] | 220 | if (dccp_delta_seqno(dp->dccps_osr, |
| 221 | DCCP_SKB_CB(skb)->dccpd_seq) >= 0) { |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 222 | send_sync: |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 223 | dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, |
| 224 | DCCP_PKT_SYNC); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 225 | } |
| 226 | break; |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 227 | case DCCP_PKT_SYNC: |
| 228 | dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, |
| 229 | DCCP_PKT_SYNCACK); |
| 230 | /* |
Gerrit Renker | 0e64e94 | 2006-10-24 16:17:51 -0700 | [diff] [blame] | 231 | * From RFC 4340, sec. 5.7 |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 232 | * |
| 233 | * As with DCCP-Ack packets, DCCP-Sync and DCCP-SyncAck packets |
| 234 | * MAY have non-zero-length application data areas, whose |
Gerrit Renker | 0e64e94 | 2006-10-24 16:17:51 -0700 | [diff] [blame] | 235 | * contents receivers MUST ignore. |
Arnaldo Carvalho de Melo | e92ae93 | 2005-08-17 03:10:59 -0300 | [diff] [blame] | 236 | */ |
| 237 | goto discard; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | DCCP_INC_STATS_BH(DCCP_MIB_INERRS); |
| 241 | discard: |
| 242 | __kfree_skb(skb); |
| 243 | return 0; |
| 244 | } |
| 245 | |
Andrea Bittau | 709dd3a | 2006-01-03 14:25:17 -0800 | [diff] [blame] | 246 | int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, |
| 247 | const struct dccp_hdr *dh, const unsigned len) |
| 248 | { |
| 249 | struct dccp_sock *dp = dccp_sk(sk); |
| 250 | |
| 251 | if (dccp_check_seqno(sk, skb)) |
| 252 | goto discard; |
| 253 | |
| 254 | if (dccp_parse_options(sk, skb)) |
| 255 | goto discard; |
| 256 | |
| 257 | if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) |
| 258 | dccp_event_ack_recv(sk, skb); |
| 259 | |
Arnaldo Carvalho de Melo | a4bf390 | 2006-03-20 22:50:58 -0800 | [diff] [blame] | 260 | if (dccp_msk(sk)->dccpms_send_ack_vector && |
Andrea Bittau | 709dd3a | 2006-01-03 14:25:17 -0800 | [diff] [blame] | 261 | dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, |
| 262 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 263 | DCCP_ACKVEC_STATE_RECEIVED)) |
| 264 | goto discard; |
| 265 | |
Gerrit Renker | 151a993 | 2007-03-07 12:53:48 -0800 | [diff] [blame] | 266 | ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); |
| 267 | ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); |
Andrea Bittau | 709dd3a | 2006-01-03 14:25:17 -0800 | [diff] [blame] | 268 | |
| 269 | return __dccp_rcv_established(sk, skb, dh, len); |
| 270 | discard: |
| 271 | __kfree_skb(skb); |
| 272 | return 0; |
| 273 | } |
| 274 | |
Arnaldo Carvalho de Melo | f21e68c | 2005-12-13 23:24:16 -0800 | [diff] [blame] | 275 | EXPORT_SYMBOL_GPL(dccp_rcv_established); |
| 276 | |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 277 | static int dccp_rcv_request_sent_state_process(struct sock *sk, |
| 278 | struct sk_buff *skb, |
| 279 | const struct dccp_hdr *dh, |
| 280 | const unsigned len) |
| 281 | { |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 282 | /* |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 283 | * Step 4: Prepare sequence numbers in REQUEST |
| 284 | * If S.state == REQUEST, |
| 285 | * If (P.type == Response or P.type == Reset) |
| 286 | * and S.AWL <= P.ackno <= S.AWH, |
| 287 | * / * Set sequence number variables corresponding to the |
| 288 | * other endpoint, so P will pass the tests in Step 6 * / |
| 289 | * Set S.GSR, S.ISR, S.SWL, S.SWH |
| 290 | * / * Response processing continues in Step 10; Reset |
| 291 | * processing continues in Step 9 * / |
| 292 | */ |
| 293 | if (dh->dccph_type == DCCP_PKT_RESPONSE) { |
| 294 | const struct inet_connection_sock *icsk = inet_csk(sk); |
| 295 | struct dccp_sock *dp = dccp_sk(sk); |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 296 | long tstamp = dccp_timestamp(); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 297 | |
| 298 | /* Stop the REQUEST timer */ |
| 299 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); |
| 300 | BUG_TRAP(sk->sk_send_head != NULL); |
| 301 | __kfree_skb(sk->sk_send_head); |
| 302 | sk->sk_send_head = NULL; |
| 303 | |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 304 | if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, |
| 305 | dp->dccps_awl, dp->dccps_awh)) { |
| 306 | dccp_pr_debug("invalid ackno: S.AWL=%llu, " |
| 307 | "P.ackno=%llu, S.AWH=%llu \n", |
| 308 | (unsigned long long)dp->dccps_awl, |
| 309 | (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq, |
| 310 | (unsigned long long)dp->dccps_awh); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 311 | goto out_invalid_packet; |
| 312 | } |
| 313 | |
Andrea Bittau | afe0025 | 2006-03-20 17:43:56 -0800 | [diff] [blame] | 314 | if (dccp_parse_options(sk, skb)) |
| 315 | goto out_invalid_packet; |
| 316 | |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 317 | /* Obtain usec RTT sample from SYN exchange (used by CCID 3) */ |
| 318 | if (likely(dp->dccps_options_received.dccpor_timestamp_echo)) |
| 319 | dp->dccps_syn_rtt = dccp_sample_rtt(sk, 10 * (tstamp - |
| 320 | dp->dccps_options_received.dccpor_timestamp_echo)); |
Gerrit Renker | 89560b5 | 2007-03-20 15:27:17 -0300 | [diff] [blame] | 321 | |
YOSHIFUJI Hideaki | c9eaf17 | 2007-02-09 23:24:38 +0900 | [diff] [blame] | 322 | if (dccp_msk(sk)->dccpms_send_ack_vector && |
| 323 | dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, |
| 324 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 325 | DCCP_ACKVEC_STATE_RECEIVED)) |
| 326 | goto out_invalid_packet; /* FIXME: change error code */ |
Andrea Bittau | 9e37720 | 2006-01-03 14:25:49 -0800 | [diff] [blame] | 327 | |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 328 | dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq; |
Arnaldo Carvalho de Melo | 03ace39 | 2005-08-21 05:36:45 -0300 | [diff] [blame] | 329 | dccp_update_gsr(sk, dp->dccps_isr); |
| 330 | /* |
| 331 | * SWL and AWL are initially adjusted so that they are not less than |
| 332 | * the initial Sequence Numbers received and sent, respectively: |
| 333 | * SWL := max(GSR + 1 - floor(W/4), ISR), |
| 334 | * AWL := max(GSS - W' + 1, ISS). |
| 335 | * These adjustments MUST be applied only at the beginning of the |
| 336 | * connection. |
| 337 | * |
| 338 | * AWL was adjusted in dccp_v4_connect -acme |
| 339 | */ |
| 340 | dccp_set_seqno(&dp->dccps_swl, |
| 341 | max48(dp->dccps_swl, dp->dccps_isr)); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 342 | |
Arnaldo Carvalho de Melo | d83d846 | 2005-12-13 23:26:10 -0800 | [diff] [blame] | 343 | dccp_sync_mss(sk, icsk->icsk_pmtu_cookie); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 344 | |
| 345 | /* |
| 346 | * Step 10: Process REQUEST state (second part) |
| 347 | * If S.state == REQUEST, |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 348 | * / * If we get here, P is a valid Response from the |
| 349 | * server (see Step 4), and we should move to |
| 350 | * PARTOPEN state. PARTOPEN means send an Ack, |
| 351 | * don't send Data packets, retransmit Acks |
| 352 | * periodically, and always include any Init Cookie |
| 353 | * from the Response * / |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 354 | * S.state := PARTOPEN |
| 355 | * Set PARTOPEN timer |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 356 | * Continue with S.state == PARTOPEN |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 357 | * / * Step 12 will send the Ack completing the |
| 358 | * three-way handshake * / |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 359 | */ |
| 360 | dccp_set_state(sk, DCCP_PARTOPEN); |
| 361 | |
| 362 | /* Make sure socket is routed, for correct metrics. */ |
Arnaldo Carvalho de Melo | 57cca05 | 2005-12-13 23:16:16 -0800 | [diff] [blame] | 363 | icsk->icsk_af_ops->rebuild_header(sk); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 364 | |
| 365 | if (!sock_flag(sk, SOCK_DEAD)) { |
| 366 | sk->sk_state_change(sk); |
| 367 | sk_wake_async(sk, 0, POLL_OUT); |
| 368 | } |
| 369 | |
| 370 | if (sk->sk_write_pending || icsk->icsk_ack.pingpong || |
| 371 | icsk->icsk_accept_queue.rskq_defer_accept) { |
| 372 | /* Save one ACK. Data will be ready after |
| 373 | * several ticks, if write_pending is set. |
| 374 | * |
| 375 | * It may be deleted, but with this feature tcpdumps |
| 376 | * look so _wonderfully_ clever, that I was not able |
| 377 | * to stand against the temptation 8) --ANK |
| 378 | */ |
| 379 | /* |
| 380 | * OK, in DCCP we can as well do a similar trick, its |
| 381 | * even in the draft, but there is no need for us to |
| 382 | * schedule an ack here, as dccp_sendmsg does this for |
| 383 | * us, also stated in the draft. -acme |
| 384 | */ |
| 385 | __kfree_skb(skb); |
| 386 | return 0; |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 387 | } |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 388 | dccp_send_ack(sk); |
| 389 | return -1; |
| 390 | } |
| 391 | |
| 392 | out_invalid_packet: |
Arnaldo Carvalho de Melo | 0c10c5d | 2005-09-16 16:58:33 -0700 | [diff] [blame] | 393 | /* dccp_v4_do_rcv will send a reset */ |
| 394 | DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_PACKET_ERROR; |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 395 | return 1; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | static int dccp_rcv_respond_partopen_state_process(struct sock *sk, |
| 399 | struct sk_buff *skb, |
| 400 | const struct dccp_hdr *dh, |
| 401 | const unsigned len) |
| 402 | { |
| 403 | int queued = 0; |
| 404 | |
| 405 | switch (dh->dccph_type) { |
| 406 | case DCCP_PKT_RESET: |
| 407 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); |
| 408 | break; |
Arnaldo Carvalho de Melo | 2a9bc9b | 2005-10-10 21:25:00 -0700 | [diff] [blame] | 409 | case DCCP_PKT_DATA: |
| 410 | if (sk->sk_state == DCCP_RESPOND) |
| 411 | break; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 412 | case DCCP_PKT_DATAACK: |
| 413 | case DCCP_PKT_ACK: |
| 414 | /* |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 415 | * FIXME: we should be reseting the PARTOPEN (DELACK) timer |
| 416 | * here but only if we haven't used the DELACK timer for |
| 417 | * something else, like sending a delayed ack for a TIMESTAMP |
| 418 | * echo, etc, for now were not clearing it, sending an extra |
| 419 | * ACK when there is nothing else to do in DELACK is not a big |
| 420 | * deal after all. |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 421 | */ |
| 422 | |
| 423 | /* Stop the PARTOPEN timer */ |
| 424 | if (sk->sk_state == DCCP_PARTOPEN) |
| 425 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); |
| 426 | |
| 427 | dccp_sk(sk)->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq; |
| 428 | dccp_set_state(sk, DCCP_OPEN); |
| 429 | |
Arnaldo Carvalho de Melo | 2a9bc9b | 2005-10-10 21:25:00 -0700 | [diff] [blame] | 430 | if (dh->dccph_type == DCCP_PKT_DATAACK || |
| 431 | dh->dccph_type == DCCP_PKT_DATA) { |
Andrea Bittau | 709dd3a | 2006-01-03 14:25:17 -0800 | [diff] [blame] | 432 | __dccp_rcv_established(sk, skb, dh, len); |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 433 | queued = 1; /* packet was queued |
Andrea Bittau | 709dd3a | 2006-01-03 14:25:17 -0800 | [diff] [blame] | 434 | (by __dccp_rcv_established) */ |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 435 | } |
| 436 | break; |
| 437 | } |
| 438 | |
| 439 | return queued; |
| 440 | } |
| 441 | |
| 442 | int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, |
| 443 | struct dccp_hdr *dh, unsigned len) |
| 444 | { |
| 445 | struct dccp_sock *dp = dccp_sk(sk); |
Arnaldo Carvalho de Melo | 0c10c5d | 2005-09-16 16:58:33 -0700 | [diff] [blame] | 446 | struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 447 | const int old_state = sk->sk_state; |
| 448 | int queued = 0; |
| 449 | |
Arnaldo Carvalho de Melo | 8649b0d | 2005-08-13 20:36:01 -0300 | [diff] [blame] | 450 | /* |
| 451 | * Step 3: Process LISTEN state |
Arnaldo Carvalho de Melo | 8649b0d | 2005-08-13 20:36:01 -0300 | [diff] [blame] | 452 | * |
| 453 | * If S.state == LISTEN, |
Gerrit Renker | d83ca5a | 2006-11-10 16:29:14 -0200 | [diff] [blame] | 454 | * If P.type == Request or P contains a valid Init Cookie option, |
| 455 | * (* Must scan the packet's options to check for Init |
| 456 | * Cookies. Only Init Cookies are processed here, |
| 457 | * however; other options are processed in Step 8. This |
| 458 | * scan need only be performed if the endpoint uses Init |
| 459 | * Cookies *) |
| 460 | * (* Generate a new socket and switch to that socket *) |
| 461 | * Set S := new socket for this port pair |
| 462 | * S.state = RESPOND |
| 463 | * Choose S.ISS (initial seqno) or set from Init Cookies |
| 464 | * Initialize S.GAR := S.ISS |
| 465 | * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init |
| 466 | * Cookies Continue with S.state == RESPOND |
| 467 | * (* A Response packet will be generated in Step 11 *) |
| 468 | * Otherwise, |
| 469 | * Generate Reset(No Connection) unless P.type == Reset |
| 470 | * Drop packet and return |
Arnaldo Carvalho de Melo | 8649b0d | 2005-08-13 20:36:01 -0300 | [diff] [blame] | 471 | */ |
| 472 | if (sk->sk_state == DCCP_LISTEN) { |
| 473 | if (dh->dccph_type == DCCP_PKT_REQUEST) { |
Arnaldo Carvalho de Melo | 57cca05 | 2005-12-13 23:16:16 -0800 | [diff] [blame] | 474 | if (inet_csk(sk)->icsk_af_ops->conn_request(sk, |
| 475 | skb) < 0) |
Arnaldo Carvalho de Melo | 8649b0d | 2005-08-13 20:36:01 -0300 | [diff] [blame] | 476 | return 1; |
| 477 | |
| 478 | /* FIXME: do congestion control initialization */ |
| 479 | goto discard; |
| 480 | } |
| 481 | if (dh->dccph_type == DCCP_PKT_RESET) |
| 482 | goto discard; |
| 483 | |
Arnaldo Carvalho de Melo | 0c10c5d | 2005-09-16 16:58:33 -0700 | [diff] [blame] | 484 | /* Caller (dccp_v4_do_rcv) will send Reset */ |
| 485 | dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION; |
Arnaldo Carvalho de Melo | 8649b0d | 2005-08-13 20:36:01 -0300 | [diff] [blame] | 486 | return 1; |
| 487 | } |
| 488 | |
| 489 | if (sk->sk_state != DCCP_REQUESTING) { |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 490 | if (dccp_check_seqno(sk, skb)) |
| 491 | goto discard; |
| 492 | |
| 493 | /* |
| 494 | * Step 8: Process options and mark acknowledgeable |
| 495 | */ |
| 496 | if (dccp_parse_options(sk, skb)) |
| 497 | goto discard; |
| 498 | |
Arnaldo Carvalho de Melo | 0c10c5d | 2005-09-16 16:58:33 -0700 | [diff] [blame] | 499 | if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 500 | dccp_event_ack_recv(sk, skb); |
| 501 | |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 502 | if (dccp_msk(sk)->dccpms_send_ack_vector && |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 503 | dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 504 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 505 | DCCP_ACKVEC_STATE_RECEIVED)) |
| 506 | goto discard; |
Andrea Bittau | e84a9f5 | 2006-01-03 14:26:15 -0800 | [diff] [blame] | 507 | |
Gerrit Renker | 151a993 | 2007-03-07 12:53:48 -0800 | [diff] [blame] | 508 | ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); |
| 509 | ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | /* |
| 513 | * Step 9: Process Reset |
| 514 | * If P.type == Reset, |
| 515 | * Tear down connection |
| 516 | * S.state := TIMEWAIT |
| 517 | * Set TIMEWAIT timer |
| 518 | * Drop packet and return |
| 519 | */ |
| 520 | if (dh->dccph_type == DCCP_PKT_RESET) { |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 521 | /* |
| 522 | * Queue the equivalent of TCP fin so that dccp_recvmsg |
| 523 | * exits the loop |
| 524 | */ |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 525 | dccp_fin(sk, skb); |
| 526 | dccp_time_wait(sk, DCCP_TIME_WAIT, 0); |
| 527 | return 0; |
| 528 | /* |
| 529 | * Step 7: Check for unexpected packet types |
| 530 | * If (S.is_server and P.type == CloseReq) |
| 531 | * or (S.is_server and P.type == Response) |
| 532 | * or (S.is_client and P.type == Request) |
| 533 | * or (S.state == RESPOND and P.type == Data), |
| 534 | * Send Sync packet acknowledging P.seqno |
| 535 | * Drop packet and return |
| 536 | */ |
| 537 | } else if ((dp->dccps_role != DCCP_ROLE_CLIENT && |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 538 | (dh->dccph_type == DCCP_PKT_RESPONSE || |
| 539 | dh->dccph_type == DCCP_PKT_CLOSEREQ)) || |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 540 | (dp->dccps_role == DCCP_ROLE_CLIENT && |
| 541 | dh->dccph_type == DCCP_PKT_REQUEST) || |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 542 | (sk->sk_state == DCCP_RESPOND && |
| 543 | dh->dccph_type == DCCP_PKT_DATA)) { |
Arnaldo Carvalho de Melo | 0c10c5d | 2005-09-16 16:58:33 -0700 | [diff] [blame] | 544 | dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 545 | goto discard; |
Arnaldo Carvalho de Melo | 7ad07e7 | 2005-08-23 21:50:06 -0700 | [diff] [blame] | 546 | } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) { |
| 547 | dccp_rcv_closereq(sk, skb); |
| 548 | goto discard; |
| 549 | } else if (dh->dccph_type == DCCP_PKT_CLOSE) { |
| 550 | dccp_rcv_close(sk, skb); |
| 551 | return 0; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | switch (sk->sk_state) { |
| 555 | case DCCP_CLOSED: |
Arnaldo Carvalho de Melo | 0c10c5d | 2005-09-16 16:58:33 -0700 | [diff] [blame] | 556 | dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 557 | return 1; |
| 558 | |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 559 | case DCCP_REQUESTING: |
| 560 | /* FIXME: do congestion control initialization */ |
| 561 | |
| 562 | queued = dccp_rcv_request_sent_state_process(sk, skb, dh, len); |
| 563 | if (queued >= 0) |
| 564 | return queued; |
| 565 | |
| 566 | __kfree_skb(skb); |
| 567 | return 0; |
| 568 | |
| 569 | case DCCP_RESPOND: |
| 570 | case DCCP_PARTOPEN: |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 571 | queued = dccp_rcv_respond_partopen_state_process(sk, skb, |
| 572 | dh, len); |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 573 | break; |
| 574 | } |
| 575 | |
Arnaldo Carvalho de Melo | 7690af3 | 2005-08-13 20:34:54 -0300 | [diff] [blame] | 576 | if (dh->dccph_type == DCCP_PKT_ACK || |
| 577 | dh->dccph_type == DCCP_PKT_DATAACK) { |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 578 | switch (old_state) { |
| 579 | case DCCP_PARTOPEN: |
| 580 | sk->sk_state_change(sk); |
| 581 | sk_wake_async(sk, 0, POLL_OUT); |
| 582 | break; |
| 583 | } |
Gerrit Renker | 0883170 | 2007-09-26 10:30:05 -0300 | [diff] [blame] | 584 | } else if (unlikely(dh->dccph_type == DCCP_PKT_SYNC)) { |
| 585 | dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNCACK); |
| 586 | goto discard; |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 589 | if (!queued) { |
Arnaldo Carvalho de Melo | 7c65787 | 2005-08-09 20:14:34 -0700 | [diff] [blame] | 590 | discard: |
| 591 | __kfree_skb(skb); |
| 592 | } |
| 593 | return 0; |
| 594 | } |
Arnaldo Carvalho de Melo | f21e68c | 2005-12-13 23:24:16 -0800 | [diff] [blame] | 595 | |
| 596 | EXPORT_SYMBOL_GPL(dccp_rcv_state_process); |
Gerrit Renker | 4712a79 | 2007-03-20 15:23:18 -0300 | [diff] [blame] | 597 | |
| 598 | /** |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 599 | * dccp_sample_rtt - Validate and finalise computation of RTT sample |
| 600 | * @delta: number of microseconds between packet and acknowledgment |
| 601 | * The routine is kept generic to work in different contexts. It should be |
| 602 | * called immediately when the ACK used for the RTT sample arrives. |
Gerrit Renker | 4712a79 | 2007-03-20 15:23:18 -0300 | [diff] [blame] | 603 | */ |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 604 | u32 dccp_sample_rtt(struct sock *sk, long delta) |
Gerrit Renker | 4712a79 | 2007-03-20 15:23:18 -0300 | [diff] [blame] | 605 | { |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 606 | /* dccpor_elapsed_time is either zeroed out or set and > 0 */ |
| 607 | delta -= dccp_sk(sk)->dccps_options_received.dccpor_elapsed_time * 10; |
Gerrit Renker | 4712a79 | 2007-03-20 15:23:18 -0300 | [diff] [blame] | 608 | |
| 609 | if (unlikely(delta <= 0)) { |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 610 | DCCP_WARN("unusable RTT sample %ld, using min\n", delta); |
Gerrit Renker | 4712a79 | 2007-03-20 15:23:18 -0300 | [diff] [blame] | 611 | return DCCP_SANE_RTT_MIN; |
| 612 | } |
Gerrit Renker | 3393da8 | 2007-09-25 22:40:44 -0700 | [diff] [blame] | 613 | if (unlikely(delta > DCCP_SANE_RTT_MAX)) { |
| 614 | DCCP_WARN("RTT sample %ld too large, using max\n", delta); |
Gerrit Renker | 4712a79 | 2007-03-20 15:23:18 -0300 | [diff] [blame] | 615 | return DCCP_SANE_RTT_MAX; |
| 616 | } |
| 617 | |
| 618 | return delta; |
| 619 | } |
| 620 | |
| 621 | EXPORT_SYMBOL_GPL(dccp_sample_rtt); |