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/tcp.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/tcp.h')
-rw-r--r-- | include/net/tcp.h | 160 |
1 files changed, 8 insertions, 152 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index a943c79c88b0..dd9a5a288f88 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -19,18 +19,16 @@ | |||
19 | #define _TCP_H | 19 | #define _TCP_H |
20 | 20 | ||
21 | #define TCP_DEBUG 1 | 21 | #define TCP_DEBUG 1 |
22 | #define INET_CSK_DEBUG 1 | ||
23 | #define FASTRETRANS_DEBUG 1 | 22 | #define FASTRETRANS_DEBUG 1 |
24 | 23 | ||
25 | /* Cancel timers, when they are not required. */ | ||
26 | #undef INET_CSK_CLEAR_TIMERS | ||
27 | |||
28 | #include <linux/config.h> | 24 | #include <linux/config.h> |
29 | #include <linux/list.h> | 25 | #include <linux/list.h> |
30 | #include <linux/tcp.h> | 26 | #include <linux/tcp.h> |
31 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
32 | #include <linux/cache.h> | 28 | #include <linux/cache.h> |
33 | #include <linux/percpu.h> | 29 | #include <linux/percpu.h> |
30 | |||
31 | #include <net/inet_connection_sock.h> | ||
34 | #include <net/inet_hashtables.h> | 32 | #include <net/inet_hashtables.h> |
35 | #include <net/checksum.h> | 33 | #include <net/checksum.h> |
36 | #include <net/request_sock.h> | 34 | #include <net/request_sock.h> |
@@ -206,11 +204,6 @@ extern void tcp_tw_deschedule(struct inet_timewait_sock *tw); | |||
206 | #define TCPOLEN_SACK_BASE_ALIGNED 4 | 204 | #define TCPOLEN_SACK_BASE_ALIGNED 4 |
207 | #define TCPOLEN_SACK_PERBLOCK 8 | 205 | #define TCPOLEN_SACK_PERBLOCK 8 |
208 | 206 | ||
209 | #define ICSK_TIME_RETRANS 1 /* Retransmit timer */ | ||
210 | #define ICSK_TIME_DACK 2 /* Delayed ack timer */ | ||
211 | #define ICSK_TIME_PROBE0 3 /* Zero window probe timer */ | ||
212 | #define ICSK_TIME_KEEPOPEN 4 /* Keepalive timer */ | ||
213 | |||
214 | /* Flags in tp->nonagle */ | 207 | /* Flags in tp->nonagle */ |
215 | #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ | 208 | #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ |
216 | #define TCP_NAGLE_CORK 2 /* Socket is corked */ | 209 | #define TCP_NAGLE_CORK 2 /* Socket is corked */ |
@@ -257,12 +250,6 @@ extern atomic_t tcp_memory_allocated; | |||
257 | extern atomic_t tcp_sockets_allocated; | 250 | extern atomic_t tcp_sockets_allocated; |
258 | extern int tcp_memory_pressure; | 251 | extern int tcp_memory_pressure; |
259 | 252 | ||
260 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
261 | #define AF_INET_FAMILY(fam) ((fam) == AF_INET) | ||
262 | #else | ||
263 | #define AF_INET_FAMILY(fam) 1 | ||
264 | #endif | ||
265 | |||
266 | /* | 253 | /* |
267 | * Pointers to address related TCP functions | 254 | * Pointers to address related TCP functions |
268 | * (i.e. things that depend on the address family) | 255 | * (i.e. things that depend on the address family) |
@@ -373,22 +360,6 @@ extern int tcp_rcv_established(struct sock *sk, | |||
373 | 360 | ||
374 | extern void tcp_rcv_space_adjust(struct sock *sk); | 361 | extern void tcp_rcv_space_adjust(struct sock *sk); |
375 | 362 | ||
376 | enum inet_csk_ack_state_t { | ||
377 | ICSK_ACK_SCHED = 1, | ||
378 | ICSK_ACK_TIMER = 2, | ||
379 | ICSK_ACK_PUSHED = 4 | ||
380 | }; | ||
381 | |||
382 | static inline void inet_csk_schedule_ack(struct sock *sk) | ||
383 | { | ||
384 | inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_SCHED; | ||
385 | } | ||
386 | |||
387 | static inline int inet_csk_ack_scheduled(const struct sock *sk) | ||
388 | { | ||
389 | return inet_csk(sk)->icsk_ack.pending & ICSK_ACK_SCHED; | ||
390 | } | ||
391 | |||
392 | static inline void tcp_dec_quickack_mode(struct sock *sk, | 363 | static inline void tcp_dec_quickack_mode(struct sock *sk, |
393 | const unsigned int pkts) | 364 | const unsigned int pkts) |
394 | { | 365 | { |
@@ -406,11 +377,6 @@ static inline void tcp_dec_quickack_mode(struct sock *sk, | |||
406 | 377 | ||
407 | extern void tcp_enter_quickack_mode(struct sock *sk); | 378 | extern void tcp_enter_quickack_mode(struct sock *sk); |
408 | 379 | ||
409 | static inline void inet_csk_delack_init(struct sock *sk) | ||
410 | { | ||
411 | memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack)); | ||
412 | } | ||
413 | |||
414 | static inline void tcp_clear_options(struct tcp_options_received *rx_opt) | 380 | static inline void tcp_clear_options(struct tcp_options_received *rx_opt) |
415 | { | 381 | { |
416 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; | 382 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; |
@@ -442,7 +408,6 @@ extern void tcp_update_metrics(struct sock *sk); | |||
442 | 408 | ||
443 | extern void tcp_close(struct sock *sk, | 409 | extern void tcp_close(struct sock *sk, |
444 | long timeout); | 410 | long timeout); |
445 | extern struct sock * inet_csk_accept(struct sock *sk, int flags, int *err); | ||
446 | extern unsigned int tcp_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait); | 411 | extern unsigned int tcp_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait); |
447 | 412 | ||
448 | extern int tcp_getsockopt(struct sock *sk, int level, | 413 | extern int tcp_getsockopt(struct sock *sk, int level, |
@@ -541,15 +506,9 @@ static inline void tcp_clear_xmit_timers(struct sock *sk) | |||
541 | inet_csk_clear_xmit_timers(sk); | 506 | inet_csk_clear_xmit_timers(sk); |
542 | } | 507 | } |
543 | 508 | ||
544 | extern void inet_csk_delete_keepalive_timer(struct sock *sk); | ||
545 | extern void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long timeout); | ||
546 | extern unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu); | 509 | extern unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu); |
547 | extern unsigned int tcp_current_mss(struct sock *sk, int large); | 510 | extern unsigned int tcp_current_mss(struct sock *sk, int large); |
548 | 511 | ||
549 | #ifdef INET_CSK_DEBUG | ||
550 | extern const char inet_csk_timer_bug_msg[]; | ||
551 | #endif | ||
552 | |||
553 | /* tcp_diag.c */ | 512 | /* tcp_diag.c */ |
554 | extern void tcp_get_info(struct sock *, struct tcp_info *); | 513 | extern void tcp_get_info(struct sock *, struct tcp_info *); |
555 | 514 | ||
@@ -559,60 +518,6 @@ typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, | |||
559 | extern int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, | 518 | extern int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, |
560 | sk_read_actor_t recv_actor); | 519 | sk_read_actor_t recv_actor); |
561 | 520 | ||
562 | static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what) | ||
563 | { | ||
564 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
565 | |||
566 | if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0) { | ||
567 | icsk->icsk_pending = 0; | ||
568 | #ifdef INET_CSK_CLEAR_TIMERS | ||
569 | sk_stop_timer(sk, &icsk->icsk_retransmit_timer); | ||
570 | #endif | ||
571 | } else if (what == ICSK_TIME_DACK) { | ||
572 | icsk->icsk_ack.blocked = icsk->icsk_ack.pending = 0; | ||
573 | #ifdef INET_CSK_CLEAR_TIMERS | ||
574 | sk_stop_timer(sk, &icsk->icsk_delack_timer); | ||
575 | #endif | ||
576 | } | ||
577 | #ifdef INET_CSK_DEBUG | ||
578 | else { | ||
579 | pr_debug(inet_csk_timer_bug_msg); | ||
580 | } | ||
581 | #endif | ||
582 | } | ||
583 | |||
584 | /* | ||
585 | * Reset the retransmission timer | ||
586 | */ | ||
587 | static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what, | ||
588 | unsigned long when) | ||
589 | { | ||
590 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
591 | |||
592 | if (when > TCP_RTO_MAX) { | ||
593 | #ifdef INET_CSK_DEBUG | ||
594 | pr_debug("reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n", | ||
595 | sk, what, when, current_text_addr()); | ||
596 | #endif | ||
597 | when = TCP_RTO_MAX; | ||
598 | } | ||
599 | |||
600 | if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0) { | ||
601 | icsk->icsk_pending = what; | ||
602 | icsk->icsk_timeout = jiffies + when; | ||
603 | sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout); | ||
604 | } else if (what == ICSK_TIME_DACK) { | ||
605 | icsk->icsk_ack.pending |= ICSK_ACK_TIMER; | ||
606 | icsk->icsk_ack.timeout = jiffies + when; | ||
607 | sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout); | ||
608 | } | ||
609 | #ifdef INET_CSK_DEBUG | ||
610 | else { | ||
611 | pr_debug(inet_csk_timer_bug_msg); | ||
612 | } | ||
613 | #endif | ||
614 | } | ||
615 | |||
616 | /* Initialize RCV_MSS value. | 521 | /* Initialize RCV_MSS value. |
617 | * RCV_MSS is an our guess about MSS used by the peer. | 522 | * RCV_MSS is an our guess about MSS used by the peer. |
618 | * We haven't any direct information about the MSS. | 523 | * We haven't any direct information about the MSS. |
@@ -765,7 +670,8 @@ static inline void tcp_packets_out_inc(struct sock *sk, | |||
765 | 670 | ||
766 | tp->packets_out += tcp_skb_pcount(skb); | 671 | tp->packets_out += tcp_skb_pcount(skb); |
767 | if (!orig) | 672 | if (!orig) |
768 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, inet_csk(sk)->icsk_rto); | 673 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
674 | inet_csk(sk)->icsk_rto, TCP_RTO_MAX); | ||
769 | } | 675 | } |
770 | 676 | ||
771 | static inline void tcp_packets_out_dec(struct tcp_sock *tp, | 677 | static inline void tcp_packets_out_dec(struct tcp_sock *tp, |
@@ -934,7 +840,8 @@ static __inline__ void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *t | |||
934 | { | 840 | { |
935 | const struct inet_connection_sock *icsk = inet_csk(sk); | 841 | const struct inet_connection_sock *icsk = inet_csk(sk); |
936 | if (!tp->packets_out && !icsk->icsk_pending) | 842 | if (!tp->packets_out && !icsk->icsk_pending) |
937 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, icsk->icsk_rto); | 843 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, |
844 | icsk->icsk_rto, TCP_RTO_MAX); | ||
938 | } | 845 | } |
939 | 846 | ||
940 | static __inline__ void tcp_push_pending_frames(struct sock *sk, | 847 | static __inline__ void tcp_push_pending_frames(struct sock *sk, |
@@ -1017,7 +924,8 @@ static __inline__ int tcp_prequeue(struct sock *sk, struct sk_buff *skb) | |||
1017 | wake_up_interruptible(sk->sk_sleep); | 924 | wake_up_interruptible(sk->sk_sleep); |
1018 | if (!inet_csk_ack_scheduled(sk)) | 925 | if (!inet_csk_ack_scheduled(sk)) |
1019 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, | 926 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, |
1020 | (3 * TCP_RTO_MIN) / 4); | 927 | (3 * TCP_RTO_MIN) / 4, |
928 | TCP_RTO_MAX); | ||
1021 | } | 929 | } |
1022 | return 1; | 930 | return 1; |
1023 | } | 931 | } |
@@ -1181,58 +1089,6 @@ static inline int tcp_full_space(const struct sock *sk) | |||
1181 | return tcp_win_from_space(sk->sk_rcvbuf); | 1089 | return tcp_win_from_space(sk->sk_rcvbuf); |
1182 | } | 1090 | } |
1183 | 1091 | ||
1184 | static inline void inet_csk_reqsk_queue_add(struct sock *sk, | ||
1185 | struct request_sock *req, | ||
1186 | struct sock *child) | ||
1187 | { | ||
1188 | reqsk_queue_add(&inet_csk(sk)->icsk_accept_queue, req, sk, child); | ||
1189 | } | ||
1190 | |||
1191 | static inline void inet_csk_reqsk_queue_removed(struct sock *sk, | ||
1192 | struct request_sock *req) | ||
1193 | { | ||
1194 | if (reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req) == 0) | ||
1195 | inet_csk_delete_keepalive_timer(sk); | ||
1196 | } | ||
1197 | |||
1198 | static inline void inet_csk_reqsk_queue_added(struct sock *sk, | ||
1199 | const unsigned long timeout) | ||
1200 | { | ||
1201 | if (reqsk_queue_added(&inet_csk(sk)->icsk_accept_queue) == 0) | ||
1202 | inet_csk_reset_keepalive_timer(sk, timeout); | ||
1203 | } | ||
1204 | |||
1205 | static inline int inet_csk_reqsk_queue_len(const struct sock *sk) | ||
1206 | { | ||
1207 | return reqsk_queue_len(&inet_csk(sk)->icsk_accept_queue); | ||
1208 | } | ||
1209 | |||
1210 | static inline int inet_csk_reqsk_queue_young(const struct sock *sk) | ||
1211 | { | ||
1212 | return reqsk_queue_len_young(&inet_csk(sk)->icsk_accept_queue); | ||
1213 | } | ||
1214 | |||
1215 | static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk) | ||
1216 | { | ||
1217 | return reqsk_queue_is_full(&inet_csk(sk)->icsk_accept_queue); | ||
1218 | } | ||
1219 | |||
1220 | static inline void inet_csk_reqsk_queue_unlink(struct sock *sk, | ||
1221 | struct request_sock *req, | ||
1222 | struct request_sock **prev) | ||
1223 | { | ||
1224 | reqsk_queue_unlink(&inet_csk(sk)->icsk_accept_queue, req, prev); | ||
1225 | } | ||
1226 | |||
1227 | static inline void inet_csk_reqsk_queue_drop(struct sock *sk, | ||
1228 | struct request_sock *req, | ||
1229 | struct request_sock **prev) | ||
1230 | { | ||
1231 | inet_csk_reqsk_queue_unlink(sk, req, prev); | ||
1232 | inet_csk_reqsk_queue_removed(sk, req); | ||
1233 | reqsk_free(req); | ||
1234 | } | ||
1235 | |||
1236 | static __inline__ void tcp_openreq_init(struct request_sock *req, | 1092 | static __inline__ void tcp_openreq_init(struct request_sock *req, |
1237 | struct tcp_options_received *rx_opt, | 1093 | struct tcp_options_received *rx_opt, |
1238 | struct sk_buff *skb) | 1094 | struct sk_buff *skb) |