diff options
author | Eric Dumazet <edumazet@google.com> | 2013-10-09 18:21:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-10 00:08:07 -0400 |
commit | 634fb979e8f3a70f04c1f2f519d0cd1142eb5c1a (patch) | |
tree | ffd7f7ef4a313c94859180d1bc20f2713a11f987 /net/dccp | |
parent | 8a29111c7ca68d928dfab58636f3f6acf0ac04f7 (diff) |
inet: includes a sock_common in request_sock
TCP listener refactoring, part 5 :
We want to be able to insert request sockets (SYN_RECV) into main
ehash table instead of the per listener hash table to allow RCU
lookups and remove listener lock contention.
This patch includes the needed struct sock_common in front
of struct request_sock
This means there is no more inet6_request_sock IPv6 specific
structure.
Following inet_request_sock fields were renamed as they became
macros to reference fields from struct sock_common.
Prefix ir_ was chosen to avoid name collisions.
loc_port -> ir_loc_port
loc_addr -> ir_loc_addr
rmt_addr -> ir_rmt_addr
rmt_port -> ir_rmt_port
iif -> ir_iif
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ipv4.c | 18 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 63 | ||||
-rw-r--r-- | net/dccp/ipv6.h | 1 | ||||
-rw-r--r-- | net/dccp/minisocks.c | 4 | ||||
-rw-r--r-- | net/dccp/output.c | 4 |
5 files changed, 44 insertions, 46 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index ebc54fef85a5..720c36225ed9 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -409,9 +409,9 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
409 | 409 | ||
410 | newinet = inet_sk(newsk); | 410 | newinet = inet_sk(newsk); |
411 | ireq = inet_rsk(req); | 411 | ireq = inet_rsk(req); |
412 | newinet->inet_daddr = ireq->rmt_addr; | 412 | newinet->inet_daddr = ireq->ir_rmt_addr; |
413 | newinet->inet_rcv_saddr = ireq->loc_addr; | 413 | newinet->inet_rcv_saddr = ireq->ir_loc_addr; |
414 | newinet->inet_saddr = ireq->loc_addr; | 414 | newinet->inet_saddr = ireq->ir_loc_addr; |
415 | newinet->inet_opt = ireq->opt; | 415 | newinet->inet_opt = ireq->opt; |
416 | ireq->opt = NULL; | 416 | ireq->opt = NULL; |
417 | newinet->mc_index = inet_iif(skb); | 417 | newinet->mc_index = inet_iif(skb); |
@@ -516,10 +516,10 @@ static int dccp_v4_send_response(struct sock *sk, struct request_sock *req) | |||
516 | const struct inet_request_sock *ireq = inet_rsk(req); | 516 | const struct inet_request_sock *ireq = inet_rsk(req); |
517 | struct dccp_hdr *dh = dccp_hdr(skb); | 517 | struct dccp_hdr *dh = dccp_hdr(skb); |
518 | 518 | ||
519 | dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->loc_addr, | 519 | dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->ir_loc_addr, |
520 | ireq->rmt_addr); | 520 | ireq->ir_rmt_addr); |
521 | err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr, | 521 | err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr, |
522 | ireq->rmt_addr, | 522 | ireq->ir_rmt_addr, |
523 | ireq->opt); | 523 | ireq->opt); |
524 | err = net_xmit_eval(err); | 524 | err = net_xmit_eval(err); |
525 | } | 525 | } |
@@ -641,8 +641,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
641 | goto drop_and_free; | 641 | goto drop_and_free; |
642 | 642 | ||
643 | ireq = inet_rsk(req); | 643 | ireq = inet_rsk(req); |
644 | ireq->loc_addr = ip_hdr(skb)->daddr; | 644 | ireq->ir_loc_addr = ip_hdr(skb)->daddr; |
645 | ireq->rmt_addr = ip_hdr(skb)->saddr; | 645 | ireq->ir_rmt_addr = ip_hdr(skb)->saddr; |
646 | 646 | ||
647 | /* | 647 | /* |
648 | * Step 3: Process LISTEN state | 648 | * Step 3: Process LISTEN state |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 7f075b83128a..5cc5b24a956e 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -216,7 +216,7 @@ out: | |||
216 | 216 | ||
217 | static int dccp_v6_send_response(struct sock *sk, struct request_sock *req) | 217 | static int dccp_v6_send_response(struct sock *sk, struct request_sock *req) |
218 | { | 218 | { |
219 | struct inet6_request_sock *ireq6 = inet6_rsk(req); | 219 | struct inet_request_sock *ireq = inet_rsk(req); |
220 | struct ipv6_pinfo *np = inet6_sk(sk); | 220 | struct ipv6_pinfo *np = inet6_sk(sk); |
221 | struct sk_buff *skb; | 221 | struct sk_buff *skb; |
222 | struct in6_addr *final_p, final; | 222 | struct in6_addr *final_p, final; |
@@ -226,12 +226,12 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req) | |||
226 | 226 | ||
227 | memset(&fl6, 0, sizeof(fl6)); | 227 | memset(&fl6, 0, sizeof(fl6)); |
228 | fl6.flowi6_proto = IPPROTO_DCCP; | 228 | fl6.flowi6_proto = IPPROTO_DCCP; |
229 | fl6.daddr = ireq6->rmt_addr; | 229 | fl6.daddr = ireq->ir_v6_rmt_addr; |
230 | fl6.saddr = ireq6->loc_addr; | 230 | fl6.saddr = ireq->ir_v6_loc_addr; |
231 | fl6.flowlabel = 0; | 231 | fl6.flowlabel = 0; |
232 | fl6.flowi6_oif = ireq6->iif; | 232 | fl6.flowi6_oif = ireq->ir_iif; |
233 | fl6.fl6_dport = inet_rsk(req)->rmt_port; | 233 | fl6.fl6_dport = ireq->ir_rmt_port; |
234 | fl6.fl6_sport = inet_rsk(req)->loc_port; | 234 | fl6.fl6_sport = ireq->ir_loc_port; |
235 | security_req_classify_flow(req, flowi6_to_flowi(&fl6)); | 235 | security_req_classify_flow(req, flowi6_to_flowi(&fl6)); |
236 | 236 | ||
237 | 237 | ||
@@ -249,9 +249,9 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req) | |||
249 | struct dccp_hdr *dh = dccp_hdr(skb); | 249 | struct dccp_hdr *dh = dccp_hdr(skb); |
250 | 250 | ||
251 | dh->dccph_checksum = dccp_v6_csum_finish(skb, | 251 | dh->dccph_checksum = dccp_v6_csum_finish(skb, |
252 | &ireq6->loc_addr, | 252 | &ireq->ir_v6_loc_addr, |
253 | &ireq6->rmt_addr); | 253 | &ireq->ir_v6_rmt_addr); |
254 | fl6.daddr = ireq6->rmt_addr; | 254 | fl6.daddr = ireq->ir_v6_rmt_addr; |
255 | err = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass); | 255 | err = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass); |
256 | err = net_xmit_eval(err); | 256 | err = net_xmit_eval(err); |
257 | } | 257 | } |
@@ -264,8 +264,7 @@ done: | |||
264 | static void dccp_v6_reqsk_destructor(struct request_sock *req) | 264 | static void dccp_v6_reqsk_destructor(struct request_sock *req) |
265 | { | 265 | { |
266 | dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg); | 266 | dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg); |
267 | if (inet6_rsk(req)->pktopts != NULL) | 267 | kfree_skb(inet_rsk(req)->pktopts); |
268 | kfree_skb(inet6_rsk(req)->pktopts); | ||
269 | } | 268 | } |
270 | 269 | ||
271 | static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb) | 270 | static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb) |
@@ -359,7 +358,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
359 | { | 358 | { |
360 | struct request_sock *req; | 359 | struct request_sock *req; |
361 | struct dccp_request_sock *dreq; | 360 | struct dccp_request_sock *dreq; |
362 | struct inet6_request_sock *ireq6; | 361 | struct inet_request_sock *ireq; |
363 | struct ipv6_pinfo *np = inet6_sk(sk); | 362 | struct ipv6_pinfo *np = inet6_sk(sk); |
364 | const __be32 service = dccp_hdr_request(skb)->dccph_req_service; | 363 | const __be32 service = dccp_hdr_request(skb)->dccph_req_service; |
365 | struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); | 364 | struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); |
@@ -398,22 +397,22 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
398 | if (security_inet_conn_request(sk, skb, req)) | 397 | if (security_inet_conn_request(sk, skb, req)) |
399 | goto drop_and_free; | 398 | goto drop_and_free; |
400 | 399 | ||
401 | ireq6 = inet6_rsk(req); | 400 | ireq = inet_rsk(req); |
402 | ireq6->rmt_addr = ipv6_hdr(skb)->saddr; | 401 | ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr; |
403 | ireq6->loc_addr = ipv6_hdr(skb)->daddr; | 402 | ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr; |
404 | 403 | ||
405 | if (ipv6_opt_accepted(sk, skb) || | 404 | if (ipv6_opt_accepted(sk, skb) || |
406 | np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || | 405 | np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || |
407 | np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { | 406 | np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { |
408 | atomic_inc(&skb->users); | 407 | atomic_inc(&skb->users); |
409 | ireq6->pktopts = skb; | 408 | ireq->pktopts = skb; |
410 | } | 409 | } |
411 | ireq6->iif = sk->sk_bound_dev_if; | 410 | ireq->ir_iif = sk->sk_bound_dev_if; |
412 | 411 | ||
413 | /* So that link locals have meaning */ | 412 | /* So that link locals have meaning */ |
414 | if (!sk->sk_bound_dev_if && | 413 | if (!sk->sk_bound_dev_if && |
415 | ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL) | 414 | ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL) |
416 | ireq6->iif = inet6_iif(skb); | 415 | ireq->ir_iif = inet6_iif(skb); |
417 | 416 | ||
418 | /* | 417 | /* |
419 | * Step 3: Process LISTEN state | 418 | * Step 3: Process LISTEN state |
@@ -446,7 +445,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
446 | struct request_sock *req, | 445 | struct request_sock *req, |
447 | struct dst_entry *dst) | 446 | struct dst_entry *dst) |
448 | { | 447 | { |
449 | struct inet6_request_sock *ireq6 = inet6_rsk(req); | 448 | struct inet_request_sock *ireq = inet_rsk(req); |
450 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); | 449 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); |
451 | struct inet_sock *newinet; | 450 | struct inet_sock *newinet; |
452 | struct dccp6_sock *newdp6; | 451 | struct dccp6_sock *newdp6; |
@@ -505,12 +504,12 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
505 | 504 | ||
506 | memset(&fl6, 0, sizeof(fl6)); | 505 | memset(&fl6, 0, sizeof(fl6)); |
507 | fl6.flowi6_proto = IPPROTO_DCCP; | 506 | fl6.flowi6_proto = IPPROTO_DCCP; |
508 | fl6.daddr = ireq6->rmt_addr; | 507 | fl6.daddr = ireq->ir_v6_rmt_addr; |
509 | final_p = fl6_update_dst(&fl6, np->opt, &final); | 508 | final_p = fl6_update_dst(&fl6, np->opt, &final); |
510 | fl6.saddr = ireq6->loc_addr; | 509 | fl6.saddr = ireq->ir_v6_loc_addr; |
511 | fl6.flowi6_oif = sk->sk_bound_dev_if; | 510 | fl6.flowi6_oif = sk->sk_bound_dev_if; |
512 | fl6.fl6_dport = inet_rsk(req)->rmt_port; | 511 | fl6.fl6_dport = ireq->ir_rmt_port; |
513 | fl6.fl6_sport = inet_rsk(req)->loc_port; | 512 | fl6.fl6_sport = ireq->ir_loc_port; |
514 | security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); | 513 | security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); |
515 | 514 | ||
516 | dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false); | 515 | dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false); |
@@ -538,10 +537,10 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
538 | 537 | ||
539 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); | 538 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); |
540 | 539 | ||
541 | newsk->sk_v6_daddr = ireq6->rmt_addr; | 540 | newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr; |
542 | newnp->saddr = ireq6->loc_addr; | 541 | newnp->saddr = ireq->ir_v6_loc_addr; |
543 | newsk->sk_v6_rcv_saddr = ireq6->loc_addr; | 542 | newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr; |
544 | newsk->sk_bound_dev_if = ireq6->iif; | 543 | newsk->sk_bound_dev_if = ireq->ir_iif; |
545 | 544 | ||
546 | /* Now IPv6 options... | 545 | /* Now IPv6 options... |
547 | 546 | ||
@@ -554,10 +553,10 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
554 | 553 | ||
555 | /* Clone pktoptions received with SYN */ | 554 | /* Clone pktoptions received with SYN */ |
556 | newnp->pktoptions = NULL; | 555 | newnp->pktoptions = NULL; |
557 | if (ireq6->pktopts != NULL) { | 556 | if (ireq->pktopts != NULL) { |
558 | newnp->pktoptions = skb_clone(ireq6->pktopts, GFP_ATOMIC); | 557 | newnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC); |
559 | consume_skb(ireq6->pktopts); | 558 | consume_skb(ireq->pktopts); |
560 | ireq6->pktopts = NULL; | 559 | ireq->pktopts = NULL; |
561 | if (newnp->pktoptions) | 560 | if (newnp->pktoptions) |
562 | skb_set_owner_r(newnp->pktoptions, newsk); | 561 | skb_set_owner_r(newnp->pktoptions, newsk); |
563 | } | 562 | } |
diff --git a/net/dccp/ipv6.h b/net/dccp/ipv6.h index 6604fc3fe953..af259e15e7f0 100644 --- a/net/dccp/ipv6.h +++ b/net/dccp/ipv6.h | |||
@@ -25,7 +25,6 @@ struct dccp6_sock { | |||
25 | 25 | ||
26 | struct dccp6_request_sock { | 26 | struct dccp6_request_sock { |
27 | struct dccp_request_sock dccp; | 27 | struct dccp_request_sock dccp; |
28 | struct inet6_request_sock inet6; | ||
29 | }; | 28 | }; |
30 | 29 | ||
31 | struct dccp6_timewait_sock { | 30 | struct dccp6_timewait_sock { |
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 32e80d96d4c0..66afbcec2941 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c | |||
@@ -266,8 +266,8 @@ int dccp_reqsk_init(struct request_sock *req, | |||
266 | { | 266 | { |
267 | struct dccp_request_sock *dreq = dccp_rsk(req); | 267 | struct dccp_request_sock *dreq = dccp_rsk(req); |
268 | 268 | ||
269 | inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport; | 269 | inet_rsk(req)->ir_rmt_port = dccp_hdr(skb)->dccph_sport; |
270 | inet_rsk(req)->loc_port = dccp_hdr(skb)->dccph_dport; | 270 | inet_rsk(req)->ir_loc_port = dccp_hdr(skb)->dccph_dport; |
271 | inet_rsk(req)->acked = 0; | 271 | inet_rsk(req)->acked = 0; |
272 | dreq->dreq_timestamp_echo = 0; | 272 | dreq->dreq_timestamp_echo = 0; |
273 | 273 | ||
diff --git a/net/dccp/output.c b/net/dccp/output.c index d17fc90a74b6..9bf195d1b87a 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
@@ -424,8 +424,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, | |||
424 | /* Build and checksum header */ | 424 | /* Build and checksum header */ |
425 | dh = dccp_zeroed_hdr(skb, dccp_header_size); | 425 | dh = dccp_zeroed_hdr(skb, dccp_header_size); |
426 | 426 | ||
427 | dh->dccph_sport = inet_rsk(req)->loc_port; | 427 | dh->dccph_sport = inet_rsk(req)->ir_loc_port; |
428 | dh->dccph_dport = inet_rsk(req)->rmt_port; | 428 | dh->dccph_dport = inet_rsk(req)->ir_rmt_port; |
429 | dh->dccph_doff = (dccp_header_size + | 429 | dh->dccph_doff = (dccp_header_size + |
430 | DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; | 430 | DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; |
431 | dh->dccph_type = DCCP_PKT_RESPONSE; | 431 | dh->dccph_type = DCCP_PKT_RESPONSE; |