ipv6.c (0eea505058740aa45486145296ef4fefbd8cab85) | ipv6.c (45f6fad84cc305103b28d73482b344d7f5b76f39) |
---|---|
1/* 2 * DCCP over IPv6 3 * Linux INET6 implementation 4 * 5 * Based on net/dccp6/ipv6.c 6 * 7 * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> 8 * --- 188 unchanged lines hidden (view full) --- 197 fl6.saddr = ireq->ir_v6_loc_addr; 198 fl6.flowlabel = 0; 199 fl6.flowi6_oif = ireq->ir_iif; 200 fl6.fl6_dport = ireq->ir_rmt_port; 201 fl6.fl6_sport = htons(ireq->ir_num); 202 security_req_classify_flow(req, flowi6_to_flowi(&fl6)); 203 204 | 1/* 2 * DCCP over IPv6 3 * Linux INET6 implementation 4 * 5 * Based on net/dccp6/ipv6.c 6 * 7 * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> 8 * --- 188 unchanged lines hidden (view full) --- 197 fl6.saddr = ireq->ir_v6_loc_addr; 198 fl6.flowlabel = 0; 199 fl6.flowi6_oif = ireq->ir_iif; 200 fl6.fl6_dport = ireq->ir_rmt_port; 201 fl6.fl6_sport = htons(ireq->ir_num); 202 security_req_classify_flow(req, flowi6_to_flowi(&fl6)); 203 204 |
205 final_p = fl6_update_dst(&fl6, np->opt, &final); | 205 rcu_read_lock(); 206 final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final); 207 rcu_read_unlock(); |
206 207 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 208 if (IS_ERR(dst)) { 209 err = PTR_ERR(dst); 210 dst = NULL; 211 goto done; 212 } 213 214 skb = dccp_make_response(sk, dst, req); 215 if (skb != NULL) { 216 struct dccp_hdr *dh = dccp_hdr(skb); 217 218 dh->dccph_checksum = dccp_v6_csum_finish(skb, 219 &ireq->ir_v6_loc_addr, 220 &ireq->ir_v6_rmt_addr); 221 fl6.daddr = ireq->ir_v6_rmt_addr; | 208 209 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 210 if (IS_ERR(dst)) { 211 err = PTR_ERR(dst); 212 dst = NULL; 213 goto done; 214 } 215 216 skb = dccp_make_response(sk, dst, req); 217 if (skb != NULL) { 218 struct dccp_hdr *dh = dccp_hdr(skb); 219 220 dh->dccph_checksum = dccp_v6_csum_finish(skb, 221 &ireq->ir_v6_loc_addr, 222 &ireq->ir_v6_rmt_addr); 223 fl6.daddr = ireq->ir_v6_rmt_addr; |
222 err = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass); | 224 rcu_read_lock(); 225 err = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt), 226 np->tclass); 227 rcu_read_unlock(); |
223 err = net_xmit_eval(err); 224 } 225 226done: 227 dst_release(dst); 228 return err; 229} 230 --- 151 unchanged lines hidden (view full) --- 382 struct request_sock *req, 383 struct dst_entry *dst, 384 struct request_sock *req_unhash, 385 bool *own_req) 386{ 387 struct inet_request_sock *ireq = inet_rsk(req); 388 struct ipv6_pinfo *newnp; 389 const struct ipv6_pinfo *np = inet6_sk(sk); | 228 err = net_xmit_eval(err); 229 } 230 231done: 232 dst_release(dst); 233 return err; 234} 235 --- 151 unchanged lines hidden (view full) --- 387 struct request_sock *req, 388 struct dst_entry *dst, 389 struct request_sock *req_unhash, 390 bool *own_req) 391{ 392 struct inet_request_sock *ireq = inet_rsk(req); 393 struct ipv6_pinfo *newnp; 394 const struct ipv6_pinfo *np = inet6_sk(sk); |
395 struct ipv6_txoptions *opt; |
|
390 struct inet_sock *newinet; 391 struct dccp6_sock *newdp6; 392 struct sock *newsk; 393 394 if (skb->protocol == htons(ETH_P_IP)) { 395 /* 396 * v6 mapped 397 */ --- 85 unchanged lines hidden (view full) --- 483 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; 484 485 /* 486 * Clone native IPv6 options from listening socket (if any) 487 * 488 * Yes, keeping reference count would be much more clever, but we make 489 * one more one thing there: reattach optmem to newsk. 490 */ | 396 struct inet_sock *newinet; 397 struct dccp6_sock *newdp6; 398 struct sock *newsk; 399 400 if (skb->protocol == htons(ETH_P_IP)) { 401 /* 402 * v6 mapped 403 */ --- 85 unchanged lines hidden (view full) --- 489 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; 490 491 /* 492 * Clone native IPv6 options from listening socket (if any) 493 * 494 * Yes, keeping reference count would be much more clever, but we make 495 * one more one thing there: reattach optmem to newsk. 496 */ |
491 if (np->opt != NULL) 492 newnp->opt = ipv6_dup_options(newsk, np->opt); 493 | 497 opt = rcu_dereference(np->opt); 498 if (opt) { 499 opt = ipv6_dup_options(newsk, opt); 500 RCU_INIT_POINTER(newnp->opt, opt); 501 } |
494 inet_csk(newsk)->icsk_ext_hdr_len = 0; | 502 inet_csk(newsk)->icsk_ext_hdr_len = 0; |
495 if (newnp->opt != NULL) 496 inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + 497 newnp->opt->opt_flen); | 503 if (opt) 504 inet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen + 505 opt->opt_flen; |
498 499 dccp_sync_mss(newsk, dst_mtu(dst)); 500 501 newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; 502 newinet->inet_rcv_saddr = LOOPBACK4_IPV6; 503 504 if (__inet_inherit_port(sk, newsk) < 0) { 505 inet_csk_prepare_forced_close(newsk); --- 246 unchanged lines hidden (view full) --- 752 int addr_len) 753{ 754 struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr; 755 struct inet_connection_sock *icsk = inet_csk(sk); 756 struct inet_sock *inet = inet_sk(sk); 757 struct ipv6_pinfo *np = inet6_sk(sk); 758 struct dccp_sock *dp = dccp_sk(sk); 759 struct in6_addr *saddr = NULL, *final_p, final; | 506 507 dccp_sync_mss(newsk, dst_mtu(dst)); 508 509 newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; 510 newinet->inet_rcv_saddr = LOOPBACK4_IPV6; 511 512 if (__inet_inherit_port(sk, newsk) < 0) { 513 inet_csk_prepare_forced_close(newsk); --- 246 unchanged lines hidden (view full) --- 760 int addr_len) 761{ 762 struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr; 763 struct inet_connection_sock *icsk = inet_csk(sk); 764 struct inet_sock *inet = inet_sk(sk); 765 struct ipv6_pinfo *np = inet6_sk(sk); 766 struct dccp_sock *dp = dccp_sk(sk); 767 struct in6_addr *saddr = NULL, *final_p, final; |
768 struct ipv6_txoptions *opt; |
|
760 struct flowi6 fl6; 761 struct dst_entry *dst; 762 int addr_type; 763 int err; 764 765 dp->dccps_role = DCCP_ROLE_CLIENT; 766 767 if (addr_len < SIN6_LEN_RFC2133) --- 83 unchanged lines hidden (view full) --- 851 fl6.flowi6_proto = IPPROTO_DCCP; 852 fl6.daddr = sk->sk_v6_daddr; 853 fl6.saddr = saddr ? *saddr : np->saddr; 854 fl6.flowi6_oif = sk->sk_bound_dev_if; 855 fl6.fl6_dport = usin->sin6_port; 856 fl6.fl6_sport = inet->inet_sport; 857 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 858 | 769 struct flowi6 fl6; 770 struct dst_entry *dst; 771 int addr_type; 772 int err; 773 774 dp->dccps_role = DCCP_ROLE_CLIENT; 775 776 if (addr_len < SIN6_LEN_RFC2133) --- 83 unchanged lines hidden (view full) --- 860 fl6.flowi6_proto = IPPROTO_DCCP; 861 fl6.daddr = sk->sk_v6_daddr; 862 fl6.saddr = saddr ? *saddr : np->saddr; 863 fl6.flowi6_oif = sk->sk_bound_dev_if; 864 fl6.fl6_dport = usin->sin6_port; 865 fl6.fl6_sport = inet->inet_sport; 866 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 867 |
859 final_p = fl6_update_dst(&fl6, np->opt, &final); | 868 opt = rcu_dereference_protected(np->opt, sock_owned_by_user(sk)); 869 final_p = fl6_update_dst(&fl6, opt, &final); |
860 861 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 862 if (IS_ERR(dst)) { 863 err = PTR_ERR(dst); 864 goto failure; 865 } 866 867 if (saddr == NULL) { 868 saddr = &fl6.saddr; 869 sk->sk_v6_rcv_saddr = *saddr; 870 } 871 872 /* set the source address */ 873 np->saddr = *saddr; 874 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 875 876 __ip6_dst_store(sk, dst, NULL, NULL); 877 878 icsk->icsk_ext_hdr_len = 0; | 870 871 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 872 if (IS_ERR(dst)) { 873 err = PTR_ERR(dst); 874 goto failure; 875 } 876 877 if (saddr == NULL) { 878 saddr = &fl6.saddr; 879 sk->sk_v6_rcv_saddr = *saddr; 880 } 881 882 /* set the source address */ 883 np->saddr = *saddr; 884 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 885 886 __ip6_dst_store(sk, dst, NULL, NULL); 887 888 icsk->icsk_ext_hdr_len = 0; |
879 if (np->opt != NULL) 880 icsk->icsk_ext_hdr_len = (np->opt->opt_flen + 881 np->opt->opt_nflen); | 889 if (opt) 890 icsk->icsk_ext_hdr_len = opt->opt_flen + opt->opt_nflen; |
882 883 inet->inet_dport = usin->sin6_port; 884 885 dccp_set_state(sk, DCCP_REQUESTING); 886 err = inet6_hash_connect(&dccp_death_row, sk); 887 if (err) 888 goto late_failure; 889 --- 222 unchanged lines hidden --- | 891 892 inet->inet_dport = usin->sin6_port; 893 894 dccp_set_state(sk, DCCP_REQUESTING); 895 err = inet6_hash_connect(&dccp_death_row, sk); 896 if (err) 897 goto late_failure; 898 --- 222 unchanged lines hidden --- |