diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-06-19 01:46:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-19 01:46:52 -0400 |
commit | 2e6599cb899ba4b133f42cbf9d2b1883d2dc583a (patch) | |
tree | b5d4fcca4d2a515fc3d3d20cefaaeebd8dbf661f /net/ipv4/tcp_diag.c | |
parent | 1944972d3bb651474a5021c9da8d0166ae19f1eb (diff) |
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_diag.c')
-rw-r--r-- | net/ipv4/tcp_diag.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c index 8faa8948f75c..700ff2413588 100644 --- a/net/ipv4/tcp_diag.c +++ b/net/ipv4/tcp_diag.c | |||
@@ -458,6 +458,7 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
458 | struct open_request *req, | 458 | struct open_request *req, |
459 | u32 pid, u32 seq) | 459 | u32 pid, u32 seq) |
460 | { | 460 | { |
461 | const struct inet_request_sock *ireq = inet_rsk(req); | ||
461 | struct inet_sock *inet = inet_sk(sk); | 462 | struct inet_sock *inet = inet_sk(sk); |
462 | unsigned char *b = skb->tail; | 463 | unsigned char *b = skb->tail; |
463 | struct tcpdiagmsg *r; | 464 | struct tcpdiagmsg *r; |
@@ -482,9 +483,9 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
482 | tmo = 0; | 483 | tmo = 0; |
483 | 484 | ||
484 | r->id.tcpdiag_sport = inet->sport; | 485 | r->id.tcpdiag_sport = inet->sport; |
485 | r->id.tcpdiag_dport = req->rmt_port; | 486 | r->id.tcpdiag_dport = ireq->rmt_port; |
486 | r->id.tcpdiag_src[0] = req->af.v4_req.loc_addr; | 487 | r->id.tcpdiag_src[0] = ireq->loc_addr; |
487 | r->id.tcpdiag_dst[0] = req->af.v4_req.rmt_addr; | 488 | r->id.tcpdiag_dst[0] = ireq->rmt_addr; |
488 | r->tcpdiag_expires = jiffies_to_msecs(tmo), | 489 | r->tcpdiag_expires = jiffies_to_msecs(tmo), |
489 | r->tcpdiag_rqueue = 0; | 490 | r->tcpdiag_rqueue = 0; |
490 | r->tcpdiag_wqueue = 0; | 491 | r->tcpdiag_wqueue = 0; |
@@ -493,9 +494,9 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, | |||
493 | #ifdef CONFIG_IP_TCPDIAG_IPV6 | 494 | #ifdef CONFIG_IP_TCPDIAG_IPV6 |
494 | if (r->tcpdiag_family == AF_INET6) { | 495 | if (r->tcpdiag_family == AF_INET6) { |
495 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, | 496 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, |
496 | &req->af.v6_req.loc_addr); | 497 | &tcp6_rsk(req)->loc_addr); |
497 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, | 498 | ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, |
498 | &req->af.v6_req.rmt_addr); | 499 | &tcp6_rsk(req)->rmt_addr); |
499 | } | 500 | } |
500 | #endif | 501 | #endif |
501 | nlh->nlmsg_len = skb->tail - b; | 502 | nlh->nlmsg_len = skb->tail - b; |
@@ -545,9 +546,11 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
545 | 546 | ||
546 | reqnum = 0; | 547 | reqnum = 0; |
547 | for (req = head; req; reqnum++, req = req->dl_next) { | 548 | for (req = head; req; reqnum++, req = req->dl_next) { |
549 | struct inet_request_sock *ireq = inet_rsk(req); | ||
550 | |||
548 | if (reqnum < s_reqnum) | 551 | if (reqnum < s_reqnum) |
549 | continue; | 552 | continue; |
550 | if (r->id.tcpdiag_dport != req->rmt_port && | 553 | if (r->id.tcpdiag_dport != ireq->rmt_port && |
551 | r->id.tcpdiag_dport) | 554 | r->id.tcpdiag_dport) |
552 | continue; | 555 | continue; |
553 | 556 | ||
@@ -555,16 +558,16 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, | |||
555 | entry.saddr = | 558 | entry.saddr = |
556 | #ifdef CONFIG_IP_TCPDIAG_IPV6 | 559 | #ifdef CONFIG_IP_TCPDIAG_IPV6 |
557 | (entry.family == AF_INET6) ? | 560 | (entry.family == AF_INET6) ? |
558 | req->af.v6_req.loc_addr.s6_addr32 : | 561 | tcp6_rsk(req)->loc_addr.s6_addr32 : |
559 | #endif | 562 | #endif |
560 | &req->af.v4_req.loc_addr; | 563 | &ireq->loc_addr; |
561 | entry.daddr = | 564 | entry.daddr = |
562 | #ifdef CONFIG_IP_TCPDIAG_IPV6 | 565 | #ifdef CONFIG_IP_TCPDIAG_IPV6 |
563 | (entry.family == AF_INET6) ? | 566 | (entry.family == AF_INET6) ? |
564 | req->af.v6_req.rmt_addr.s6_addr32 : | 567 | tcp6_rsk(req)->rmt_addr.s6_addr32 : |
565 | #endif | 568 | #endif |
566 | &req->af.v4_req.rmt_addr; | 569 | &ireq->rmt_addr; |
567 | entry.dport = ntohs(req->rmt_port); | 570 | entry.dport = ntohs(ireq->rmt_port); |
568 | 571 | ||
569 | if (!tcpdiag_bc_run(RTA_DATA(bc), | 572 | if (!tcpdiag_bc_run(RTA_DATA(bc), |
570 | RTA_PAYLOAD(bc), &entry)) | 573 | RTA_PAYLOAD(bc), &entry)) |