Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41878
b: refs/heads/master
c: 522f1d0
h: refs/heads/master
v: v3
  • Loading branch information
Andrea Bittau authored and David S. Miller committed Dec 3, 2006
1 parent e7e260a commit e36ab1a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bdf13d208dee4ada6d2b422536a12b45d5831aa3
refs/heads/master: 522f1d095bf76dbe2430fb9a9a257c0f27033f31
46 changes: 32 additions & 14 deletions trunk/net/dccp/ackvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
{
struct dccp_sock *dp = dccp_sk(sk);
struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
int len = av->dccpav_vec_len + 2;
/* Figure out how many options do we need to represent the ackvec */
const u16 nr_opts = (av->dccpav_vec_len +
DCCP_MAX_ACKVEC_OPT_LEN - 1) /
DCCP_MAX_ACKVEC_OPT_LEN;
u16 len = av->dccpav_vec_len + 2 * nr_opts, i;
struct timeval now;
u32 elapsed_time;
unsigned char *to, *from;
const unsigned char *tail, *from;
unsigned char *to;
struct dccp_ackvec_record *avr;

if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
Expand All @@ -90,24 +95,37 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)

DCCP_SKB_CB(skb)->dccpd_opt_len += len;

to = skb_push(skb, len);
*to++ = DCCPO_ACK_VECTOR_0;
*to++ = len;

to = skb_push(skb, len);
len = av->dccpav_vec_len;
from = av->dccpav_buf + av->dccpav_buf_head;
tail = av->dccpav_buf + DCCP_MAX_ACKVEC_LEN;

for (i = 0; i < nr_opts; ++i) {
int copylen = len;

if (len > DCCP_MAX_ACKVEC_OPT_LEN)
copylen = DCCP_MAX_ACKVEC_OPT_LEN;

/* Check if buf_head wraps */
if ((int)av->dccpav_buf_head + len > DCCP_MAX_ACKVEC_LEN) {
const u32 tailsize = DCCP_MAX_ACKVEC_LEN - av->dccpav_buf_head;
*to++ = DCCPO_ACK_VECTOR_0;
*to++ = copylen + 2;

/* Check if buf_head wraps */
if (from + copylen > tail) {
const u16 tailsize = tail - from;

memcpy(to, from, tailsize);
to += tailsize;
len -= tailsize;
copylen -= tailsize;
from = av->dccpav_buf;
}

memcpy(to, from, tailsize);
to += tailsize;
len -= tailsize;
from = av->dccpav_buf;
memcpy(to, from, copylen);
from += copylen;
to += copylen;
len -= copylen;
}

memcpy(to, from, len);
/*
* From RFC 4340, A.2:
*
Expand Down

0 comments on commit e36ab1a

Please sign in to comment.