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 /include/net/request_sock.h | |
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 'include/net/request_sock.h')
-rw-r--r-- | include/net/request_sock.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/include/net/request_sock.h b/include/net/request_sock.h new file mode 100644 index 000000000000..9502f5587931 --- /dev/null +++ b/include/net/request_sock.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * NET Generic infrastructure for Network protocols. | ||
3 | * | ||
4 | * Definitions for request_sock | ||
5 | * | ||
6 | * Authors: Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
7 | * | ||
8 | * From code originally in include/net/tcp.h | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | ||
15 | #ifndef _REQUEST_SOCK_H | ||
16 | #define _REQUEST_SOCK_H | ||
17 | |||
18 | #include <linux/slab.h> | ||
19 | #include <linux/types.h> | ||
20 | #include <net/sock.h> | ||
21 | |||
22 | struct open_request; | ||
23 | struct sk_buff; | ||
24 | struct dst_entry; | ||
25 | struct proto; | ||
26 | |||
27 | struct or_calltable { | ||
28 | int family; | ||
29 | kmem_cache_t *slab; | ||
30 | int obj_size; | ||
31 | int (*rtx_syn_ack)(struct sock *sk, | ||
32 | struct open_request *req, | ||
33 | struct dst_entry *dst); | ||
34 | void (*send_ack)(struct sk_buff *skb, | ||
35 | struct open_request *req); | ||
36 | void (*send_reset)(struct sk_buff *skb); | ||
37 | void (*destructor)(struct open_request *req); | ||
38 | }; | ||
39 | |||
40 | /* struct open_request - mini sock to represent a connection request | ||
41 | */ | ||
42 | struct open_request { | ||
43 | struct open_request *dl_next; /* Must be first member! */ | ||
44 | u16 mss; | ||
45 | u8 retrans; | ||
46 | u8 __pad; | ||
47 | /* The following two fields can be easily recomputed I think -AK */ | ||
48 | u32 window_clamp; /* window clamp at creation time */ | ||
49 | u32 rcv_wnd; /* rcv_wnd offered first time */ | ||
50 | u32 ts_recent; | ||
51 | unsigned long expires; | ||
52 | struct or_calltable *class; | ||
53 | struct sock *sk; | ||
54 | }; | ||
55 | |||
56 | static inline struct open_request *tcp_openreq_alloc(struct or_calltable *class) | ||
57 | { | ||
58 | struct open_request *req = kmem_cache_alloc(class->slab, SLAB_ATOMIC); | ||
59 | |||
60 | if (req != NULL) | ||
61 | req->class = class; | ||
62 | |||
63 | return req; | ||
64 | } | ||
65 | |||
66 | static inline void tcp_openreq_fastfree(struct open_request *req) | ||
67 | { | ||
68 | kmem_cache_free(req->class->slab, req); | ||
69 | } | ||
70 | |||
71 | static inline void tcp_openreq_free(struct open_request *req) | ||
72 | { | ||
73 | req->class->destructor(req); | ||
74 | tcp_openreq_fastfree(req); | ||
75 | } | ||
76 | |||
77 | #endif /* _REQUEST_SOCK_H */ | ||