aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/options.c')
-rw-r--r--net/dccp/options.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 7f99306c8e99..7d73b33a6043 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -155,7 +155,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
155 if (len != 4) 155 if (len != 4)
156 goto out_invalid_option; 156 goto out_invalid_option;
157 157
158 opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); 158 opt_recv->dccpor_timestamp = ntohl(*(__be32 *)value);
159 159
160 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; 160 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
161 dccp_timestamp(sk, &dp->dccps_timestamp_time); 161 dccp_timestamp(sk, &dp->dccps_timestamp_time);
@@ -169,7 +169,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
169 if (len != 4 && len != 6 && len != 8) 169 if (len != 4 && len != 6 && len != 8)
170 goto out_invalid_option; 170 goto out_invalid_option;
171 171
172 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value); 172 opt_recv->dccpor_timestamp_echo = ntohl(*(__be32 *)value);
173 173
174 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, ", 174 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, ",
175 debug_prefix, 175 debug_prefix,
@@ -183,9 +183,9 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
183 break; 183 break;
184 184
185 if (len == 6) 185 if (len == 6)
186 elapsed_time = ntohs(*(u16 *)(value + 4)); 186 elapsed_time = ntohs(*(__be16 *)(value + 4));
187 else 187 else
188 elapsed_time = ntohl(*(u32 *)(value + 4)); 188 elapsed_time = ntohl(*(__be32 *)(value + 4));
189 189
190 /* Give precedence to the biggest ELAPSED_TIME */ 190 /* Give precedence to the biggest ELAPSED_TIME */
191 if (elapsed_time > opt_recv->dccpor_elapsed_time) 191 if (elapsed_time > opt_recv->dccpor_elapsed_time)
@@ -199,9 +199,9 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
199 continue; 199 continue;
200 200
201 if (len == 2) 201 if (len == 2)
202 elapsed_time = ntohs(*(u16 *)value); 202 elapsed_time = ntohs(*(__be16 *)value);
203 else 203 else
204 elapsed_time = ntohl(*(u32 *)value); 204 elapsed_time = ntohl(*(__be32 *)value);
205 205
206 if (elapsed_time > opt_recv->dccpor_elapsed_time) 206 if (elapsed_time > opt_recv->dccpor_elapsed_time)
207 opt_recv->dccpor_elapsed_time = elapsed_time; 207 opt_recv->dccpor_elapsed_time = elapsed_time;
@@ -358,10 +358,10 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
358 *to++ = len; 358 *to++ = len;
359 359
360 if (elapsed_time_len == 2) { 360 if (elapsed_time_len == 2) {
361 const u16 var16 = htons((u16)elapsed_time); 361 const __be16 var16 = htons((u16)elapsed_time);
362 memcpy(to, &var16, 2); 362 memcpy(to, &var16, 2);
363 } else { 363 } else {
364 const u32 var32 = htonl(elapsed_time); 364 const __be32 var32 = htonl(elapsed_time);
365 memcpy(to, &var32, 4); 365 memcpy(to, &var32, 4);
366 } 366 }
367 367
@@ -392,14 +392,13 @@ EXPORT_SYMBOL_GPL(dccp_timestamp);
392void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) 392void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
393{ 393{
394 struct timeval tv; 394 struct timeval tv;
395 u32 now; 395 __be32 now;
396 396
397 dccp_timestamp(sk, &tv); 397 dccp_timestamp(sk, &tv);
398 now = timeval_usecs(&tv) / 10; 398 now = htonl(timeval_usecs(&tv) / 10);
399 /* yes this will overflow but that is the point as we want a 399 /* yes this will overflow but that is the point as we want a
400 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ 400 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
401 401
402 now = htonl(now);
403 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now)); 402 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
404} 403}
405 404
@@ -414,7 +413,7 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk,
414 "CLIENT TX opt: " : "server TX opt: "; 413 "CLIENT TX opt: " : "server TX opt: ";
415#endif 414#endif
416 struct timeval now; 415 struct timeval now;
417 u32 tstamp_echo; 416 __be32 tstamp_echo;
418 u32 elapsed_time; 417 u32 elapsed_time;
419 int len, elapsed_time_len; 418 int len, elapsed_time_len;
420 unsigned char *to; 419 unsigned char *to;
@@ -441,10 +440,10 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk,
441 to += 4; 440 to += 4;
442 441
443 if (elapsed_time_len == 2) { 442 if (elapsed_time_len == 2) {
444 const u16 var16 = htons((u16)elapsed_time); 443 const __be16 var16 = htons((u16)elapsed_time);
445 memcpy(to, &var16, 2); 444 memcpy(to, &var16, 2);
446 } else if (elapsed_time_len == 4) { 445 } else if (elapsed_time_len == 4) {
447 const u32 var32 = htonl(elapsed_time); 446 const __be32 var32 = htonl(elapsed_time);
448 memcpy(to, &var32, 4); 447 memcpy(to, &var32, 4);
449 } 448 }
450 449