aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2010-09-14 14:21:29 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2010-09-15 06:36:02 -0400
commit37efb03fbd0935f5f85a0538c46b53be5cf40504 (patch)
treec0335ed0e231bbf081442d380e5dd945d51e0e80 /net/dccp/ccids
parentd2c726309d88df3c5568486e4b5b9e4c3150903f (diff)
dccp ccid-3: Simplify and consolidate tx_parse_options
This simplifies and consolidates the TX option-parsing code: 1. The Loss Intervals option is not currently used, so dead code related to this option is removed. I am aware of no plans to support the option, but if someone wants to implement it (e.g. for inter-op tests), it is better to start afresh than having to also update currently unused code. 2. The Loss Event and Receive Rate options have a lot of code in common (both are 32 bit, both have same length etc.), so this is consolidated. 3. The test against GSR is not necessary, because - on first loading CCID3, ccid_new() zeroes out all fields in the socket; - ccid3_hc_tx_packet_recv() treats 0 and ~0U equivalently, due to pinv = opt_recv->ccid3or_loss_event_rate; if (pinv == ~0U || pinv == 0) hctx->p = 0; - as a result, the sequence number field is removed from opt_recv. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid3.c57
-rw-r--r--net/dccp/ccids/ccid3.h3
2 files changed, 14 insertions, 46 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index b2ddd205d438..ce8059130070 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -485,60 +485,31 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
485 unsigned char len, u16 idx, 485 unsigned char len, u16 idx,
486 unsigned char *value) 486 unsigned char *value)
487{ 487{
488 int rc = 0;
489 const struct dccp_sock *dp = dccp_sk(sk);
490 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); 488 struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
491 struct ccid3_options_received *opt_recv = &hc->tx_options_received; 489 struct ccid3_options_received *opt_recv = &hc->tx_options_received;
492 __be32 opt_val; 490 __be32 opt_val;
493 491
494 if (opt_recv->ccid3or_seqno != dp->dccps_gsr) {
495 opt_recv->ccid3or_seqno = dp->dccps_gsr;
496 opt_recv->ccid3or_loss_event_rate = ~0;
497 opt_recv->ccid3or_loss_intervals_idx = 0;
498 opt_recv->ccid3or_loss_intervals_len = 0;
499 opt_recv->ccid3or_receive_rate = 0;
500 }
501
502 switch (option) { 492 switch (option) {
493 case TFRC_OPT_RECEIVE_RATE:
503 case TFRC_OPT_LOSS_EVENT_RATE: 494 case TFRC_OPT_LOSS_EVENT_RATE:
504 if (unlikely(len != 4)) { 495 if (unlikely(len != 4)) {
505 DCCP_WARN("%s(%p), invalid len %d " 496 DCCP_WARN("%s(%p), invalid len %d for %u\n",
506 "for TFRC_OPT_LOSS_EVENT_RATE\n", 497 dccp_role(sk), sk, len, option);
507 dccp_role(sk), sk, len); 498 return -EINVAL;
508 rc = -EINVAL;
509 } else {
510 opt_val = get_unaligned((__be32 *)value);
511 opt_recv->ccid3or_loss_event_rate = ntohl(opt_val);
512 ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
513 dccp_role(sk), sk,
514 opt_recv->ccid3or_loss_event_rate);
515 } 499 }
516 break; 500 opt_val = ntohl(get_unaligned((__be32 *)value));
517 case TFRC_OPT_LOSS_INTERVALS: 501
518 opt_recv->ccid3or_loss_intervals_idx = idx; 502 if (option == TFRC_OPT_RECEIVE_RATE) {
519 opt_recv->ccid3or_loss_intervals_len = len; 503 opt_recv->ccid3or_receive_rate = opt_val;
520 ccid3_pr_debug("%s(%p), LOSS_INTERVALS=(%u, %u)\n",
521 dccp_role(sk), sk,
522 opt_recv->ccid3or_loss_intervals_idx,
523 opt_recv->ccid3or_loss_intervals_len);
524 break;
525 case TFRC_OPT_RECEIVE_RATE:
526 if (unlikely(len != 4)) {
527 DCCP_WARN("%s(%p), invalid len %d "
528 "for TFRC_OPT_RECEIVE_RATE\n",
529 dccp_role(sk), sk, len);
530 rc = -EINVAL;
531 } else {
532 opt_val = get_unaligned((__be32 *)value);
533 opt_recv->ccid3or_receive_rate = ntohl(opt_val);
534 ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n", 504 ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n",
535 dccp_role(sk), sk, 505 dccp_role(sk), sk, opt_val);
536 opt_recv->ccid3or_receive_rate); 506 } else {
507 opt_recv->ccid3or_loss_event_rate = opt_val;
508 ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
509 dccp_role(sk), sk, opt_val);
537 } 510 }
538 break;
539 } 511 }
540 512 return 0;
541 return rc;
542} 513}
543 514
544static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) 515static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 4a00174a97dd..9eb90b863abd 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -68,9 +68,6 @@ enum ccid3_options {
68}; 68};
69 69
70struct ccid3_options_received { 70struct ccid3_options_received {
71 u64 ccid3or_seqno:48,
72 ccid3or_loss_intervals_idx:16;
73 u16 ccid3or_loss_intervals_len;
74 u32 ccid3or_loss_event_rate; 71 u32 ccid3or_loss_event_rate;
75 u32 ccid3or_receive_rate; 72 u32 ccid3or_receive_rate;
76}; 73};