Commit df054e1d authored by Gerrit Renker's avatar Gerrit Renker Committed by David S. Miller

[CCID2]: Don't assign negative values to Ack Ratio

Since it makes not sense to assign negative values to Ack Ratio, this
patch disallows this possibility.

As a consequence, a Bug test for negative Ack Ratio values becomes obsolete.

Furthermore, a check against overflow (as Ack Ratio may not exceed 2 bytes,
due to RFC 4340, 11.3) has been added.
Signed-off-by: default avatarGerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: default avatarIan McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cfbbeabc
...@@ -140,7 +140,7 @@ static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) ...@@ -140,7 +140,7 @@ static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
return 1; /* XXX CCID should dequeue when ready instead of polling */ return 1; /* XXX CCID should dequeue when ready instead of polling */
} }
static void ccid2_change_l_ack_ratio(struct sock *sk, int val) static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
/* /*
...@@ -159,9 +159,10 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, int val) ...@@ -159,9 +159,10 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, int val)
if (val > max) if (val > max)
val = max; val = max;
} }
if (val > 0xFFFF) /* RFC 4340, 11.3 */
val = 0xFFFF;
ccid2_pr_debug("changing local ack ratio to %d\n", val); ccid2_pr_debug("changing local ack ratio to %u\n", val);
WARN_ON(val <= 0);
dp->dccps_l_ack_ratio = val; dp->dccps_l_ack_ratio = val;
} }
...@@ -572,7 +573,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) ...@@ -572,7 +573,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
hctx->ccid2hctx_rpdupack = -1; /* XXX lame */ hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
hctx->ccid2hctx_rpseq = 0; hctx->ccid2hctx_rpseq = 0;
ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio << 1); ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment