diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-07-13 06:51:40 -0400 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-07-13 06:51:40 -0400 |
commit | 5b5d0e704880addfd979c262e6441f126708539c (patch) | |
tree | 1b3bff6cd378c858ab245de3a40c3510d4ba4745 /net/dccp/options.c | |
parent | 2013c7e35aeba39777f9b3eef8a70207b3931152 (diff) |
dccp: Upgrade NDP count from 3 to 6 bytes
RFC 4340, 7.7 specifies up to 6 bytes for the NDP Count option, whereas the code
is currently limited to up to 3 bytes. This seems to be a relict of an earlier
draft version and is brought up to date by the patch.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/options.c')
-rw-r--r-- | net/dccp/options.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/dccp/options.c b/net/dccp/options.c index 43bc24e761d0..dc7c158a2f4b 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c | |||
@@ -124,12 +124,12 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq, | |||
124 | mandatory = 1; | 124 | mandatory = 1; |
125 | break; | 125 | break; |
126 | case DCCPO_NDP_COUNT: | 126 | case DCCPO_NDP_COUNT: |
127 | if (len > 3) | 127 | if (len > 6) |
128 | goto out_invalid_option; | 128 | goto out_invalid_option; |
129 | 129 | ||
130 | opt_recv->dccpor_ndp = dccp_decode_value_var(value, len); | 130 | opt_recv->dccpor_ndp = dccp_decode_value_var(value, len); |
131 | dccp_pr_debug("%s rx opt: NDP count=%d\n", dccp_role(sk), | 131 | dccp_pr_debug("%s opt: NDP count=%llu\n", dccp_role(sk), |
132 | opt_recv->dccpor_ndp); | 132 | (unsigned long long)opt_recv->dccpor_ndp); |
133 | break; | 133 | break; |
134 | case DCCPO_CHANGE_L: | 134 | case DCCPO_CHANGE_L: |
135 | /* fall through */ | 135 | /* fall through */ |
@@ -307,9 +307,11 @@ static void dccp_encode_value_var(const u32 value, unsigned char *to, | |||
307 | *to++ = (value & 0xFF); | 307 | *to++ = (value & 0xFF); |
308 | } | 308 | } |
309 | 309 | ||
310 | static inline int dccp_ndp_len(const int ndp) | 310 | static inline u8 dccp_ndp_len(const u64 ndp) |
311 | { | 311 | { |
312 | return likely(ndp <= 0xFF) ? 1 : ndp <= 0xFFFF ? 2 : 3; | 312 | if (likely(ndp <= 0xFF)) |
313 | return 1; | ||
314 | return likely(ndp <= USHORT_MAX) ? 2 : (ndp <= UINT_MAX ? 4 : 6); | ||
313 | } | 315 | } |
314 | 316 | ||
315 | int dccp_insert_option(struct sock *sk, struct sk_buff *skb, | 317 | int dccp_insert_option(struct sock *sk, struct sk_buff *skb, |
@@ -336,7 +338,7 @@ EXPORT_SYMBOL_GPL(dccp_insert_option); | |||
336 | static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb) | 338 | static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb) |
337 | { | 339 | { |
338 | struct dccp_sock *dp = dccp_sk(sk); | 340 | struct dccp_sock *dp = dccp_sk(sk); |
339 | int ndp = dp->dccps_ndp_count; | 341 | u64 ndp = dp->dccps_ndp_count; |
340 | 342 | ||
341 | if (dccp_non_data_packet(skb)) | 343 | if (dccp_non_data_packet(skb)) |
342 | ++dp->dccps_ndp_count; | 344 | ++dp->dccps_ndp_count; |