aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2006-11-10 13:08:37 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:22:03 -0500
commitcf557926f6955b4c3fa55e81fdb3675e752e8eed (patch)
tree672d24def170058545736be30040ef2249741cc3 /net/dccp
parentf45b3ec481581f24719d8ab0bc812c02fcedc2bc (diff)
[DCCP]: tidy up dccp_v{4,6}_conn_request
This is a code simplification to remove reduplicated code by concentrating and abstracting shared code. Detailed Changes:
Diffstat (limited to 'net/dccp')
-rw-r--r--net/dccp/dccp.h13
-rw-r--r--net/dccp/ipv4.c9
-rw-r--r--net/dccp/ipv6.c7
-rw-r--r--net/dccp/minisocks.c9
4 files changed, 16 insertions, 22 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 7b859a723826..2990bfb12587 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -155,18 +155,7 @@ extern const char *dccp_state_name(const int state);
155extern void dccp_set_state(struct sock *sk, const int state); 155extern void dccp_set_state(struct sock *sk, const int state);
156extern void dccp_done(struct sock *sk); 156extern void dccp_done(struct sock *sk);
157 157
158static inline void dccp_openreq_init(struct request_sock *req, 158extern void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb);
159 struct dccp_sock *dp,
160 struct sk_buff *skb)
161{
162 /*
163 * FIXME: fill in the other req fields from the DCCP options
164 * received
165 */
166 inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
167 inet_rsk(req)->acked = 0;
168 req->rcv_wnd = 0;
169}
170 159
171extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb); 160extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
172 161
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index ed6202652bcc..d75ce8c7e488 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -636,11 +636,8 @@ static struct request_sock_ops dccp_request_sock_ops __read_mostly = {
636int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) 636int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
637{ 637{
638 struct inet_request_sock *ireq; 638 struct inet_request_sock *ireq;
639 struct dccp_sock dp;
640 struct request_sock *req; 639 struct request_sock *req;
641 struct dccp_request_sock *dreq; 640 struct dccp_request_sock *dreq;
642 const __be32 saddr = skb->nh.iph->saddr;
643 const __be32 daddr = skb->nh.iph->daddr;
644 const __be32 service = dccp_hdr_request(skb)->dccph_req_service; 641 const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
645 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 642 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
646 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; 643 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
@@ -680,14 +677,14 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
680 if (dccp_parse_options(sk, skb)) 677 if (dccp_parse_options(sk, skb))
681 goto drop_and_free; 678 goto drop_and_free;
682 679
683 dccp_openreq_init(req, &dp, skb); 680 dccp_reqsk_init(req, skb);
684 681
685 if (security_inet_conn_request(sk, skb, req)) 682 if (security_inet_conn_request(sk, skb, req))
686 goto drop_and_free; 683 goto drop_and_free;
687 684
688 ireq = inet_rsk(req); 685 ireq = inet_rsk(req);
689 ireq->loc_addr = daddr; 686 ireq->loc_addr = skb->nh.iph->daddr;
690 ireq->rmt_addr = saddr; 687 ireq->rmt_addr = skb->nh.iph->saddr;
691 req->rcv_wnd = dccp_feat_default_sequence_window; 688 req->rcv_wnd = dccp_feat_default_sequence_window;
692 ireq->opt = NULL; 689 ireq->opt = NULL;
693 690
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index ed4a50263802..19a4f763099d 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -427,7 +427,6 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
427 427
428static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) 428static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
429{ 429{
430 struct dccp_sock dp;
431 struct request_sock *req; 430 struct request_sock *req;
432 struct dccp_request_sock *dreq; 431 struct dccp_request_sock *dreq;
433 struct inet6_request_sock *ireq6; 432 struct inet6_request_sock *ireq6;
@@ -459,9 +458,10 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
459 if (req == NULL) 458 if (req == NULL)
460 goto drop; 459 goto drop;
461 460
462 /* FIXME: process options */ 461 if (dccp_parse_options(sk, skb))
462 goto drop_and_free;
463 463
464 dccp_openreq_init(req, &dp, skb); 464 dccp_reqsk_init(req, skb);
465 465
466 if (security_inet_conn_request(sk, skb, req)) 466 if (security_inet_conn_request(sk, skb, req))
467 goto drop_and_free; 467 goto drop_and_free;
@@ -469,7 +469,6 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
469 ireq6 = inet6_rsk(req); 469 ireq6 = inet6_rsk(req);
470 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr); 470 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr);
471 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr); 471 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr);
472 req->rcv_wnd = dccp_feat_default_sequence_window;
473 ireq6->pktopts = NULL; 472 ireq6->pktopts = NULL;
474 473
475 if (ipv6_opt_accepted(sk, skb) || 474 if (ipv6_opt_accepted(sk, skb) ||
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 5f3e1a4c036b..0f228ab5169d 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -293,3 +293,12 @@ void dccp_reqsk_send_ack(struct sk_buff *skb, struct request_sock *rsk)
293} 293}
294 294
295EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack); 295EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack);
296
297void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb)
298{
299 inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
300 inet_rsk(req)->acked = 0;
301 req->rcv_wnd = dccp_feat_default_sequence_window;
302}
303
304EXPORT_SYMBOL_GPL(dccp_reqsk_init);