aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ipv6.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ipv6.c')
-rw-r--r--net/dccp/ipv6.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index e48ca5d45658..3b11e41a2929 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/random.h> 16#include <linux/random.h>
17#include <linux/slab.h>
17#include <linux/xfrm.h> 18#include <linux/xfrm.h>
18 19
19#include <net/addrconf.h> 20#include <net/addrconf.h>
@@ -46,7 +47,7 @@ static void dccp_v6_hash(struct sock *sk)
46 return; 47 return;
47 } 48 }
48 local_bh_disable(); 49 local_bh_disable();
49 __inet6_hash(sk); 50 __inet6_hash(sk, NULL);
50 local_bh_enable(); 51 local_bh_enable();
51 } 52 }
52} 53}
@@ -158,8 +159,8 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
158 ipv6_addr_copy(&fl.fl6_dst, &np->daddr); 159 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
159 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 160 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
160 fl.oif = sk->sk_bound_dev_if; 161 fl.oif = sk->sk_bound_dev_if;
161 fl.fl_ip_dport = inet->dport; 162 fl.fl_ip_dport = inet->inet_dport;
162 fl.fl_ip_sport = inet->sport; 163 fl.fl_ip_sport = inet->inet_sport;
163 security_sk_classify_flow(sk, &fl); 164 security_sk_classify_flow(sk, &fl);
164 165
165 err = ip6_dst_lookup(sk, &dst, &fl); 166 err = ip6_dst_lookup(sk, &dst, &fl);
@@ -241,7 +242,8 @@ out:
241} 242}
242 243
243 244
244static int dccp_v6_send_response(struct sock *sk, struct request_sock *req) 245static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
246 struct request_values *rv_unused)
245{ 247{
246 struct inet6_request_sock *ireq6 = inet6_rsk(req); 248 struct inet6_request_sock *ireq6 = inet6_rsk(req);
247 struct ipv6_pinfo *np = inet6_sk(sk); 249 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -468,7 +470,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
468 dreq->dreq_iss = dccp_v6_init_sequence(skb); 470 dreq->dreq_iss = dccp_v6_init_sequence(skb);
469 dreq->dreq_service = service; 471 dreq->dreq_service = service;
470 472
471 if (dccp_v6_send_response(sk, req)) 473 if (dccp_v6_send_response(sk, req, NULL))
472 goto drop_and_free; 474 goto drop_and_free;
473 475
474 inet6_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); 476 inet6_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
@@ -510,11 +512,9 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
510 512
511 memcpy(newnp, np, sizeof(struct ipv6_pinfo)); 513 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
512 514
513 ipv6_addr_set(&newnp->daddr, 0, 0, htonl(0x0000FFFF), 515 ipv6_addr_set_v4mapped(newinet->inet_daddr, &newnp->daddr);
514 newinet->daddr);
515 516
516 ipv6_addr_set(&newnp->saddr, 0, 0, htonl(0x0000FFFF), 517 ipv6_addr_set_v4mapped(newinet->inet_saddr, &newnp->saddr);
517 newinet->saddr);
518 518
519 ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr); 519 ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr);
520 520
@@ -642,9 +642,10 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
642 642
643 dccp_sync_mss(newsk, dst_mtu(dst)); 643 dccp_sync_mss(newsk, dst_mtu(dst));
644 644
645 newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6; 645 newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;
646 newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
646 647
647 __inet6_hash(newsk); 648 __inet6_hash(newsk, NULL);
648 __inet_inherit_port(sk, newsk); 649 __inet_inherit_port(sk, newsk);
649 650
650 return newsk; 651 return newsk;
@@ -970,12 +971,9 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
970 icsk->icsk_af_ops = &dccp_ipv6_af_ops; 971 icsk->icsk_af_ops = &dccp_ipv6_af_ops;
971 sk->sk_backlog_rcv = dccp_v6_do_rcv; 972 sk->sk_backlog_rcv = dccp_v6_do_rcv;
972 goto failure; 973 goto failure;
973 } else {
974 ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF),
975 inet->saddr);
976 ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000FFFF),
977 inet->rcv_saddr);
978 } 974 }
975 ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr);
976 ipv6_addr_set_v4mapped(inet->inet_rcv_saddr, &np->rcv_saddr);
979 977
980 return err; 978 return err;
981 } 979 }
@@ -988,7 +986,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
988 ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr); 986 ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr);
989 fl.oif = sk->sk_bound_dev_if; 987 fl.oif = sk->sk_bound_dev_if;
990 fl.fl_ip_dport = usin->sin6_port; 988 fl.fl_ip_dport = usin->sin6_port;
991 fl.fl_ip_sport = inet->sport; 989 fl.fl_ip_sport = inet->inet_sport;
992 security_sk_classify_flow(sk, &fl); 990 security_sk_classify_flow(sk, &fl);
993 991
994 if (np->opt != NULL && np->opt->srcrt != NULL) { 992 if (np->opt != NULL && np->opt->srcrt != NULL) {
@@ -1021,7 +1019,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
1021 1019
1022 /* set the source address */ 1020 /* set the source address */
1023 ipv6_addr_copy(&np->saddr, saddr); 1021 ipv6_addr_copy(&np->saddr, saddr);
1024 inet->rcv_saddr = LOOPBACK4_IPV6; 1022 inet->inet_rcv_saddr = LOOPBACK4_IPV6;
1025 1023
1026 __ip6_dst_store(sk, dst, NULL, NULL); 1024 __ip6_dst_store(sk, dst, NULL, NULL);
1027 1025
@@ -1030,7 +1028,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
1030 icsk->icsk_ext_hdr_len = (np->opt->opt_flen + 1028 icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
1031 np->opt->opt_nflen); 1029 np->opt->opt_nflen);
1032 1030
1033 inet->dport = usin->sin6_port; 1031 inet->inet_dport = usin->sin6_port;
1034 1032
1035 dccp_set_state(sk, DCCP_REQUESTING); 1033 dccp_set_state(sk, DCCP_REQUESTING);
1036 err = inet6_hash_connect(&dccp_death_row, sk); 1034 err = inet6_hash_connect(&dccp_death_row, sk);
@@ -1039,7 +1037,8 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
1039 1037
1040 dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32, 1038 dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,
1041 np->daddr.s6_addr32, 1039 np->daddr.s6_addr32,
1042 inet->sport, inet->dport); 1040 inet->inet_sport,
1041 inet->inet_dport);
1043 err = dccp_connect(sk); 1042 err = dccp_connect(sk);
1044 if (err) 1043 if (err)
1045 goto late_failure; 1044 goto late_failure;
@@ -1050,7 +1049,7 @@ late_failure:
1050 dccp_set_state(sk, DCCP_CLOSED); 1049 dccp_set_state(sk, DCCP_CLOSED);
1051 __sk_dst_reset(sk); 1050 __sk_dst_reset(sk);
1052failure: 1051failure:
1053 inet->dport = 0; 1052 inet->inet_dport = 0;
1054 sk->sk_route_caps = 0; 1053 sk->sk_route_caps = 0;
1055 return err; 1054 return err;
1056} 1055}
@@ -1188,20 +1187,19 @@ static struct inet_protosw dccp_v6_protosw = {
1188 .protocol = IPPROTO_DCCP, 1187 .protocol = IPPROTO_DCCP,
1189 .prot = &dccp_v6_prot, 1188 .prot = &dccp_v6_prot,
1190 .ops = &inet6_dccp_ops, 1189 .ops = &inet6_dccp_ops,
1191 .capability = -1,
1192 .flags = INET_PROTOSW_ICSK, 1190 .flags = INET_PROTOSW_ICSK,
1193}; 1191};
1194 1192
1195static int dccp_v6_init_net(struct net *net) 1193static int __net_init dccp_v6_init_net(struct net *net)
1196{ 1194{
1197 int err; 1195 if (dccp_hashinfo.bhash == NULL)
1196 return -ESOCKTNOSUPPORT;
1198 1197
1199 err = inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6, 1198 return inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,
1200 SOCK_DCCP, IPPROTO_DCCP, net); 1199 SOCK_DCCP, IPPROTO_DCCP, net);
1201 return err;
1202} 1200}
1203 1201
1204static void dccp_v6_exit_net(struct net *net) 1202static void __net_exit dccp_v6_exit_net(struct net *net)
1205{ 1203{
1206 inet_ctl_sock_destroy(net->dccp.v6_ctl_sk); 1204 inet_ctl_sock_destroy(net->dccp.v6_ctl_sk);
1207} 1205}