Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * net/dccp/ackvec.c |
| 3 | * |
| 4 | * An implementation of the DCCP protocol |
| 5 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; version 2 of the License; |
| 10 | */ |
| 11 | |
| 12 | #include "ackvec.h" |
| 13 | #include "dccp.h" |
| 14 | |
| 15 | #include <linux/dccp.h> |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame^] | 16 | #include <linux/init.h> |
| 17 | #include <linux/errno.h> |
| 18 | #include <linux/kernel.h> |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 19 | #include <linux/skbuff.h> |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame^] | 20 | #include <linux/slab.h> |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 21 | |
| 22 | #include <net/sock.h> |
| 23 | |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame^] | 24 | static kmem_cache_t *dccp_ackvec_slab; |
| 25 | |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 26 | int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb) |
| 27 | { |
| 28 | struct dccp_sock *dp = dccp_sk(sk); |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 29 | #ifdef CONFIG_IP_DCCP_DEBUG |
| 30 | const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? |
| 31 | "CLIENT tx: " : "server tx: "; |
| 32 | #endif |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 33 | struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec; |
| 34 | int len = av->dccpav_vec_len + 2; |
| 35 | struct timeval now; |
| 36 | u32 elapsed_time; |
| 37 | unsigned char *to, *from; |
| 38 | |
| 39 | dccp_timestamp(sk, &now); |
| 40 | elapsed_time = timeval_delta(&now, &av->dccpav_time) / 10; |
| 41 | |
| 42 | if (elapsed_time != 0) |
| 43 | dccp_insert_option_elapsed_time(sk, skb, elapsed_time); |
| 44 | |
| 45 | if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) |
| 46 | return -1; |
| 47 | |
| 48 | /* |
| 49 | * XXX: now we have just one ack vector sent record, so |
| 50 | * we have to wait for it to be cleared. |
| 51 | * |
| 52 | * Of course this is not acceptable, but this is just for |
| 53 | * basic testing now. |
| 54 | */ |
| 55 | if (av->dccpav_ack_seqno != DCCP_MAX_SEQNO + 1) |
| 56 | return -1; |
| 57 | |
| 58 | DCCP_SKB_CB(skb)->dccpd_opt_len += len; |
| 59 | |
| 60 | to = skb_push(skb, len); |
| 61 | *to++ = DCCPO_ACK_VECTOR_0; |
| 62 | *to++ = len; |
| 63 | |
| 64 | len = av->dccpav_vec_len; |
| 65 | from = av->dccpav_buf + av->dccpav_buf_head; |
| 66 | |
| 67 | /* Check if buf_head wraps */ |
Arnaldo Carvalho de Melo | e4dfd44 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 68 | if ((int)av->dccpav_buf_head + len > av->dccpav_vec_len) { |
| 69 | const u32 tailsize = av->dccpav_vec_len - av->dccpav_buf_head; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 70 | |
| 71 | memcpy(to, from, tailsize); |
| 72 | to += tailsize; |
| 73 | len -= tailsize; |
| 74 | from = av->dccpav_buf; |
| 75 | } |
| 76 | |
| 77 | memcpy(to, from, len); |
| 78 | /* |
| 79 | * From draft-ietf-dccp-spec-11.txt: |
| 80 | * |
| 81 | * For each acknowledgement it sends, the HC-Receiver will add an |
| 82 | * acknowledgement record. ack_seqno will equal the HC-Receiver |
| 83 | * sequence number it used for the ack packet; ack_ptr will equal |
| 84 | * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will |
| 85 | * equal buf_nonce. |
| 86 | * |
| 87 | * This implemention uses just one ack record for now. |
| 88 | */ |
| 89 | av->dccpav_ack_seqno = DCCP_SKB_CB(skb)->dccpd_seq; |
| 90 | av->dccpav_ack_ptr = av->dccpav_buf_head; |
| 91 | av->dccpav_ack_ackno = av->dccpav_buf_ackno; |
| 92 | av->dccpav_ack_nonce = av->dccpav_buf_nonce; |
| 93 | av->dccpav_sent_len = av->dccpav_vec_len; |
| 94 | |
| 95 | dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, " |
| 96 | "ack_ackno=%llu\n", |
| 97 | debug_prefix, av->dccpav_sent_len, |
| 98 | (unsigned long long)av->dccpav_ack_seqno, |
| 99 | (unsigned long long)av->dccpav_ack_ackno); |
| 100 | return -1; |
| 101 | } |
| 102 | |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 103 | struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 104 | { |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame^] | 105 | struct dccp_ackvec *av = kmem_cache_alloc(dccp_ackvec_slab, priority); |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 106 | |
| 107 | if (av != NULL) { |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 108 | av->dccpav_buf_head = |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 109 | av->dccpav_buf_tail = DCCP_MAX_ACKVEC_LEN - 1; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 110 | av->dccpav_buf_ackno = |
| 111 | av->dccpav_ack_ackno = av->dccpav_ack_seqno = ~0LLU; |
| 112 | av->dccpav_buf_nonce = av->dccpav_buf_nonce = 0; |
| 113 | av->dccpav_ack_ptr = 0; |
| 114 | av->dccpav_time.tv_sec = 0; |
| 115 | av->dccpav_time.tv_usec = 0; |
| 116 | av->dccpav_sent_len = av->dccpav_vec_len = 0; |
| 117 | } |
| 118 | |
| 119 | return av; |
| 120 | } |
| 121 | |
| 122 | void dccp_ackvec_free(struct dccp_ackvec *av) |
| 123 | { |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame^] | 124 | kmem_cache_free(dccp_ackvec_slab, av); |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static inline u8 dccp_ackvec_state(const struct dccp_ackvec *av, |
Arnaldo Carvalho de Melo | e4dfd44 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 128 | const u8 index) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 129 | { |
| 130 | return av->dccpav_buf[index] & DCCP_ACKVEC_STATE_MASK; |
| 131 | } |
| 132 | |
| 133 | static inline u8 dccp_ackvec_len(const struct dccp_ackvec *av, |
Arnaldo Carvalho de Melo | e4dfd44 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 134 | const u8 index) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 135 | { |
| 136 | return av->dccpav_buf[index] & DCCP_ACKVEC_LEN_MASK; |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * If several packets are missing, the HC-Receiver may prefer to enter multiple |
| 141 | * bytes with run length 0, rather than a single byte with a larger run length; |
| 142 | * this simplifies table updates if one of the missing packets arrives. |
| 143 | */ |
| 144 | static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av, |
| 145 | const unsigned int packets, |
Arnaldo Carvalho de Melo | e4dfd44 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 146 | const unsigned char state) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 147 | { |
| 148 | unsigned int gap; |
Kris Katterjohn | a8fc3d8 | 2006-01-17 13:03:54 -0800 | [diff] [blame] | 149 | long new_head; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 150 | |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 151 | if (av->dccpav_vec_len + packets > DCCP_MAX_ACKVEC_LEN) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 152 | return -ENOBUFS; |
| 153 | |
| 154 | gap = packets - 1; |
| 155 | new_head = av->dccpav_buf_head - packets; |
| 156 | |
| 157 | if (new_head < 0) { |
| 158 | if (gap > 0) { |
| 159 | memset(av->dccpav_buf, DCCP_ACKVEC_STATE_NOT_RECEIVED, |
| 160 | gap + new_head + 1); |
| 161 | gap = -new_head; |
| 162 | } |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 163 | new_head += DCCP_MAX_ACKVEC_LEN; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | av->dccpav_buf_head = new_head; |
| 167 | |
| 168 | if (gap > 0) |
| 169 | memset(av->dccpav_buf + av->dccpav_buf_head + 1, |
| 170 | DCCP_ACKVEC_STATE_NOT_RECEIVED, gap); |
| 171 | |
| 172 | av->dccpav_buf[av->dccpav_buf_head] = state; |
| 173 | av->dccpav_vec_len += packets; |
| 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | /* |
| 178 | * Implements the draft-ietf-dccp-spec-11.txt Appendix A |
| 179 | */ |
| 180 | int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, |
| 181 | const u64 ackno, const u8 state) |
| 182 | { |
| 183 | /* |
| 184 | * Check at the right places if the buffer is full, if it is, tell the |
| 185 | * caller to start dropping packets till the HC-Sender acks our ACK |
| 186 | * vectors, when we will free up space in dccpav_buf. |
| 187 | * |
| 188 | * We may well decide to do buffer compression, etc, but for now lets |
| 189 | * just drop. |
| 190 | * |
| 191 | * From Appendix A: |
| 192 | * |
| 193 | * Of course, the circular buffer may overflow, either when the |
| 194 | * HC-Sender is sending data at a very high rate, when the |
| 195 | * HC-Receiver's acknowledgements are not reaching the HC-Sender, |
| 196 | * or when the HC-Sender is forgetting to acknowledge those acks |
| 197 | * (so the HC-Receiver is unable to clean up old state). In this |
| 198 | * case, the HC-Receiver should either compress the buffer (by |
| 199 | * increasing run lengths when possible), transfer its state to |
| 200 | * a larger buffer, or, as a last resort, drop all received |
| 201 | * packets, without processing them whatsoever, until its buffer |
| 202 | * shrinks again. |
| 203 | */ |
| 204 | |
| 205 | /* See if this is the first ackno being inserted */ |
| 206 | if (av->dccpav_vec_len == 0) { |
| 207 | av->dccpav_buf[av->dccpav_buf_head] = state; |
| 208 | av->dccpav_vec_len = 1; |
| 209 | } else if (after48(ackno, av->dccpav_buf_ackno)) { |
| 210 | const u64 delta = dccp_delta_seqno(av->dccpav_buf_ackno, |
| 211 | ackno); |
| 212 | |
| 213 | /* |
| 214 | * Look if the state of this packet is the same as the |
| 215 | * previous ackno and if so if we can bump the head len. |
| 216 | */ |
| 217 | if (delta == 1 && |
| 218 | dccp_ackvec_state(av, av->dccpav_buf_head) == state && |
| 219 | (dccp_ackvec_len(av, av->dccpav_buf_head) < |
| 220 | DCCP_ACKVEC_LEN_MASK)) |
| 221 | av->dccpav_buf[av->dccpav_buf_head]++; |
| 222 | else if (dccp_ackvec_set_buf_head_state(av, delta, state)) |
| 223 | return -ENOBUFS; |
| 224 | } else { |
| 225 | /* |
| 226 | * A.1.2. Old Packets |
| 227 | * |
| 228 | * When a packet with Sequence Number S arrives, and |
| 229 | * S <= buf_ackno, the HC-Receiver will scan the table |
| 230 | * for the byte corresponding to S. (Indexing structures |
| 231 | * could reduce the complexity of this scan.) |
| 232 | */ |
| 233 | u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno); |
Arnaldo Carvalho de Melo | e4dfd44 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 234 | u8 index = av->dccpav_buf_head; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 235 | |
| 236 | while (1) { |
| 237 | const u8 len = dccp_ackvec_len(av, index); |
| 238 | const u8 state = dccp_ackvec_state(av, index); |
| 239 | /* |
| 240 | * valid packets not yet in dccpav_buf have a reserved |
| 241 | * entry, with a len equal to 0. |
| 242 | */ |
| 243 | if (state == DCCP_ACKVEC_STATE_NOT_RECEIVED && |
| 244 | len == 0 && delta == 0) { /* Found our |
| 245 | reserved seat! */ |
| 246 | dccp_pr_debug("Found %llu reserved seat!\n", |
| 247 | (unsigned long long)ackno); |
| 248 | av->dccpav_buf[index] = state; |
| 249 | goto out; |
| 250 | } |
| 251 | /* len == 0 means one packet */ |
| 252 | if (delta < len + 1) |
| 253 | goto out_duplicate; |
| 254 | |
| 255 | delta -= len + 1; |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 256 | if (++index == DCCP_MAX_ACKVEC_LEN) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 257 | index = 0; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | av->dccpav_buf_ackno = ackno; |
| 262 | dccp_timestamp(sk, &av->dccpav_time); |
| 263 | out: |
| 264 | dccp_pr_debug(""); |
| 265 | return 0; |
| 266 | |
| 267 | out_duplicate: |
| 268 | /* Duplicate packet */ |
| 269 | dccp_pr_debug("Received a dup or already considered lost " |
| 270 | "packet: %llu\n", (unsigned long long)ackno); |
| 271 | return -EILSEQ; |
| 272 | } |
| 273 | |
| 274 | #ifdef CONFIG_IP_DCCP_DEBUG |
| 275 | void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len) |
| 276 | { |
| 277 | if (!dccp_debug) |
| 278 | return; |
| 279 | |
| 280 | printk("ACK vector len=%d, ackno=%llu |", len, |
| 281 | (unsigned long long)ackno); |
| 282 | |
| 283 | while (len--) { |
| 284 | const u8 state = (*vector & DCCP_ACKVEC_STATE_MASK) >> 6; |
| 285 | const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK; |
| 286 | |
| 287 | printk("%d,%d|", state, rl); |
| 288 | ++vector; |
| 289 | } |
| 290 | |
| 291 | printk("\n"); |
| 292 | } |
| 293 | |
| 294 | void dccp_ackvec_print(const struct dccp_ackvec *av) |
| 295 | { |
| 296 | dccp_ackvector_print(av->dccpav_buf_ackno, |
| 297 | av->dccpav_buf + av->dccpav_buf_head, |
| 298 | av->dccpav_vec_len); |
| 299 | } |
| 300 | #endif |
| 301 | |
Andrea Bittau | 6742bbc | 2006-01-04 01:45:17 -0200 | [diff] [blame] | 302 | static void dccp_ackvec_throw_away_ack_record(struct dccp_ackvec *av) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 303 | { |
| 304 | /* |
| 305 | * As we're keeping track of the ack vector size (dccpav_vec_len) and |
| 306 | * the sent ack vector size (dccpav_sent_len) we don't need |
| 307 | * dccpav_buf_tail at all, but keep this code here as in the future |
| 308 | * we'll implement a vector of ack records, as suggested in |
| 309 | * draft-ietf-dccp-spec-11.txt Appendix A. -acme |
| 310 | */ |
| 311 | #if 0 |
Arnaldo Carvalho de Melo | e4dfd44 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 312 | u32 new_buf_tail = av->dccpav_ack_ptr + 1; |
| 313 | if (new_buf_tail >= av->dccpav_vec_len) |
| 314 | new_buf_tail -= av->dccpav_vec_len; |
| 315 | av->dccpav_buf_tail = new_buf_tail; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 316 | #endif |
| 317 | av->dccpav_vec_len -= av->dccpav_sent_len; |
| 318 | } |
| 319 | |
| 320 | void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, struct sock *sk, |
| 321 | const u64 ackno) |
| 322 | { |
| 323 | /* Check if we actually sent an ACK vector */ |
| 324 | if (av->dccpav_ack_seqno == DCCP_MAX_SEQNO + 1) |
| 325 | return; |
| 326 | |
| 327 | if (ackno == av->dccpav_ack_seqno) { |
| 328 | #ifdef CONFIG_IP_DCCP_DEBUG |
| 329 | struct dccp_sock *dp = dccp_sk(sk); |
| 330 | const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? |
| 331 | "CLIENT rx ack: " : "server rx ack: "; |
| 332 | #endif |
| 333 | dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, " |
| 334 | "ack_ackno=%llu, ACKED!\n", |
| 335 | debug_prefix, 1, |
| 336 | (unsigned long long)av->dccpav_ack_seqno, |
| 337 | (unsigned long long)av->dccpav_ack_ackno); |
Andrea Bittau | 6742bbc | 2006-01-04 01:45:17 -0200 | [diff] [blame] | 338 | dccp_ackvec_throw_away_ack_record(av); |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 339 | av->dccpav_ack_seqno = DCCP_MAX_SEQNO + 1; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av, |
| 344 | struct sock *sk, u64 ackno, |
| 345 | const unsigned char len, |
| 346 | const unsigned char *vector) |
| 347 | { |
| 348 | unsigned char i; |
| 349 | |
| 350 | /* Check if we actually sent an ACK vector */ |
| 351 | if (av->dccpav_ack_seqno == DCCP_MAX_SEQNO + 1) |
| 352 | return; |
| 353 | /* |
| 354 | * We're in the receiver half connection, so if the received an ACK |
| 355 | * vector ackno (e.g. 50) before dccpav_ack_seqno (e.g. 52), we're |
| 356 | * not interested. |
| 357 | * |
| 358 | * Extra explanation with example: |
| 359 | * |
| 360 | * if we received an ACK vector with ackno 50, it can only be acking |
| 361 | * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent). |
| 362 | */ |
| 363 | /* dccp_pr_debug("is %llu < %llu? ", ackno, av->dccpav_ack_seqno); */ |
| 364 | if (before48(ackno, av->dccpav_ack_seqno)) { |
| 365 | /* dccp_pr_debug_cat("yes\n"); */ |
| 366 | return; |
| 367 | } |
| 368 | /* dccp_pr_debug_cat("no\n"); */ |
| 369 | |
| 370 | i = len; |
| 371 | while (i--) { |
| 372 | const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK; |
| 373 | u64 ackno_end_rl; |
| 374 | |
| 375 | dccp_set_seqno(&ackno_end_rl, ackno - rl); |
| 376 | |
| 377 | /* |
| 378 | * dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl, |
| 379 | * av->dccpav_ack_seqno, ackno); |
| 380 | */ |
| 381 | if (between48(av->dccpav_ack_seqno, ackno_end_rl, ackno)) { |
| 382 | const u8 state = (*vector & |
| 383 | DCCP_ACKVEC_STATE_MASK) >> 6; |
| 384 | /* dccp_pr_debug_cat("yes\n"); */ |
| 385 | |
| 386 | if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED) { |
| 387 | #ifdef CONFIG_IP_DCCP_DEBUG |
| 388 | struct dccp_sock *dp = dccp_sk(sk); |
| 389 | const char *debug_prefix = |
| 390 | dp->dccps_role == DCCP_ROLE_CLIENT ? |
| 391 | "CLIENT rx ack: " : "server rx ack: "; |
| 392 | #endif |
| 393 | dccp_pr_debug("%sACK vector 0, len=%d, " |
| 394 | "ack_seqno=%llu, ack_ackno=%llu, " |
| 395 | "ACKED!\n", |
| 396 | debug_prefix, len, |
| 397 | (unsigned long long) |
| 398 | av->dccpav_ack_seqno, |
| 399 | (unsigned long long) |
| 400 | av->dccpav_ack_ackno); |
Andrea Bittau | 6742bbc | 2006-01-04 01:45:17 -0200 | [diff] [blame] | 401 | dccp_ackvec_throw_away_ack_record(av); |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 402 | } |
| 403 | /* |
| 404 | * If dccpav_ack_seqno was not received, no problem |
| 405 | * we'll send another ACK vector. |
| 406 | */ |
| 407 | av->dccpav_ack_seqno = DCCP_MAX_SEQNO + 1; |
| 408 | break; |
| 409 | } |
| 410 | /* dccp_pr_debug_cat("no\n"); */ |
| 411 | |
| 412 | dccp_set_seqno(&ackno, ackno_end_rl - 1); |
| 413 | ++vector; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, |
| 418 | const u8 opt, const u8 *value, const u8 len) |
| 419 | { |
| 420 | if (len > DCCP_MAX_ACKVEC_LEN) |
| 421 | return -1; |
| 422 | |
| 423 | /* dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, value, len); */ |
| 424 | dccp_ackvec_check_rcv_ackvector(dccp_sk(sk)->dccps_hc_rx_ackvec, sk, |
| 425 | DCCP_SKB_CB(skb)->dccpd_ack_seq, |
| 426 | len, value); |
| 427 | return 0; |
| 428 | } |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame^] | 429 | |
| 430 | static char dccp_ackvec_slab_msg[] __initdata = |
| 431 | KERN_CRIT "DCCP: Unable to create ack vectors slab cache\n"; |
| 432 | |
| 433 | int __init dccp_ackvec_init(void) |
| 434 | { |
| 435 | dccp_ackvec_slab = kmem_cache_create("dccp_ackvec", |
| 436 | sizeof(struct dccp_ackvec), 0, |
| 437 | SLAB_HWCACHE_ALIGN, NULL, NULL); |
| 438 | if (dccp_ackvec_slab == NULL) { |
| 439 | printk(dccp_ackvec_slab_msg); |
| 440 | return -ENOBUFS; |
| 441 | } |
| 442 | |
| 443 | return 0; |
| 444 | } |
| 445 | |
| 446 | void dccp_ackvec_exit(void) |
| 447 | { |
| 448 | if (dccp_ackvec_slab != NULL) { |
| 449 | kmem_cache_destroy(dccp_ackvec_slab); |
| 450 | dccp_ackvec_slab = NULL; |
| 451 | } |
| 452 | } |