aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Bittau <a.bittau@cs.ucl.ac.uk>2006-03-20 22:23:32 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-20 22:23:32 -0500
commit60fe62e789076ae7c13f7ffb35fec4b24802530d (patch)
treecc8d507a4276c3d5a2bcb72746660d485bc2e045
parenta193a4abdd1f742a57f3f70b6a83c3e536876e97 (diff)
[DCCP]: sparse endianness annotations
This also fixes the layout of dccp_hdr short sequence numbers, problem was not fatal now as we only support long (48 bits) sequence numbers. Signed-off-by: Andrea Bittau <a.bittau@cs.ucl.ac.uk> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/dccp.h52
-rw-r--r--net/dccp/ccids/ccid3.c6
-rw-r--r--net/dccp/dccp.h23
-rw-r--r--net/dccp/ipv4.c12
-rw-r--r--net/dccp/ipv6.c4
-rw-r--r--net/dccp/options.c27
-rw-r--r--net/dccp/proto.c6
7 files changed, 54 insertions, 76 deletions
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index bdd756cc60b1..496dbad8e896 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -18,7 +18,7 @@
18 * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x 18 * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
19 */ 19 */
20struct dccp_hdr { 20struct dccp_hdr {
21 __u16 dccph_sport, 21 __be16 dccph_sport,
22 dccph_dport; 22 dccph_dport;
23 __u8 dccph_doff; 23 __u8 dccph_doff;
24#if defined(__LITTLE_ENDIAN_BITFIELD) 24#if defined(__LITTLE_ENDIAN_BITFIELD)
@@ -32,18 +32,18 @@ struct dccp_hdr {
32#endif 32#endif
33 __u16 dccph_checksum; 33 __u16 dccph_checksum;
34#if defined(__LITTLE_ENDIAN_BITFIELD) 34#if defined(__LITTLE_ENDIAN_BITFIELD)
35 __u32 dccph_x:1, 35 __u8 dccph_x:1,
36 dccph_type:4, 36 dccph_type:4,
37 dccph_reserved:3, 37 dccph_reserved:3;
38 dccph_seq:24;
39#elif defined(__BIG_ENDIAN_BITFIELD) 38#elif defined(__BIG_ENDIAN_BITFIELD)
40 __u32 dccph_reserved:3, 39 __u8 dccph_reserved:3,
41 dccph_type:4, 40 dccph_type:4,
42 dccph_x:1, 41 dccph_x:1;
43 dccph_seq:24;
44#else 42#else
45#error "Adjust your <asm/byteorder.h> defines" 43#error "Adjust your <asm/byteorder.h> defines"
46#endif 44#endif
45 __u8 dccph_seq2;
46 __be16 dccph_seq;
47}; 47};
48 48
49/** 49/**
@@ -52,7 +52,7 @@ struct dccp_hdr {
52 * @dccph_seq_low - low 24 bits of a 48 bit seq packet 52 * @dccph_seq_low - low 24 bits of a 48 bit seq packet
53 */ 53 */
54struct dccp_hdr_ext { 54struct dccp_hdr_ext {
55 __u32 dccph_seq_low; 55 __be32 dccph_seq_low;
56}; 56};
57 57
58/** 58/**
@@ -62,7 +62,7 @@ struct dccp_hdr_ext {
62 * @dccph_req_options - list of options (must be a multiple of 32 bits 62 * @dccph_req_options - list of options (must be a multiple of 32 bits
63 */ 63 */
64struct dccp_hdr_request { 64struct dccp_hdr_request {
65 __u32 dccph_req_service; 65 __be32 dccph_req_service;
66}; 66};
67/** 67/**
68 * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets 68 * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
@@ -71,9 +71,9 @@ struct dccp_hdr_request {
71 * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR 71 * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
72 */ 72 */
73struct dccp_hdr_ack_bits { 73struct dccp_hdr_ack_bits {
74 __u32 dccph_reserved1:8, 74 __be16 dccph_reserved1;
75 dccph_ack_nr_high:24; 75 __be16 dccph_ack_nr_high;
76 __u32 dccph_ack_nr_low; 76 __be32 dccph_ack_nr_low;
77}; 77};
78/** 78/**
79 * struct dccp_hdr_response - Conection initiation response header 79 * struct dccp_hdr_response - Conection initiation response header
@@ -85,7 +85,7 @@ struct dccp_hdr_ack_bits {
85 */ 85 */
86struct dccp_hdr_response { 86struct dccp_hdr_response {
87 struct dccp_hdr_ack_bits dccph_resp_ack; 87 struct dccp_hdr_ack_bits dccph_resp_ack;
88 __u32 dccph_resp_service; 88 __be32 dccph_resp_service;
89}; 89};
90 90
91/** 91/**
@@ -269,16 +269,12 @@ static inline unsigned int dccp_basic_hdr_len(const struct sk_buff *skb)
269static inline __u64 dccp_hdr_seq(const struct sk_buff *skb) 269static inline __u64 dccp_hdr_seq(const struct sk_buff *skb)
270{ 270{
271 const struct dccp_hdr *dh = dccp_hdr(skb); 271 const struct dccp_hdr *dh = dccp_hdr(skb);
272#if defined(__LITTLE_ENDIAN_BITFIELD) 272 __u64 seq_nr = ntohs(dh->dccph_seq);
273 __u64 seq_nr = ntohl(dh->dccph_seq << 8);
274#elif defined(__BIG_ENDIAN_BITFIELD)
275 __u64 seq_nr = ntohl(dh->dccph_seq);
276#else
277#error "Adjust your <asm/byteorder.h> defines"
278#endif
279 273
280 if (dh->dccph_x != 0) 274 if (dh->dccph_x != 0)
281 seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low); 275 seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low);
276 else
277 seq_nr += (u32)dh->dccph_seq2 << 16;
282 278
283 return seq_nr; 279 return seq_nr;
284} 280}
@@ -296,13 +292,7 @@ static inline struct dccp_hdr_ack_bits *dccp_hdr_ack_bits(const struct sk_buff *
296static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb) 292static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb)
297{ 293{
298 const struct dccp_hdr_ack_bits *dhack = dccp_hdr_ack_bits(skb); 294 const struct dccp_hdr_ack_bits *dhack = dccp_hdr_ack_bits(skb);
299#if defined(__LITTLE_ENDIAN_BITFIELD) 295 return ((u64)ntohs(dhack->dccph_ack_nr_high) << 32) + ntohl(dhack->dccph_ack_nr_low);
300 return (((u64)ntohl(dhack->dccph_ack_nr_high << 8)) << 32) + ntohl(dhack->dccph_ack_nr_low);
301#elif defined(__BIG_ENDIAN_BITFIELD)
302 return (((u64)ntohl(dhack->dccph_ack_nr_high)) << 32) + ntohl(dhack->dccph_ack_nr_low);
303#else
304#error "Adjust your <asm/byteorder.h> defines"
305#endif
306} 296}
307 297
308static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb) 298static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb)
@@ -387,7 +377,7 @@ struct dccp_request_sock {
387 struct inet_request_sock dreq_inet_rsk; 377 struct inet_request_sock dreq_inet_rsk;
388 __u64 dreq_iss; 378 __u64 dreq_iss;
389 __u64 dreq_isr; 379 __u64 dreq_isr;
390 __u32 dreq_service; 380 __be32 dreq_service;
391}; 381};
392 382
393static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req) 383static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
@@ -415,13 +405,13 @@ enum dccp_role {
415 405
416struct dccp_service_list { 406struct dccp_service_list {
417 __u32 dccpsl_nr; 407 __u32 dccpsl_nr;
418 __u32 dccpsl_list[0]; 408 __be32 dccpsl_list[0];
419}; 409};
420 410
421#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1) 411#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
422 412
423static inline int dccp_list_has_service(const struct dccp_service_list *sl, 413static inline int dccp_list_has_service(const struct dccp_service_list *sl,
424 const u32 service) 414 const __be32 service)
425{ 415{
426 if (likely(sl != NULL)) { 416 if (likely(sl != NULL)) {
427 u32 i = sl->dccpsl_nr; 417 u32 i = sl->dccpsl_nr;
@@ -467,7 +457,7 @@ struct dccp_sock {
467 __u64 dccps_gss; 457 __u64 dccps_gss;
468 __u64 dccps_gsr; 458 __u64 dccps_gsr;
469 __u64 dccps_gar; 459 __u64 dccps_gar;
470 __u32 dccps_service; 460 __be32 dccps_service;
471 struct dccp_service_list *dccps_service_list; 461 struct dccp_service_list *dccps_service_list;
472 struct timeval dccps_timestamp_time; 462 struct timeval dccps_timestamp_time;
473 __u32 dccps_timestamp_echo; 463 __u32 dccps_timestamp_echo;
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 0587f52e4af1..86201631fb6e 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -615,7 +615,7 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
615 __FUNCTION__, dccp_role(sk), sk); 615 __FUNCTION__, dccp_role(sk), sk);
616 rc = -EINVAL; 616 rc = -EINVAL;
617 } else { 617 } else {
618 opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value); 618 opt_recv->ccid3or_loss_event_rate = ntohl(*(__be32 *)value);
619 ccid3_pr_debug("%s, sk=%p, LOSS_EVENT_RATE=%u\n", 619 ccid3_pr_debug("%s, sk=%p, LOSS_EVENT_RATE=%u\n",
620 dccp_role(sk), sk, 620 dccp_role(sk), sk,
621 opt_recv->ccid3or_loss_event_rate); 621 opt_recv->ccid3or_loss_event_rate);
@@ -636,7 +636,7 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
636 __FUNCTION__, dccp_role(sk), sk); 636 __FUNCTION__, dccp_role(sk), sk);
637 rc = -EINVAL; 637 rc = -EINVAL;
638 } else { 638 } else {
639 opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value); 639 opt_recv->ccid3or_receive_rate = ntohl(*(__be32 *)value);
640 ccid3_pr_debug("%s, sk=%p, RECEIVE_RATE=%u\n", 640 ccid3_pr_debug("%s, sk=%p, RECEIVE_RATE=%u\n",
641 dccp_role(sk), sk, 641 dccp_role(sk), sk,
642 opt_recv->ccid3or_receive_rate); 642 opt_recv->ccid3or_receive_rate);
@@ -777,7 +777,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
777static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) 777static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
778{ 778{
779 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 779 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
780 u32 x_recv, pinv; 780 __be32 x_recv, pinv;
781 781
782 BUG_ON(hcrx == NULL); 782 BUG_ON(hcrx == NULL);
783 783
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 93f26dd6e6cb..1764adb4f15e 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -262,7 +262,7 @@ extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
262 int addr_len); 262 int addr_len);
263 263
264extern int dccp_v4_checksum(const struct sk_buff *skb, 264extern int dccp_v4_checksum(const struct sk_buff *skb,
265 const u32 saddr, const u32 daddr); 265 const __be32 saddr, const __be32 daddr);
266 266
267extern int dccp_v4_send_reset(struct sock *sk, 267extern int dccp_v4_send_reset(struct sock *sk,
268 enum dccp_reset_codes code); 268 enum dccp_reset_codes code);
@@ -270,7 +270,7 @@ extern void dccp_send_close(struct sock *sk, const int active);
270extern int dccp_invalid_packet(struct sk_buff *skb); 270extern int dccp_invalid_packet(struct sk_buff *skb);
271 271
272static inline int dccp_bad_service_code(const struct sock *sk, 272static inline int dccp_bad_service_code(const struct sock *sk,
273 const __u32 service) 273 const __be32 service)
274{ 274{
275 const struct dccp_sock *dp = dccp_sk(sk); 275 const struct dccp_sock *dp = dccp_sk(sk);
276 276
@@ -334,27 +334,16 @@ static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
334{ 334{
335 struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh + 335 struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh +
336 sizeof(*dh)); 336 sizeof(*dh));
337 337 dh->dccph_seq2 = 0;
338#if defined(__LITTLE_ENDIAN_BITFIELD) 338 dh->dccph_seq = htons((gss >> 32) & 0xfffff);
339 dh->dccph_seq = htonl((gss >> 32)) >> 8;
340#elif defined(__BIG_ENDIAN_BITFIELD)
341 dh->dccph_seq = htonl((gss >> 32));
342#else
343#error "Adjust your <asm/byteorder.h> defines"
344#endif
345 dhx->dccph_seq_low = htonl(gss & 0xffffffff); 339 dhx->dccph_seq_low = htonl(gss & 0xffffffff);
346} 340}
347 341
348static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, 342static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack,
349 const u64 gsr) 343 const u64 gsr)
350{ 344{
351#if defined(__LITTLE_ENDIAN_BITFIELD) 345 dhack->dccph_reserved1 = 0;
352 dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8; 346 dhack->dccph_ack_nr_high = htons(gsr >> 32);
353#elif defined(__BIG_ENDIAN_BITFIELD)
354 dhack->dccph_ack_nr_high = htonl((gsr >> 32));
355#else
356#error "Adjust your <asm/byteorder.h> defines"
357#endif
358 dhack->dccph_ack_nr_low = htonl(gsr & 0xffffffff); 347 dhack->dccph_ack_nr_low = htonl(gsr & 0xffffffff);
359} 348}
360 349
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index aa7708fed32e..be5ce57b8046 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -498,9 +498,9 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
498 struct dccp_sock dp; 498 struct dccp_sock dp;
499 struct request_sock *req; 499 struct request_sock *req;
500 struct dccp_request_sock *dreq; 500 struct dccp_request_sock *dreq;
501 const __u32 saddr = skb->nh.iph->saddr; 501 const __be32 saddr = skb->nh.iph->saddr;
502 const __u32 daddr = skb->nh.iph->daddr; 502 const __be32 daddr = skb->nh.iph->daddr;
503 const __u32 service = dccp_hdr_request(skb)->dccph_req_service; 503 const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
504 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 504 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
505 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; 505 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
506 506
@@ -662,8 +662,8 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
662 return sk; 662 return sk;
663} 663}
664 664
665int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, 665int dccp_v4_checksum(const struct sk_buff *skb, const __be32 saddr,
666 const u32 daddr) 666 const __be32 daddr)
667{ 667{
668 const struct dccp_hdr* dh = dccp_hdr(skb); 668 const struct dccp_hdr* dh = dccp_hdr(skb);
669 int checksum_len; 669 int checksum_len;
@@ -683,7 +683,7 @@ int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr,
683} 683}
684 684
685static int dccp_v4_verify_checksum(struct sk_buff *skb, 685static int dccp_v4_verify_checksum(struct sk_buff *skb,
686 const u32 saddr, const u32 daddr) 686 const __be32 saddr, const __be32 daddr)
687{ 687{
688 struct dccp_hdr *dh = dccp_hdr(skb); 688 struct dccp_hdr *dh = dccp_hdr(skb);
689 int checksum_len; 689 int checksum_len;
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 80c4d048869e..ad5a1c66362d 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -264,7 +264,7 @@ failure:
264} 264}
265 265
266static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 266static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
267 int type, int code, int offset, __u32 info) 267 int type, int code, int offset, __be32 info)
268{ 268{
269 struct ipv6hdr *hdr = (struct ipv6hdr *)skb->data; 269 struct ipv6hdr *hdr = (struct ipv6hdr *)skb->data;
270 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset); 270 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
@@ -678,7 +678,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
678 struct dccp_request_sock *dreq; 678 struct dccp_request_sock *dreq;
679 struct inet6_request_sock *ireq6; 679 struct inet6_request_sock *ireq6;
680 struct ipv6_pinfo *np = inet6_sk(sk); 680 struct ipv6_pinfo *np = inet6_sk(sk);
681 const __u32 service = dccp_hdr_request(skb)->dccph_req_service; 681 const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
682 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 682 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
683 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; 683 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
684 684
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
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 1a8cf8ecfe63..53735ee2bbd1 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -221,7 +221,7 @@ int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
221 221
222EXPORT_SYMBOL_GPL(dccp_ioctl); 222EXPORT_SYMBOL_GPL(dccp_ioctl);
223 223
224static int dccp_setsockopt_service(struct sock *sk, const u32 service, 224static int dccp_setsockopt_service(struct sock *sk, const __be32 service,
225 char __user *optval, int optlen) 225 char __user *optval, int optlen)
226{ 226{
227 struct dccp_sock *dp = dccp_sk(sk); 227 struct dccp_sock *dp = dccp_sk(sk);
@@ -349,7 +349,7 @@ int dccp_setsockopt(struct sock *sk, int level, int optname,
349EXPORT_SYMBOL_GPL(dccp_setsockopt); 349EXPORT_SYMBOL_GPL(dccp_setsockopt);
350 350
351static int dccp_getsockopt_service(struct sock *sk, int len, 351static int dccp_getsockopt_service(struct sock *sk, int len,
352 u32 __user *optval, 352 __be32 __user *optval,
353 int __user *optlen) 353 int __user *optlen)
354{ 354{
355 const struct dccp_sock *dp = dccp_sk(sk); 355 const struct dccp_sock *dp = dccp_sk(sk);
@@ -404,7 +404,7 @@ int dccp_getsockopt(struct sock *sk, int level, int optname,
404 break; 404 break;
405 case DCCP_SOCKOPT_SERVICE: 405 case DCCP_SOCKOPT_SERVICE:
406 return dccp_getsockopt_service(sk, len, 406 return dccp_getsockopt_service(sk, len,
407 (u32 __user *)optval, optlen); 407 (__be32 __user *)optval, optlen);
408 case 128 ... 191: 408 case 128 ... 191:
409 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname, 409 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
410 len, (u32 __user *)optval, optlen); 410 len, (u32 __user *)optval, optlen);