diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-08-09 23:11:08 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:49:14 -0400 |
commit | 3f421baa4720b708022f8bcc52a61e5cd6f10bf8 (patch) | |
tree | e4201b1e2356cea8b7bd8d68dfba06e84002a77d /include/net/inet_connection_sock.h | |
parent | 463c84b97f24010a67cd871746d6a7e4c925a5f9 (diff) |
[NET]: Just move the inet_connection_sock function from tcp sources
Completing the previous changeset, this also generalises tcp_v4_synq_add,
renaming it to inet_csk_reqsk_queue_hash_add, already geing used in the
DCCP tree, which I plan to merge RSN.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet_connection_sock.h')
-rw-r--r-- | include/net/inet_connection_sock.h | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index ef609396e41b..97e002001c1a 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -16,9 +16,15 @@ | |||
16 | #define _INET_CONNECTION_SOCK_H | 16 | #define _INET_CONNECTION_SOCK_H |
17 | 17 | ||
18 | #include <linux/ip.h> | 18 | #include <linux/ip.h> |
19 | #include <linux/string.h> | ||
19 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
20 | #include <net/request_sock.h> | 21 | #include <net/request_sock.h> |
21 | 22 | ||
23 | #define INET_CSK_DEBUG 1 | ||
24 | |||
25 | /* Cancel timers, when they are not required. */ | ||
26 | #undef INET_CSK_CLEAR_TIMERS | ||
27 | |||
22 | struct inet_bind_bucket; | 28 | struct inet_bind_bucket; |
23 | struct inet_hashinfo; | 29 | struct inet_hashinfo; |
24 | 30 | ||
@@ -61,17 +67,107 @@ struct inet_connection_sock { | |||
61 | } icsk_ack; | 67 | } icsk_ack; |
62 | }; | 68 | }; |
63 | 69 | ||
70 | #define ICSK_TIME_RETRANS 1 /* Retransmit timer */ | ||
71 | #define ICSK_TIME_DACK 2 /* Delayed ack timer */ | ||
72 | #define ICSK_TIME_PROBE0 3 /* Zero window probe timer */ | ||
73 | #define ICSK_TIME_KEEPOPEN 4 /* Keepalive timer */ | ||
74 | |||
64 | static inline struct inet_connection_sock *inet_csk(const struct sock *sk) | 75 | static inline struct inet_connection_sock *inet_csk(const struct sock *sk) |
65 | { | 76 | { |
66 | return (struct inet_connection_sock *)sk; | 77 | return (struct inet_connection_sock *)sk; |
67 | } | 78 | } |
68 | 79 | ||
80 | enum inet_csk_ack_state_t { | ||
81 | ICSK_ACK_SCHED = 1, | ||
82 | ICSK_ACK_TIMER = 2, | ||
83 | ICSK_ACK_PUSHED = 4 | ||
84 | }; | ||
85 | |||
69 | extern void inet_csk_init_xmit_timers(struct sock *sk, | 86 | extern void inet_csk_init_xmit_timers(struct sock *sk, |
70 | void (*retransmit_handler)(unsigned long), | 87 | void (*retransmit_handler)(unsigned long), |
71 | void (*delack_handler)(unsigned long), | 88 | void (*delack_handler)(unsigned long), |
72 | void (*keepalive_handler)(unsigned long)); | 89 | void (*keepalive_handler)(unsigned long)); |
73 | extern void inet_csk_clear_xmit_timers(struct sock *sk); | 90 | extern void inet_csk_clear_xmit_timers(struct sock *sk); |
74 | 91 | ||
92 | static inline void inet_csk_schedule_ack(struct sock *sk) | ||
93 | { | ||
94 | inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_SCHED; | ||
95 | } | ||
96 | |||
97 | static inline int inet_csk_ack_scheduled(const struct sock *sk) | ||
98 | { | ||
99 | return inet_csk(sk)->icsk_ack.pending & ICSK_ACK_SCHED; | ||
100 | } | ||
101 | |||
102 | static inline void inet_csk_delack_init(struct sock *sk) | ||
103 | { | ||
104 | memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack)); | ||
105 | } | ||
106 | |||
107 | extern void inet_csk_delete_keepalive_timer(struct sock *sk); | ||
108 | extern void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long timeout); | ||
109 | |||
110 | #ifdef INET_CSK_DEBUG | ||
111 | extern const char inet_csk_timer_bug_msg[]; | ||
112 | #endif | ||
113 | |||
114 | static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what) | ||
115 | { | ||
116 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
117 | |||
118 | if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0) { | ||
119 | icsk->icsk_pending = 0; | ||
120 | #ifdef INET_CSK_CLEAR_TIMERS | ||
121 | sk_stop_timer(sk, &icsk->icsk_retransmit_timer); | ||
122 | #endif | ||
123 | } else if (what == ICSK_TIME_DACK) { | ||
124 | icsk->icsk_ack.blocked = icsk->icsk_ack.pending = 0; | ||
125 | #ifdef INET_CSK_CLEAR_TIMERS | ||
126 | sk_stop_timer(sk, &icsk->icsk_delack_timer); | ||
127 | #endif | ||
128 | } | ||
129 | #ifdef INET_CSK_DEBUG | ||
130 | else { | ||
131 | pr_debug(inet_csk_timer_bug_msg); | ||
132 | } | ||
133 | #endif | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * Reset the retransmission timer | ||
138 | */ | ||
139 | static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what, | ||
140 | unsigned long when, | ||
141 | const unsigned long max_when) | ||
142 | { | ||
143 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
144 | |||
145 | if (when > max_when) { | ||
146 | #ifdef INET_CSK_DEBUG | ||
147 | pr_debug("reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n", | ||
148 | sk, what, when, current_text_addr()); | ||
149 | #endif | ||
150 | when = max_when; | ||
151 | } | ||
152 | |||
153 | if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0) { | ||
154 | icsk->icsk_pending = what; | ||
155 | icsk->icsk_timeout = jiffies + when; | ||
156 | sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout); | ||
157 | } else if (what == ICSK_TIME_DACK) { | ||
158 | icsk->icsk_ack.pending |= ICSK_ACK_TIMER; | ||
159 | icsk->icsk_ack.timeout = jiffies + when; | ||
160 | sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout); | ||
161 | } | ||
162 | #ifdef INET_CSK_DEBUG | ||
163 | else { | ||
164 | pr_debug(inet_csk_timer_bug_msg); | ||
165 | } | ||
166 | #endif | ||
167 | } | ||
168 | |||
169 | extern struct sock *inet_csk_accept(struct sock *sk, int flags, int *err); | ||
170 | |||
75 | extern struct request_sock *inet_csk_search_req(const struct sock *sk, | 171 | extern struct request_sock *inet_csk_search_req(const struct sock *sk, |
76 | struct request_sock ***prevp, | 172 | struct request_sock ***prevp, |
77 | const __u16 rport, | 173 | const __u16 rport, |
@@ -83,4 +179,60 @@ extern int inet_csk_get_port(struct inet_hashinfo *hashinfo, | |||
83 | extern struct dst_entry* inet_csk_route_req(struct sock *sk, | 179 | extern struct dst_entry* inet_csk_route_req(struct sock *sk, |
84 | const struct request_sock *req); | 180 | const struct request_sock *req); |
85 | 181 | ||
182 | static inline void inet_csk_reqsk_queue_add(struct sock *sk, | ||
183 | struct request_sock *req, | ||
184 | struct sock *child) | ||
185 | { | ||
186 | reqsk_queue_add(&inet_csk(sk)->icsk_accept_queue, req, sk, child); | ||
187 | } | ||
188 | |||
189 | extern void inet_csk_reqsk_queue_hash_add(struct sock *sk, | ||
190 | struct request_sock *req, | ||
191 | const unsigned timeout); | ||
192 | |||
193 | static inline void inet_csk_reqsk_queue_removed(struct sock *sk, | ||
194 | struct request_sock *req) | ||
195 | { | ||
196 | if (reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req) == 0) | ||
197 | inet_csk_delete_keepalive_timer(sk); | ||
198 | } | ||
199 | |||
200 | static inline void inet_csk_reqsk_queue_added(struct sock *sk, | ||
201 | const unsigned long timeout) | ||
202 | { | ||
203 | if (reqsk_queue_added(&inet_csk(sk)->icsk_accept_queue) == 0) | ||
204 | inet_csk_reset_keepalive_timer(sk, timeout); | ||
205 | } | ||
206 | |||
207 | static inline int inet_csk_reqsk_queue_len(const struct sock *sk) | ||
208 | { | ||
209 | return reqsk_queue_len(&inet_csk(sk)->icsk_accept_queue); | ||
210 | } | ||
211 | |||
212 | static inline int inet_csk_reqsk_queue_young(const struct sock *sk) | ||
213 | { | ||
214 | return reqsk_queue_len_young(&inet_csk(sk)->icsk_accept_queue); | ||
215 | } | ||
216 | |||
217 | static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk) | ||
218 | { | ||
219 | return reqsk_queue_is_full(&inet_csk(sk)->icsk_accept_queue); | ||
220 | } | ||
221 | |||
222 | static inline void inet_csk_reqsk_queue_unlink(struct sock *sk, | ||
223 | struct request_sock *req, | ||
224 | struct request_sock **prev) | ||
225 | { | ||
226 | reqsk_queue_unlink(&inet_csk(sk)->icsk_accept_queue, req, prev); | ||
227 | } | ||
228 | |||
229 | static inline void inet_csk_reqsk_queue_drop(struct sock *sk, | ||
230 | struct request_sock *req, | ||
231 | struct request_sock **prev) | ||
232 | { | ||
233 | inet_csk_reqsk_queue_unlink(sk, req, prev); | ||
234 | inet_csk_reqsk_queue_removed(sk, req); | ||
235 | reqsk_free(req); | ||
236 | } | ||
237 | |||
86 | #endif /* _INET_CONNECTION_SOCK_H */ | 238 | #endif /* _INET_CONNECTION_SOCK_H */ |