aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ipv6.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-03-21 01:01:29 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:01:29 -0500
commit45329e71eeb6cb483c6e7fe9e6f2849dd2932cb5 (patch)
tree95d3aea5bfee63103ff6132c630cc220820d5bbb /net/dccp/ipv6.c
parentc4d9390941aee136fd35bb38eb1d6de4e3b1487d (diff)
[DCCP] ipv6: cleanups
No changes in the logic were made, just removing trailing whitespaces, etc. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/ipv6.c')
-rw-r--r--net/dccp/ipv6.c256
1 files changed, 129 insertions, 127 deletions
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 6bd9979334a2..f28f38fd0134 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * DCCP over IPv6 2 * DCCP over IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Based on net/dccp6/ipv6.c 5 * Based on net/dccp6/ipv6.c
6 * 6 *
@@ -66,8 +66,8 @@ static void dccp_v6_hash(struct sock *sk)
66} 66}
67 67
68static inline u16 dccp_v6_check(struct dccp_hdr *dh, int len, 68static inline u16 dccp_v6_check(struct dccp_hdr *dh, int len,
69 struct in6_addr *saddr, 69 struct in6_addr *saddr,
70 struct in6_addr *daddr, 70 struct in6_addr *daddr,
71 unsigned long base) 71 unsigned long base)
72{ 72{
73 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_DCCP, base); 73 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_DCCP, base);
@@ -82,17 +82,17 @@ static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb)
82 skb->nh.ipv6h->saddr.s6_addr32, 82 skb->nh.ipv6h->saddr.s6_addr32,
83 dh->dccph_dport, 83 dh->dccph_dport,
84 dh->dccph_sport); 84 dh->dccph_sport);
85 else 85
86 return secure_dccp_sequence_number(skb->nh.iph->daddr, 86 return secure_dccp_sequence_number(skb->nh.iph->daddr,
87 skb->nh.iph->saddr, 87 skb->nh.iph->saddr,
88 dh->dccph_dport, 88 dh->dccph_dport,
89 dh->dccph_sport); 89 dh->dccph_sport);
90} 90}
91 91
92static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 92static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
93 int addr_len) 93 int addr_len)
94{ 94{
95 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; 95 struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
96 struct inet_connection_sock *icsk = inet_csk(sk); 96 struct inet_connection_sock *icsk = inet_csk(sk);
97 struct inet_sock *inet = inet_sk(sk); 97 struct inet_sock *inet = inet_sk(sk);
98 struct ipv6_pinfo *np = inet6_sk(sk); 98 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -105,10 +105,10 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
105 105
106 dp->dccps_role = DCCP_ROLE_CLIENT; 106 dp->dccps_role = DCCP_ROLE_CLIENT;
107 107
108 if (addr_len < SIN6_LEN_RFC2133) 108 if (addr_len < SIN6_LEN_RFC2133)
109 return -EINVAL; 109 return -EINVAL;
110 110
111 if (usin->sin6_family != AF_INET6) 111 if (usin->sin6_family != AF_INET6)
112 return -EAFNOSUPPORT; 112 return -EAFNOSUPPORT;
113 113
114 memset(&fl, 0, sizeof(fl)); 114 memset(&fl, 0, sizeof(fl));
@@ -125,17 +125,15 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
125 fl6_sock_release(flowlabel); 125 fl6_sock_release(flowlabel);
126 } 126 }
127 } 127 }
128
129 /* 128 /*
130 * connect() to INADDR_ANY means loopback (BSD'ism). 129 * connect() to INADDR_ANY means loopback (BSD'ism).
131 */ 130 */
132 131 if (ipv6_addr_any(&usin->sin6_addr))
133 if (ipv6_addr_any(&usin->sin6_addr)) 132 usin->sin6_addr.s6_addr[15] = 1;
134 usin->sin6_addr.s6_addr[15] = 0x1;
135 133
136 addr_type = ipv6_addr_type(&usin->sin6_addr); 134 addr_type = ipv6_addr_type(&usin->sin6_addr);
137 135
138 if(addr_type & IPV6_ADDR_MULTICAST) 136 if (addr_type & IPV6_ADDR_MULTICAST)
139 return -ENETUNREACH; 137 return -ENETUNREACH;
140 138
141 if (addr_type & IPV6_ADDR_LINKLOCAL) { 139 if (addr_type & IPV6_ADDR_LINKLOCAL) {
@@ -160,9 +158,8 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
160 np->flow_label = fl.fl6_flowlabel; 158 np->flow_label = fl.fl6_flowlabel;
161 159
162 /* 160 /*
163 * DCCP over IPv4 161 * DCCP over IPv4
164 */ 162 */
165
166 if (addr_type == IPV6_ADDR_MAPPED) { 163 if (addr_type == IPV6_ADDR_MAPPED) {
167 u32 exthdrlen = icsk->icsk_ext_hdr_len; 164 u32 exthdrlen = icsk->icsk_ext_hdr_len;
168 struct sockaddr_in sin; 165 struct sockaddr_in sin;
@@ -180,7 +177,6 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
180 sk->sk_backlog_rcv = dccp_v4_do_rcv; 177 sk->sk_backlog_rcv = dccp_v4_do_rcv;
181 178
182 err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); 179 err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
183
184 if (err) { 180 if (err) {
185 icsk->icsk_ext_hdr_len = exthdrlen; 181 icsk->icsk_ext_hdr_len = exthdrlen;
186 icsk->icsk_af_ops = &dccp_ipv6_af_ops; 182 icsk->icsk_af_ops = &dccp_ipv6_af_ops;
@@ -206,8 +202,9 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
206 fl.fl_ip_dport = usin->sin6_port; 202 fl.fl_ip_dport = usin->sin6_port;
207 fl.fl_ip_sport = inet->sport; 203 fl.fl_ip_sport = inet->sport;
208 204
209 if (np->opt && np->opt->srcrt) { 205 if (np->opt != NULL && np->opt->srcrt != NULL) {
210 struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt; 206 const struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
207
211 ipv6_addr_copy(&final, &fl.fl6_dst); 208 ipv6_addr_copy(&final, &fl.fl6_dst);
212 ipv6_addr_copy(&fl.fl6_dst, rt0->addr); 209 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
213 final_p = &final; 210 final_p = &final;
@@ -216,10 +213,12 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
216 err = ip6_dst_lookup(sk, &dst, &fl); 213 err = ip6_dst_lookup(sk, &dst, &fl);
217 if (err) 214 if (err)
218 goto failure; 215 goto failure;
216
219 if (final_p) 217 if (final_p)
220 ipv6_addr_copy(&fl.fl6_dst, final_p); 218 ipv6_addr_copy(&fl.fl6_dst, final_p);
221 219
222 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) 220 err = xfrm_lookup(&dst, &fl, sk, 0);
221 if (err < 0)
223 goto failure; 222 goto failure;
224 223
225 if (saddr == NULL) { 224 if (saddr == NULL) {
@@ -234,7 +233,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
234 ip6_dst_store(sk, dst, NULL); 233 ip6_dst_store(sk, dst, NULL);
235 234
236 icsk->icsk_ext_hdr_len = 0; 235 icsk->icsk_ext_hdr_len = 0;
237 if (np->opt) 236 if (np->opt != NULL)
238 icsk->icsk_ext_hdr_len = (np->opt->opt_flen + 237 icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
239 np->opt->opt_nflen); 238 np->opt->opt_nflen);
240 239
@@ -308,7 +307,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
308 307
309 /* icmp should have updated the destination cache entry */ 308 /* icmp should have updated the destination cache entry */
310 dst = __sk_dst_check(sk, np->dst_cookie); 309 dst = __sk_dst_check(sk, np->dst_cookie);
311
312 if (dst == NULL) { 310 if (dst == NULL) {
313 struct inet_sock *inet = inet_sk(sk); 311 struct inet_sock *inet = inet_sk(sk);
314 struct flowi fl; 312 struct flowi fl;
@@ -325,16 +323,17 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
325 fl.fl_ip_dport = inet->dport; 323 fl.fl_ip_dport = inet->dport;
326 fl.fl_ip_sport = inet->sport; 324 fl.fl_ip_sport = inet->sport;
327 325
328 if ((err = ip6_dst_lookup(sk, &dst, &fl))) { 326 err = ip6_dst_lookup(sk, &dst, &fl);
327 if (err) {
329 sk->sk_err_soft = -err; 328 sk->sk_err_soft = -err;
330 goto out; 329 goto out;
331 } 330 }
332 331
333 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { 332 err = xfrm_lookup(&dst, &fl, sk, 0);
333 if (err < 0) {
334 sk->sk_err_soft = -err; 334 sk->sk_err_soft = -err;
335 goto out; 335 goto out;
336 } 336 }
337
338 } else 337 } else
339 dst_hold(dst); 338 dst_hold(dst);
340 339
@@ -358,11 +357,12 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
358 req = inet6_csk_search_req(sk, &prev, dh->dccph_dport, 357 req = inet6_csk_search_req(sk, &prev, dh->dccph_dport,
359 &hdr->daddr, &hdr->saddr, 358 &hdr->daddr, &hdr->saddr,
360 inet6_iif(skb)); 359 inet6_iif(skb));
361 if (!req) 360 if (req == NULL)
362 goto out; 361 goto out;
363 362
364 /* ICMPs are not backlogged, hence we cannot get 363 /*
365 * an established socket here. 364 * ICMPs are not backlogged, hence we cannot get an established
365 * socket here.
366 */ 366 */
367 BUG_TRAP(req->sk == NULL); 367 BUG_TRAP(req->sk == NULL);
368 368
@@ -376,7 +376,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
376 376
377 case DCCP_REQUESTING: 377 case DCCP_REQUESTING:
378 case DCCP_RESPOND: /* Cannot happen. 378 case DCCP_RESPOND: /* Cannot happen.
379 It can, it SYNs are crossed. --ANK */ 379 It can, it SYNs are crossed. --ANK */
380 if (!sock_owned_by_user(sk)) { 380 if (!sock_owned_by_user(sk)) {
381 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS); 381 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
382 sk->sk_err = err; 382 sk->sk_err = err;
@@ -385,7 +385,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
385 * (see connect in sock.c) 385 * (see connect in sock.c)
386 */ 386 */
387 sk->sk_error_report(sk); 387 sk->sk_error_report(sk);
388
389 dccp_done(sk); 388 dccp_done(sk);
390 } else 389 } else
391 sk->sk_err_soft = err; 390 sk->sk_err_soft = err;
@@ -431,14 +430,16 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
431 ireq6->pktopts) { 430 ireq6->pktopts) {
432 struct sk_buff *pktopts = ireq6->pktopts; 431 struct sk_buff *pktopts = ireq6->pktopts;
433 struct inet6_skb_parm *rxopt = IP6CB(pktopts); 432 struct inet6_skb_parm *rxopt = IP6CB(pktopts);
433
434 if (rxopt->srcrt) 434 if (rxopt->srcrt)
435 opt = ipv6_invert_rthdr(sk, 435 opt = ipv6_invert_rthdr(sk,
436 (struct ipv6_rt_hdr *)(pktopts->nh.raw + 436 (struct ipv6_rt_hdr *)(pktopts->nh.raw +
437 rxopt->srcrt)); 437 rxopt->srcrt));
438 } 438 }
439 439
440 if (opt && opt->srcrt) { 440 if (opt != NULL && opt->srcrt != NULL) {
441 struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt; 441 const struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
442
442 ipv6_addr_copy(&final, &fl.fl6_dst); 443 ipv6_addr_copy(&final, &fl.fl6_dst);
443 ipv6_addr_copy(&fl.fl6_dst, rt0->addr); 444 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
444 final_p = &final; 445 final_p = &final;
@@ -447,15 +448,19 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
447 err = ip6_dst_lookup(sk, &dst, &fl); 448 err = ip6_dst_lookup(sk, &dst, &fl);
448 if (err) 449 if (err)
449 goto done; 450 goto done;
451
450 if (final_p) 452 if (final_p)
451 ipv6_addr_copy(&fl.fl6_dst, final_p); 453 ipv6_addr_copy(&fl.fl6_dst, final_p);
452 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) 454
455 err = xfrm_lookup(&dst, &fl, sk, 0);
456 if (err < 0)
453 goto done; 457 goto done;
454 } 458 }
455 459
456 skb = dccp_make_response(sk, dst, req); 460 skb = dccp_make_response(sk, dst, req);
457 if (skb != NULL) { 461 if (skb != NULL) {
458 struct dccp_hdr *dh = dccp_hdr(skb); 462 struct dccp_hdr *dh = dccp_hdr(skb);
463
459 dh->dccph_checksum = dccp_v6_check(dh, skb->len, 464 dh->dccph_checksum = dccp_v6_check(dh, skb->len,
460 &ireq6->loc_addr, 465 &ireq6->loc_addr,
461 &ireq6->rmt_addr, 466 &ireq6->rmt_addr,
@@ -469,7 +474,7 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
469 } 474 }
470 475
471done: 476done:
472 if (opt && opt != np->opt) 477 if (opt != NULL && opt != np->opt)
473 sock_kfree_s(sk, opt, opt->tot_len); 478 sock_kfree_s(sk, opt, opt->tot_len);
474 dst_release(dst); 479 dst_release(dst);
475 return err; 480 return err;
@@ -500,7 +505,7 @@ static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
500 struct dccp_hdr *dh = dccp_hdr(skb); 505 struct dccp_hdr *dh = dccp_hdr(skb);
501 506
502 dh->dccph_checksum = csum_ipv6_magic(&np->saddr, &np->daddr, 507 dh->dccph_checksum = csum_ipv6_magic(&np->saddr, &np->daddr,
503 len, IPPROTO_DCCP, 508 len, IPPROTO_DCCP,
504 csum_partial((char *)dh, 509 csum_partial((char *)dh,
505 dh->dccph_doff << 2, 510 dh->dccph_doff << 2,
506 skb->csum)); 511 skb->csum));
@@ -508,7 +513,7 @@ static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
508 513
509static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb) 514static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
510{ 515{
511 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; 516 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
512 const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) + 517 const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
513 sizeof(struct dccp_hdr_ext) + 518 sizeof(struct dccp_hdr_ext) +
514 sizeof(struct dccp_hdr_reset); 519 sizeof(struct dccp_hdr_reset);
@@ -520,7 +525,7 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
520 return; 525 return;
521 526
522 if (!ipv6_unicast_destination(rxskb)) 527 if (!ipv6_unicast_destination(rxskb))
523 return; 528 return;
524 529
525 /* 530 /*
526 * We need to grab some memory, and put together an RST, 531 * We need to grab some memory, and put together an RST,
@@ -529,7 +534,7 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
529 534
530 skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + 535 skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) +
531 dccp_hdr_reset_len, GFP_ATOMIC); 536 dccp_hdr_reset_len, GFP_ATOMIC);
532 if (skb == NULL) 537 if (skb == NULL)
533 return; 538 return;
534 539
535 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) + 540 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) +
@@ -608,7 +613,7 @@ static void dccp_v6_ctl_send_ack(struct sk_buff *rxskb)
608 dh->dccph_dport = rxdh->dccph_sport; 613 dh->dccph_dport = rxdh->dccph_sport;
609 dh->dccph_doff = dccp_hdr_ack_len / 4; 614 dh->dccph_doff = dccp_hdr_ack_len / 4;
610 dh->dccph_x = 1; 615 dh->dccph_x = 1;
611 616
612 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq); 617 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
613 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), 618 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
614 DCCP_SKB_CB(rxskb)->dccpd_seq); 619 DCCP_SKB_CB(rxskb)->dccpd_seq);
@@ -660,7 +665,6 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
660 &iph->saddr, dh->dccph_sport, 665 &iph->saddr, dh->dccph_sport,
661 &iph->daddr, ntohs(dh->dccph_dport), 666 &iph->daddr, ntohs(dh->dccph_dport),
662 inet6_iif(skb)); 667 inet6_iif(skb));
663
664 if (nsk != NULL) { 668 if (nsk != NULL) {
665 if (nsk->sk_state != DCCP_TIME_WAIT) { 669 if (nsk->sk_state != DCCP_TIME_WAIT) {
666 bh_lock_sock(nsk); 670 bh_lock_sock(nsk);
@@ -689,17 +693,17 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
689 return dccp_v4_conn_request(sk, skb); 693 return dccp_v4_conn_request(sk, skb);
690 694
691 if (!ipv6_unicast_destination(skb)) 695 if (!ipv6_unicast_destination(skb))
692 goto drop; 696 goto drop;
693 697
694 if (dccp_bad_service_code(sk, service)) { 698 if (dccp_bad_service_code(sk, service)) {
695 reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE; 699 reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
696 goto drop; 700 goto drop;
697 } 701 }
698 /* 702 /*
699 * There are no SYN attacks on IPv6, yet... 703 * There are no SYN attacks on IPv6, yet...
700 */ 704 */
701 if (inet_csk_reqsk_queue_is_full(sk)) 705 if (inet_csk_reqsk_queue_is_full(sk))
702 goto drop; 706 goto drop;
703 707
704 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) 708 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
705 goto drop; 709 goto drop;
@@ -733,7 +737,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
733 ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL) 737 ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL)
734 ireq6->iif = inet6_iif(skb); 738 ireq6->iif = inet6_iif(skb);
735 739
736 /* 740 /*
737 * Step 3: Process LISTEN state 741 * Step 3: Process LISTEN state
738 * 742 *
739 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie 743 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
@@ -777,9 +781,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
777 /* 781 /*
778 * v6 mapped 782 * v6 mapped
779 */ 783 */
780
781 newsk = dccp_v4_request_recv_sock(sk, skb, req, dst); 784 newsk = dccp_v4_request_recv_sock(sk, skb, req, dst);
782 if (newsk == NULL) 785 if (newsk == NULL)
783 return NULL; 786 return NULL;
784 787
785 newdp6 = (struct dccp6_sock *)newsk; 788 newdp6 = (struct dccp6_sock *)newsk;
@@ -825,9 +828,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
825 if (sk_acceptq_is_full(sk)) 828 if (sk_acceptq_is_full(sk))
826 goto out_overflow; 829 goto out_overflow;
827 830
828 if (np->rxopt.bits.osrcrt == 2 && 831 if (np->rxopt.bits.osrcrt == 2 && opt == NULL && ireq6->pktopts) {
829 opt == NULL && ireq6->pktopts) { 832 const struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts);
830 struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts); 833
831 if (rxopt->srcrt) 834 if (rxopt->srcrt)
832 opt = ipv6_invert_rthdr(sk, 835 opt = ipv6_invert_rthdr(sk,
833 (struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw + 836 (struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw +
@@ -841,8 +844,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
841 memset(&fl, 0, sizeof(fl)); 844 memset(&fl, 0, sizeof(fl));
842 fl.proto = IPPROTO_DCCP; 845 fl.proto = IPPROTO_DCCP;
843 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); 846 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
844 if (opt && opt->srcrt) { 847 if (opt != NULL && opt->srcrt != NULL) {
845 struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; 848 const struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
849
846 ipv6_addr_copy(&final, &fl.fl6_dst); 850 ipv6_addr_copy(&final, &fl.fl6_dst);
847 ipv6_addr_copy(&fl.fl6_dst, rt0->addr); 851 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
848 final_p = &final; 852 final_p = &final;
@@ -860,7 +864,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
860 864
861 if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0) 865 if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0)
862 goto out; 866 goto out;
863 } 867 }
864 868
865 newsk = dccp_create_openreq_child(sk, req, skb); 869 newsk = dccp_create_openreq_child(sk, req, skb);
866 if (newsk == NULL) 870 if (newsk == NULL)
@@ -873,9 +877,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
873 */ 877 */
874 878
875 ip6_dst_store(newsk, dst, NULL); 879 ip6_dst_store(newsk, dst, NULL);
876 newsk->sk_route_caps = dst->dev->features & 880 newsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |
877 ~(NETIF_F_IP_CSUM | NETIF_F_TSO); 881 NETIF_F_TSO);
878
879 newdp6 = (struct dccp6_sock *)newsk; 882 newdp6 = (struct dccp6_sock *)newsk;
880 newinet = inet_sk(newsk); 883 newinet = inet_sk(newsk);
881 newinet->pinet6 = &newdp6->inet6; 884 newinet->pinet6 = &newdp6->inet6;
@@ -889,7 +892,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
889 ipv6_addr_copy(&newnp->rcv_saddr, &ireq6->loc_addr); 892 ipv6_addr_copy(&newnp->rcv_saddr, &ireq6->loc_addr);
890 newsk->sk_bound_dev_if = ireq6->iif; 893 newsk->sk_bound_dev_if = ireq6->iif;
891 894
892 /* Now IPv6 options... 895 /* Now IPv6 options...
893 896
894 First: no IPv4 options. 897 First: no IPv4 options.
895 */ 898 */
@@ -911,20 +914,20 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
911 newnp->mcast_oif = inet6_iif(skb); 914 newnp->mcast_oif = inet6_iif(skb);
912 newnp->mcast_hops = skb->nh.ipv6h->hop_limit; 915 newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
913 916
914 /* Clone native IPv6 options from listening socket (if any) 917 /*
915 918 * Clone native IPv6 options from listening socket (if any)
916 Yes, keeping reference count would be much more clever, 919 *
917 but we make one more one thing there: reattach optmem 920 * Yes, keeping reference count would be much more clever, but we make
918 to newsk. 921 * one more one thing there: reattach optmem to newsk.
919 */ 922 */
920 if (opt) { 923 if (opt != NULL) {
921 newnp->opt = ipv6_dup_options(newsk, opt); 924 newnp->opt = ipv6_dup_options(newsk, opt);
922 if (opt != np->opt) 925 if (opt != np->opt)
923 sock_kfree_s(sk, opt, opt->tot_len); 926 sock_kfree_s(sk, opt, opt->tot_len);
924 } 927 }
925 928
926 inet_csk(newsk)->icsk_ext_hdr_len = 0; 929 inet_csk(newsk)->icsk_ext_hdr_len = 0;
927 if (newnp->opt) 930 if (newnp->opt != NULL)
928 inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + 931 inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen +
929 newnp->opt->opt_flen); 932 newnp->opt->opt_flen);
930 933
@@ -941,7 +944,7 @@ out_overflow:
941 NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS); 944 NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS);
942out: 945out:
943 NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS); 946 NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS);
944 if (opt && opt != np->opt) 947 if (opt != NULL && opt != np->opt)
945 sock_kfree_s(sk, opt, opt->tot_len); 948 sock_kfree_s(sk, opt, opt->tot_len);
946 dst_release(dst); 949 dst_release(dst);
947 return NULL; 950 return NULL;
@@ -975,8 +978,8 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
975 goto discard; 978 goto discard;
976 979
977 /* 980 /*
978 * socket locking is here for SMP purposes as backlog rcv 981 * socket locking is here for SMP purposes as backlog rcv is currently
979 * is currently called with bh processing disabled. 982 * called with bh processing disabled.
980 */ 983 */
981 984
982 /* Do Stevens' IPV6_PKTOPTIONS. 985 /* Do Stevens' IPV6_PKTOPTIONS.
@@ -1001,20 +1004,20 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1001 return 0; 1004 return 0;
1002 } 1005 }
1003 1006
1004 if (sk->sk_state == DCCP_LISTEN) { 1007 if (sk->sk_state == DCCP_LISTEN) {
1005 struct sock *nsk = dccp_v6_hnd_req(sk, skb); 1008 struct sock *nsk = dccp_v6_hnd_req(sk, skb);
1006 if (!nsk)
1007 goto discard;
1008 1009
1010 if (nsk == NULL)
1011 goto discard;
1009 /* 1012 /*
1010 * Queue it on the new socket if the new socket is active, 1013 * Queue it on the new socket if the new socket is active,
1011 * otherwise we just shortcircuit this and continue with 1014 * otherwise we just shortcircuit this and continue with
1012 * the new socket.. 1015 * the new socket..
1013 */ 1016 */
1014 if(nsk != sk) { 1017 if (nsk != sk) {
1015 if (dccp_child_process(sk, nsk, skb)) 1018 if (dccp_child_process(sk, nsk, skb))
1016 goto reset; 1019 goto reset;
1017 if (opt_skb) 1020 if (opt_skb != NULL)
1018 __kfree_skb(opt_skb); 1021 __kfree_skb(opt_skb);
1019 return 0; 1022 return 0;
1020 } 1023 }
@@ -1027,7 +1030,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1027reset: 1030reset:
1028 dccp_v6_ctl_send_reset(skb); 1031 dccp_v6_ctl_send_reset(skb);
1029discard: 1032discard:
1030 if (opt_skb) 1033 if (opt_skb != NULL)
1031 __kfree_skb(opt_skb); 1034 __kfree_skb(opt_skb);
1032 kfree_skb(skb); 1035 kfree_skb(skb);
1033 return 0; 1036 return 0;
@@ -1060,7 +1063,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
1060 dh->dccph_sport, 1063 dh->dccph_sport,
1061 &skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport), 1064 &skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport),
1062 inet6_iif(skb)); 1065 inet6_iif(skb));
1063 /* 1066 /*
1064 * Step 2: 1067 * Step 2:
1065 * If no socket ... 1068 * If no socket ...
1066 * Generate Reset(No Connection) unless P.type == Reset 1069 * Generate Reset(No Connection) unless P.type == Reset
@@ -1069,15 +1072,14 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
1069 if (sk == NULL) 1072 if (sk == NULL)
1070 goto no_dccp_socket; 1073 goto no_dccp_socket;
1071 1074
1072 /* 1075 /*
1073 * Step 2: 1076 * Step 2:
1074 * ... or S.state == TIMEWAIT, 1077 * ... or S.state == TIMEWAIT,
1075 * Generate Reset(No Connection) unless P.type == Reset 1078 * Generate Reset(No Connection) unless P.type == Reset
1076 * Drop packet and return 1079 * Drop packet and return
1077 */ 1080 */
1078
1079 if (sk->sk_state == DCCP_TIME_WAIT) 1081 if (sk->sk_state == DCCP_TIME_WAIT)
1080 goto do_time_wait; 1082 goto do_time_wait;
1081 1083
1082 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 1084 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1083 goto discard_and_relse; 1085 goto discard_and_relse;
@@ -1116,32 +1118,32 @@ do_time_wait:
1116} 1118}
1117 1119
1118static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = { 1120static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
1119 .queue_xmit = inet6_csk_xmit, 1121 .queue_xmit = inet6_csk_xmit,
1120 .send_check = dccp_v6_send_check, 1122 .send_check = dccp_v6_send_check,
1121 .rebuild_header = inet6_sk_rebuild_header, 1123 .rebuild_header = inet6_sk_rebuild_header,
1122 .conn_request = dccp_v6_conn_request, 1124 .conn_request = dccp_v6_conn_request,
1123 .syn_recv_sock = dccp_v6_request_recv_sock, 1125 .syn_recv_sock = dccp_v6_request_recv_sock,
1124 .net_header_len = sizeof(struct ipv6hdr), 1126 .net_header_len = sizeof(struct ipv6hdr),
1125 .setsockopt = ipv6_setsockopt, 1127 .setsockopt = ipv6_setsockopt,
1126 .getsockopt = ipv6_getsockopt, 1128 .getsockopt = ipv6_getsockopt,
1127 .addr2sockaddr = inet6_csk_addr2sockaddr, 1129 .addr2sockaddr = inet6_csk_addr2sockaddr,
1128 .sockaddr_len = sizeof(struct sockaddr_in6) 1130 .sockaddr_len = sizeof(struct sockaddr_in6)
1129}; 1131};
1130 1132
1131/* 1133/*
1132 * DCCP over IPv4 via INET6 API 1134 * DCCP over IPv4 via INET6 API
1133 */ 1135 */
1134static struct inet_connection_sock_af_ops dccp_ipv6_mapped = { 1136static struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
1135 .queue_xmit = ip_queue_xmit, 1137 .queue_xmit = ip_queue_xmit,
1136 .send_check = dccp_v4_send_check, 1138 .send_check = dccp_v4_send_check,
1137 .rebuild_header = inet_sk_rebuild_header, 1139 .rebuild_header = inet_sk_rebuild_header,
1138 .conn_request = dccp_v6_conn_request, 1140 .conn_request = dccp_v6_conn_request,
1139 .syn_recv_sock = dccp_v6_request_recv_sock, 1141 .syn_recv_sock = dccp_v6_request_recv_sock,
1140 .net_header_len = sizeof(struct iphdr), 1142 .net_header_len = sizeof(struct iphdr),
1141 .setsockopt = ipv6_setsockopt, 1143 .setsockopt = ipv6_setsockopt,
1142 .getsockopt = ipv6_getsockopt, 1144 .getsockopt = ipv6_getsockopt,
1143 .addr2sockaddr = inet6_csk_addr2sockaddr, 1145 .addr2sockaddr = inet6_csk_addr2sockaddr,
1144 .sockaddr_len = sizeof(struct sockaddr_in6) 1146 .sockaddr_len = sizeof(struct sockaddr_in6)
1145}; 1147};
1146 1148
1147/* NOTE: A lot of things set to zero explicitly by call to 1149/* NOTE: A lot of things set to zero explicitly by call to
@@ -1168,35 +1170,35 @@ static int dccp_v6_destroy_sock(struct sock *sk)
1168} 1170}
1169 1171
1170static struct proto dccp_v6_prot = { 1172static struct proto dccp_v6_prot = {
1171 .name = "DCCPv6", 1173 .name = "DCCPv6",
1172 .owner = THIS_MODULE, 1174 .owner = THIS_MODULE,
1173 .close = dccp_close, 1175 .close = dccp_close,
1174 .connect = dccp_v6_connect, 1176 .connect = dccp_v6_connect,
1175 .disconnect = dccp_disconnect, 1177 .disconnect = dccp_disconnect,
1176 .ioctl = dccp_ioctl, 1178 .ioctl = dccp_ioctl,
1177 .init = dccp_v6_init_sock, 1179 .init = dccp_v6_init_sock,
1178 .setsockopt = dccp_setsockopt, 1180 .setsockopt = dccp_setsockopt,
1179 .getsockopt = dccp_getsockopt, 1181 .getsockopt = dccp_getsockopt,
1180 .sendmsg = dccp_sendmsg, 1182 .sendmsg = dccp_sendmsg,
1181 .recvmsg = dccp_recvmsg, 1183 .recvmsg = dccp_recvmsg,
1182 .backlog_rcv = dccp_v6_do_rcv, 1184 .backlog_rcv = dccp_v6_do_rcv,
1183 .hash = dccp_v6_hash, 1185 .hash = dccp_v6_hash,
1184 .unhash = dccp_unhash, 1186 .unhash = dccp_unhash,
1185 .accept = inet_csk_accept, 1187 .accept = inet_csk_accept,
1186 .get_port = dccp_v6_get_port, 1188 .get_port = dccp_v6_get_port,
1187 .shutdown = dccp_shutdown, 1189 .shutdown = dccp_shutdown,
1188 .destroy = dccp_v6_destroy_sock, 1190 .destroy = dccp_v6_destroy_sock,
1189 .orphan_count = &dccp_orphan_count, 1191 .orphan_count = &dccp_orphan_count,
1190 .max_header = MAX_DCCP_HEADER, 1192 .max_header = MAX_DCCP_HEADER,
1191 .obj_size = sizeof(struct dccp6_sock), 1193 .obj_size = sizeof(struct dccp6_sock),
1192 .rsk_prot = &dccp6_request_sock_ops, 1194 .rsk_prot = &dccp6_request_sock_ops,
1193 .twsk_prot = &dccp6_timewait_sock_ops, 1195 .twsk_prot = &dccp6_timewait_sock_ops,
1194}; 1196};
1195 1197
1196static struct inet6_protocol dccp_v6_protocol = { 1198static struct inet6_protocol dccp_v6_protocol = {
1197 .handler = dccp_v6_rcv, 1199 .handler = dccp_v6_rcv,
1198 .err_handler = dccp_v6_err, 1200 .err_handler = dccp_v6_err,
1199 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, 1201 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
1200}; 1202};
1201 1203
1202static struct proto_ops inet6_dccp_ops = { 1204static struct proto_ops inet6_dccp_ops = {