aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ipv4.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ipv4.c')
-rw-r--r--net/dccp/ipv4.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 7302e1498d46..52ffa1cde15a 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/dccp.h> 13#include <linux/dccp.h>
14#include <linux/icmp.h> 14#include <linux/icmp.h>
15#include <linux/slab.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/skbuff.h> 17#include <linux/skbuff.h>
17#include <linux/random.h> 18#include <linux/random.h>
@@ -62,10 +63,10 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
62 nexthop = inet->opt->faddr; 63 nexthop = inet->opt->faddr;
63 } 64 }
64 65
65 tmp = ip_route_connect(&rt, nexthop, inet->saddr, 66 tmp = ip_route_connect(&rt, nexthop, inet->inet_saddr,
66 RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, 67 RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
67 IPPROTO_DCCP, 68 IPPROTO_DCCP,
68 inet->sport, usin->sin_port, sk, 1); 69 inet->inet_sport, usin->sin_port, sk, 1);
69 if (tmp < 0) 70 if (tmp < 0)
70 return tmp; 71 return tmp;
71 72
@@ -77,12 +78,12 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
77 if (inet->opt == NULL || !inet->opt->srr) 78 if (inet->opt == NULL || !inet->opt->srr)
78 daddr = rt->rt_dst; 79 daddr = rt->rt_dst;
79 80
80 if (inet->saddr == 0) 81 if (inet->inet_saddr == 0)
81 inet->saddr = rt->rt_src; 82 inet->inet_saddr = rt->rt_src;
82 inet->rcv_saddr = inet->saddr; 83 inet->inet_rcv_saddr = inet->inet_saddr;
83 84
84 inet->dport = usin->sin_port; 85 inet->inet_dport = usin->sin_port;
85 inet->daddr = daddr; 86 inet->inet_daddr = daddr;
86 87
87 inet_csk(sk)->icsk_ext_hdr_len = 0; 88 inet_csk(sk)->icsk_ext_hdr_len = 0;
88 if (inet->opt != NULL) 89 if (inet->opt != NULL)
@@ -98,17 +99,19 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
98 if (err != 0) 99 if (err != 0)
99 goto failure; 100 goto failure;
100 101
101 err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport, 102 err = ip_route_newports(&rt, IPPROTO_DCCP, inet->inet_sport,
102 sk); 103 inet->inet_dport, sk);
103 if (err != 0) 104 if (err != 0)
104 goto failure; 105 goto failure;
105 106
106 /* OK, now commit destination to socket. */ 107 /* OK, now commit destination to socket. */
107 sk_setup_caps(sk, &rt->u.dst); 108 sk_setup_caps(sk, &rt->u.dst);
108 109
109 dp->dccps_iss = secure_dccp_sequence_number(inet->saddr, inet->daddr, 110 dp->dccps_iss = secure_dccp_sequence_number(inet->inet_saddr,
110 inet->sport, inet->dport); 111 inet->inet_daddr,
111 inet->id = dp->dccps_iss ^ jiffies; 112 inet->inet_sport,
113 inet->inet_dport);
114 inet->inet_id = dp->dccps_iss ^ jiffies;
112 115
113 err = dccp_connect(sk); 116 err = dccp_connect(sk);
114 rt = NULL; 117 rt = NULL;
@@ -123,7 +126,7 @@ failure:
123 dccp_set_state(sk, DCCP_CLOSED); 126 dccp_set_state(sk, DCCP_CLOSED);
124 ip_rt_put(rt); 127 ip_rt_put(rt);
125 sk->sk_route_caps = 0; 128 sk->sk_route_caps = 0;
126 inet->dport = 0; 129 inet->inet_dport = 0;
127 goto out; 130 goto out;
128} 131}
129 132
@@ -352,7 +355,9 @@ void dccp_v4_send_check(struct sock *sk, int unused, struct sk_buff *skb)
352 struct dccp_hdr *dh = dccp_hdr(skb); 355 struct dccp_hdr *dh = dccp_hdr(skb);
353 356
354 dccp_csum_outgoing(skb); 357 dccp_csum_outgoing(skb);
355 dh->dccph_checksum = dccp_v4_csum_finish(skb, inet->saddr, inet->daddr); 358 dh->dccph_checksum = dccp_v4_csum_finish(skb,
359 inet->inet_saddr,
360 inet->inet_daddr);
356} 361}
357 362
358EXPORT_SYMBOL_GPL(dccp_v4_send_check); 363EXPORT_SYMBOL_GPL(dccp_v4_send_check);
@@ -393,18 +398,18 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb,
393 398
394 newinet = inet_sk(newsk); 399 newinet = inet_sk(newsk);
395 ireq = inet_rsk(req); 400 ireq = inet_rsk(req);
396 newinet->daddr = ireq->rmt_addr; 401 newinet->inet_daddr = ireq->rmt_addr;
397 newinet->rcv_saddr = ireq->loc_addr; 402 newinet->inet_rcv_saddr = ireq->loc_addr;
398 newinet->saddr = ireq->loc_addr; 403 newinet->inet_saddr = ireq->loc_addr;
399 newinet->opt = ireq->opt; 404 newinet->opt = ireq->opt;
400 ireq->opt = NULL; 405 ireq->opt = NULL;
401 newinet->mc_index = inet_iif(skb); 406 newinet->mc_index = inet_iif(skb);
402 newinet->mc_ttl = ip_hdr(skb)->ttl; 407 newinet->mc_ttl = ip_hdr(skb)->ttl;
403 newinet->id = jiffies; 408 newinet->inet_id = jiffies;
404 409
405 dccp_sync_mss(newsk, dst_mtu(dst)); 410 dccp_sync_mss(newsk, dst_mtu(dst));
406 411
407 __inet_hash_nolisten(newsk); 412 __inet_hash_nolisten(newsk, NULL);
408 __inet_inherit_port(sk, newsk); 413 __inet_inherit_port(sk, newsk);
409 414
410 return newsk; 415 return newsk;
@@ -473,7 +478,8 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
473 return &rt->u.dst; 478 return &rt->u.dst;
474} 479}
475 480
476static int dccp_v4_send_response(struct sock *sk, struct request_sock *req) 481static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
482 struct request_values *rv_unused)
477{ 483{
478 int err = -1; 484 int err = -1;
479 struct sk_buff *skb; 485 struct sk_buff *skb;
@@ -622,7 +628,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
622 dreq->dreq_iss = dccp_v4_init_sequence(skb); 628 dreq->dreq_iss = dccp_v4_init_sequence(skb);
623 dreq->dreq_service = service; 629 dreq->dreq_service = service;
624 630
625 if (dccp_v4_send_response(sk, req)) 631 if (dccp_v4_send_response(sk, req, NULL))
626 goto drop_and_free; 632 goto drop_and_free;
627 633
628 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); 634 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
@@ -987,21 +993,20 @@ static struct inet_protosw dccp_v4_protosw = {
987 .protocol = IPPROTO_DCCP, 993 .protocol = IPPROTO_DCCP,
988 .prot = &dccp_v4_prot, 994 .prot = &dccp_v4_prot,
989 .ops = &inet_dccp_ops, 995 .ops = &inet_dccp_ops,
990 .capability = -1,
991 .no_check = 0, 996 .no_check = 0,
992 .flags = INET_PROTOSW_ICSK, 997 .flags = INET_PROTOSW_ICSK,
993}; 998};
994 999
995static int dccp_v4_init_net(struct net *net) 1000static int __net_init dccp_v4_init_net(struct net *net)
996{ 1001{
997 int err; 1002 if (dccp_hashinfo.bhash == NULL)
1003 return -ESOCKTNOSUPPORT;
998 1004
999 err = inet_ctl_sock_create(&net->dccp.v4_ctl_sk, PF_INET, 1005 return inet_ctl_sock_create(&net->dccp.v4_ctl_sk, PF_INET,
1000 SOCK_DCCP, IPPROTO_DCCP, net); 1006 SOCK_DCCP, IPPROTO_DCCP, net);
1001 return err;
1002} 1007}
1003 1008
1004static void dccp_v4_exit_net(struct net *net) 1009static void __net_exit dccp_v4_exit_net(struct net *net)
1005{ 1010{
1006 inet_ctl_sock_destroy(net->dccp.v4_ctl_sk); 1011 inet_ctl_sock_destroy(net->dccp.v4_ctl_sk);
1007} 1012}