Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dccp ccid-2: Remove old infrastructure

This removes
* functions for which updates have been provided in the preceding patches and
* the @av_vec_len field - it is no longer necessary since the buffer length is
now always computed dynamically.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>

-265
-251
net/dccp/ackvec.c
··· 9 9 * under the terms of the GNU General Public License as published by the 10 10 * Free Software Foundation; version 2 of the License; 11 11 */ 12 - 13 - #include "ackvec.h" 14 12 #include "dccp.h" 15 - 16 - #include <linux/init.h> 17 - #include <linux/errno.h> 18 13 #include <linux/kernel.h> 19 - #include <linux/skbuff.h> 20 14 #include <linux/slab.h> 21 - 22 - #include <net/sock.h> 23 15 24 16 static struct kmem_cache *dccp_ackvec_slab; 25 17 static struct kmem_cache *dccp_ackvec_record_slab; ··· 271 279 dccp_ackvec_update_old(av, num_packets, seqno, state); 272 280 } 273 281 } 274 - } 275 - 276 - /* 277 - * If several packets are missing, the HC-Receiver may prefer to enter multiple 278 - * bytes with run length 0, rather than a single byte with a larger run length; 279 - * this simplifies table updates if one of the missing packets arrives. 280 - */ 281 - static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av, 282 - const unsigned int packets, 283 - const unsigned char state) 284 - { 285 - long gap; 286 - long new_head; 287 - 288 - if (av->av_vec_len + packets > DCCPAV_MAX_ACKVEC_LEN) 289 - return -ENOBUFS; 290 - 291 - gap = packets - 1; 292 - new_head = av->av_buf_head - packets; 293 - 294 - if (new_head < 0) { 295 - if (gap > 0) { 296 - memset(av->av_buf, DCCPAV_NOT_RECEIVED, 297 - gap + new_head + 1); 298 - gap = -new_head; 299 - } 300 - new_head += DCCPAV_MAX_ACKVEC_LEN; 301 - } 302 - 303 - av->av_buf_head = new_head; 304 - 305 - if (gap > 0) 306 - memset(av->av_buf + av->av_buf_head + 1, 307 - DCCPAV_NOT_RECEIVED, gap); 308 - 309 - av->av_buf[av->av_buf_head] = state; 310 - av->av_vec_len += packets; 311 - return 0; 312 - } 313 - 314 - /* 315 - * Implements the RFC 4340, Appendix A 316 - */ 317 - int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, 318 - const u64 ackno, const u8 state) 319 - { 320 - u8 *cur_head = av->av_buf + av->av_buf_head, 321 - *buf_end = av->av_buf + DCCPAV_MAX_ACKVEC_LEN; 322 - /* 323 - * Check at the right places if the buffer is full, if it is, tell the 324 - * caller to start dropping packets till the HC-Sender acks our ACK 325 - * vectors, when we will free up space in av_buf. 326 - * 327 - * We may well decide to do buffer compression, etc, but for now lets 328 - * just drop. 329 - * 330 - * From Appendix A.1.1 (`New Packets'): 331 - * 332 - * Of course, the circular buffer may overflow, either when the 333 - * HC-Sender is sending data at a very high rate, when the 334 - * HC-Receiver's acknowledgements are not reaching the HC-Sender, 335 - * or when the HC-Sender is forgetting to acknowledge those acks 336 - * (so the HC-Receiver is unable to clean up old state). In this 337 - * case, the HC-Receiver should either compress the buffer (by 338 - * increasing run lengths when possible), transfer its state to 339 - * a larger buffer, or, as a last resort, drop all received 340 - * packets, without processing them whatsoever, until its buffer 341 - * shrinks again. 342 - */ 343 - 344 - /* See if this is the first ackno being inserted */ 345 - if (av->av_vec_len == 0) { 346 - *cur_head = state; 347 - av->av_vec_len = 1; 348 - } else if (after48(ackno, av->av_buf_ackno)) { 349 - const u64 delta = dccp_delta_seqno(av->av_buf_ackno, ackno); 350 - 351 - /* 352 - * Look if the state of this packet is the same as the 353 - * previous ackno and if so if we can bump the head len. 354 - */ 355 - if (delta == 1 && dccp_ackvec_state(cur_head) == state && 356 - dccp_ackvec_runlen(cur_head) < DCCPAV_MAX_RUNLEN) 357 - *cur_head += 1; 358 - else if (dccp_ackvec_set_buf_head_state(av, delta, state)) 359 - return -ENOBUFS; 360 - } else { 361 - /* 362 - * A.1.2. Old Packets 363 - * 364 - * When a packet with Sequence Number S <= buf_ackno 365 - * arrives, the HC-Receiver will scan the table for 366 - * the byte corresponding to S. (Indexing structures 367 - * could reduce the complexity of this scan.) 368 - */ 369 - u64 delta = dccp_delta_seqno(ackno, av->av_buf_ackno); 370 - 371 - while (1) { 372 - const u8 len = dccp_ackvec_runlen(cur_head); 373 - /* 374 - * valid packets not yet in av_buf have a reserved 375 - * entry, with a len equal to 0. 376 - */ 377 - if (*cur_head == DCCPAV_NOT_RECEIVED && delta == 0) { 378 - dccp_pr_debug("Found %llu reserved seat!\n", 379 - (unsigned long long)ackno); 380 - *cur_head = state; 381 - goto out; 382 - } 383 - /* len == 0 means one packet */ 384 - if (delta < len + 1) 385 - goto out_duplicate; 386 - 387 - delta -= len + 1; 388 - if (++cur_head == buf_end) 389 - cur_head = av->av_buf; 390 - } 391 - } 392 - 393 - av->av_buf_ackno = ackno; 394 - out: 395 - return 0; 396 - 397 - out_duplicate: 398 - /* Duplicate packet */ 399 - dccp_pr_debug("Received a dup or already considered lost " 400 - "packet: %llu\n", (unsigned long long)ackno); 401 - return -EILSEQ; 402 - } 403 - 404 - static void dccp_ackvec_throw_record(struct dccp_ackvec *av, 405 - struct dccp_ackvec_record *avr) 406 - { 407 - struct dccp_ackvec_record *next; 408 - 409 - /* sort out vector length */ 410 - if (av->av_buf_head <= avr->avr_ack_ptr) 411 - av->av_vec_len = avr->avr_ack_ptr - av->av_buf_head; 412 - else 413 - av->av_vec_len = DCCPAV_MAX_ACKVEC_LEN - 1 - 414 - av->av_buf_head + avr->avr_ack_ptr; 415 - 416 - /* free records */ 417 - list_for_each_entry_safe_from(avr, next, &av->av_records, avr_node) { 418 - list_del(&avr->avr_node); 419 - kmem_cache_free(dccp_ackvec_record_slab, avr); 420 - } 421 - } 422 - 423 - void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, struct sock *sk, 424 - const u64 ackno) 425 - { 426 - struct dccp_ackvec_record *avr; 427 - 428 - /* 429 - * If we traverse backwards, it should be faster when we have large 430 - * windows. We will be receiving ACKs for stuff we sent a while back 431 - * -sorbo. 432 - */ 433 - list_for_each_entry_reverse(avr, &av->av_records, avr_node) { 434 - if (ackno == avr->avr_ack_seqno) { 435 - dccp_pr_debug("%s ACK packet 0, len=%d, ack_seqno=%llu, " 436 - "ack_ackno=%llu, ACKED!\n", 437 - dccp_role(sk), avr->avr_ack_runlen, 438 - (unsigned long long)avr->avr_ack_seqno, 439 - (unsigned long long)avr->avr_ack_ackno); 440 - dccp_ackvec_throw_record(av, avr); 441 - break; 442 - } else if (avr->avr_ack_seqno > ackno) 443 - break; /* old news */ 444 - } 445 - } 446 - 447 - static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av, 448 - struct sock *sk, u64 *ackno, 449 - const unsigned char len, 450 - const unsigned char *vector) 451 - { 452 - unsigned char i; 453 - struct dccp_ackvec_record *avr; 454 - 455 - /* Check if we actually sent an ACK vector */ 456 - if (list_empty(&av->av_records)) 457 - return; 458 - 459 - i = len; 460 - /* 461 - * XXX 462 - * I think it might be more efficient to work backwards. See comment on 463 - * rcv_ackno. -sorbo. 464 - */ 465 - avr = list_entry(av->av_records.next, struct dccp_ackvec_record, avr_node); 466 - while (i--) { 467 - const u8 rl = dccp_ackvec_runlen(vector); 468 - u64 ackno_end_rl; 469 - 470 - dccp_set_seqno(&ackno_end_rl, *ackno - rl); 471 - 472 - /* 473 - * If our AVR sequence number is greater than the ack, go 474 - * forward in the AVR list until it is not so. 475 - */ 476 - list_for_each_entry_from(avr, &av->av_records, avr_node) { 477 - if (!after48(avr->avr_ack_seqno, *ackno)) 478 - goto found; 479 - } 480 - /* End of the av_records list, not found, exit */ 481 - break; 482 - found: 483 - if (between48(avr->avr_ack_seqno, ackno_end_rl, *ackno)) { 484 - if (dccp_ackvec_state(vector) != DCCPAV_NOT_RECEIVED) { 485 - dccp_pr_debug("%s ACK vector 0, len=%d, " 486 - "ack_seqno=%llu, ack_ackno=%llu, " 487 - "ACKED!\n", 488 - dccp_role(sk), len, 489 - (unsigned long long) 490 - avr->avr_ack_seqno, 491 - (unsigned long long) 492 - avr->avr_ack_ackno); 493 - dccp_ackvec_throw_record(av, avr); 494 - break; 495 - } 496 - /* 497 - * If it wasn't received, continue scanning... we might 498 - * find another one. 499 - */ 500 - } 501 - 502 - dccp_set_seqno(ackno, ackno_end_rl - 1); 503 - ++vector; 504 - } 505 - } 506 - 507 - int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 508 - u64 *ackno, const u8 opt, const u8 *value, const u8 len) 509 - { 510 - if (len > DCCP_SINGLE_OPT_MAXLEN) 511 - return -1; 512 - 513 - /* dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, value, len); */ 514 - dccp_ackvec_check_rcv_ackvector(dccp_sk(sk)->dccps_hc_rx_ackvec, sk, 515 - ackno, len, value); 516 - return 0; 517 282 } 518 283 519 284 /**
-14
net/dccp/ackvec.h
··· 64 64 * %DCCP_SINGLE_OPT_MAXLEN cells in the live portion of @av_buf 65 65 * @av_overflow: if 1 then buf_head == buf_tail indicates buffer wraparound 66 66 * @av_records: list of %dccp_ackvec_record (Ack Vectors sent previously) 67 - * @av_veclen: length of the live portion of @av_buf 68 67 */ 69 68 struct dccp_ackvec { 70 69 u8 av_buf[DCCPAV_MAX_ACKVEC_LEN]; ··· 74 75 bool av_buf_nonce[DCCPAV_NUM_ACKVECS]; 75 76 u8 av_overflow:1; 76 77 struct list_head av_records; 77 - u16 av_vec_len; 78 78 }; 79 79 80 80 /** struct dccp_ackvec_record - Records information about sent Ack Vectors ··· 99 101 u8 avr_ack_nonce:1; 100 102 }; 101 103 102 - struct sock; 103 - struct sk_buff; 104 - 105 104 extern int dccp_ackvec_init(void); 106 105 extern void dccp_ackvec_exit(void); 107 106 108 107 extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); 109 108 extern void dccp_ackvec_free(struct dccp_ackvec *av); 110 - 111 - extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, 112 - const u64 ackno, const u8 state); 113 - 114 - extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, 115 - struct sock *sk, const u64 ackno); 116 - extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 117 - u64 *ackno, const u8 opt, 118 - const u8 *value, const u8 len); 119 109 120 110 extern void dccp_ackvec_input(struct dccp_ackvec *av, struct sk_buff *skb); 121 111 extern int dccp_ackvec_update_records(struct dccp_ackvec *av, u64 seq, u8 sum);