aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h71
1 files changed, 38 insertions, 33 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index acc620a4a45f..e147f42d643d 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -18,7 +18,6 @@
18#ifndef _TCP_H 18#ifndef _TCP_H
19#define _TCP_H 19#define _TCP_H
20 20
21#define TCP_DEBUG 1
22#define FASTRETRANS_DEBUG 1 21#define FASTRETRANS_DEBUG 1
23 22
24#include <linux/list.h> 23#include <linux/list.h>
@@ -327,9 +326,9 @@ extern int tcp_sendpage(struct sock *sk, struct page *page, int offset,
327 size_t size, int flags); 326 size_t size, int flags);
328extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); 327extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg);
329extern int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, 328extern int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
330 struct tcphdr *th, unsigned len); 329 const struct tcphdr *th, unsigned int len);
331extern int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, 330extern int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
332 struct tcphdr *th, unsigned len); 331 const struct tcphdr *th, unsigned int len);
333extern void tcp_rcv_space_adjust(struct sock *sk); 332extern void tcp_rcv_space_adjust(struct sock *sk);
334extern void tcp_cleanup_rbuf(struct sock *sk, int copied); 333extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
335extern int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp); 334extern int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp);
@@ -356,6 +355,7 @@ static inline void tcp_dec_quickack_mode(struct sock *sk,
356#define TCP_ECN_OK 1 355#define TCP_ECN_OK 1
357#define TCP_ECN_QUEUE_CWR 2 356#define TCP_ECN_QUEUE_CWR 2
358#define TCP_ECN_DEMAND_CWR 4 357#define TCP_ECN_DEMAND_CWR 4
358#define TCP_ECN_SEEN 8
359 359
360static __inline__ void 360static __inline__ void
361TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) 361TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
@@ -400,10 +400,10 @@ extern void tcp_set_keepalive(struct sock *sk, int val);
400extern void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req); 400extern void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req);
401extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 401extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
402 size_t len, int nonblock, int flags, int *addr_len); 402 size_t len, int nonblock, int flags, int *addr_len);
403extern void tcp_parse_options(struct sk_buff *skb, 403extern void tcp_parse_options(const struct sk_buff *skb,
404 struct tcp_options_received *opt_rx, u8 **hvpp, 404 struct tcp_options_received *opt_rx, const u8 **hvpp,
405 int estab); 405 int estab);
406extern u8 *tcp_parse_md5sig_option(struct tcphdr *th); 406extern const u8 *tcp_parse_md5sig_option(const struct tcphdr *th);
407 407
408/* 408/*
409 * TCP v4 functions exported for the inet6 API 409 * TCP v4 functions exported for the inet6 API
@@ -449,7 +449,7 @@ extern bool cookie_check_timestamp(struct tcp_options_received *opt, bool *);
449/* From net/ipv6/syncookies.c */ 449/* From net/ipv6/syncookies.c */
450extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb); 450extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
451#ifdef CONFIG_SYN_COOKIES 451#ifdef CONFIG_SYN_COOKIES
452extern __u32 cookie_v6_init_sequence(struct sock *sk, struct sk_buff *skb, 452extern __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb,
453 __u16 *mss); 453 __u16 *mss);
454#else 454#else
455static inline __u32 cookie_v6_init_sequence(struct sock *sk, 455static inline __u32 cookie_v6_init_sequence(struct sock *sk,
@@ -521,7 +521,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
521} 521}
522 522
523/* tcp.c */ 523/* tcp.c */
524extern void tcp_get_info(struct sock *, struct tcp_info *); 524extern void tcp_get_info(const struct sock *, struct tcp_info *);
525 525
526/* Read 'sendfile()'-style from a TCP socket */ 526/* Read 'sendfile()'-style from a TCP socket */
527typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, 527typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
@@ -531,8 +531,8 @@ extern int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
531 531
532extern void tcp_initialize_rcv_mss(struct sock *sk); 532extern void tcp_initialize_rcv_mss(struct sock *sk);
533 533
534extern int tcp_mtu_to_mss(struct sock *sk, int pmtu); 534extern int tcp_mtu_to_mss(const struct sock *sk, int pmtu);
535extern int tcp_mss_to_mtu(struct sock *sk, int mss); 535extern int tcp_mss_to_mtu(const struct sock *sk, int mss);
536extern void tcp_mtup_init(struct sock *sk); 536extern void tcp_mtup_init(struct sock *sk);
537extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt); 537extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt);
538 538
@@ -573,7 +573,7 @@ static inline void tcp_fast_path_check(struct sock *sk)
573/* Compute the actual rto_min value */ 573/* Compute the actual rto_min value */
574static inline u32 tcp_rto_min(struct sock *sk) 574static inline u32 tcp_rto_min(struct sock *sk)
575{ 575{
576 struct dst_entry *dst = __sk_dst_get(sk); 576 const struct dst_entry *dst = __sk_dst_get(sk);
577 u32 rto_min = TCP_RTO_MIN; 577 u32 rto_min = TCP_RTO_MIN;
578 578
579 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) 579 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN))
@@ -635,13 +635,14 @@ struct tcp_skb_cb {
635 __u32 seq; /* Starting sequence number */ 635 __u32 seq; /* Starting sequence number */
636 __u32 end_seq; /* SEQ + FIN + SYN + datalen */ 636 __u32 end_seq; /* SEQ + FIN + SYN + datalen */
637 __u32 when; /* used to compute rtt's */ 637 __u32 when; /* used to compute rtt's */
638 __u8 flags; /* TCP header flags. */ 638 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
639 __u8 sacked; /* State flags for SACK/FACK. */ 639 __u8 sacked; /* State flags for SACK/FACK. */
640#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */ 640#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */
641#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */ 641#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */
642#define TCPCB_LOST 0x04 /* SKB is lost */ 642#define TCPCB_LOST 0x04 /* SKB is lost */
643#define TCPCB_TAGBITS 0x07 /* All tag bits */ 643#define TCPCB_TAGBITS 0x07 /* All tag bits */
644 644 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
645 /* 1 byte hole */
645#define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ 646#define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */
646#define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) 647#define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS)
647 648
@@ -818,6 +819,7 @@ static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)
818static inline __u32 tcp_current_ssthresh(const struct sock *sk) 819static inline __u32 tcp_current_ssthresh(const struct sock *sk)
819{ 820{
820 const struct tcp_sock *tp = tcp_sk(sk); 821 const struct tcp_sock *tp = tcp_sk(sk);
822
821 if ((1 << inet_csk(sk)->icsk_ca_state) & (TCPF_CA_CWR | TCPF_CA_Recovery)) 823 if ((1 << inet_csk(sk)->icsk_ca_state) & (TCPF_CA_CWR | TCPF_CA_Recovery))
822 return tp->snd_ssthresh; 824 return tp->snd_ssthresh;
823 else 825 else
@@ -830,7 +832,7 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk)
830#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out) 832#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out)
831 833
832extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); 834extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh);
833extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); 835extern __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst);
834 836
835/* Slow start with delack produces 3 packets of burst, so that 837/* Slow start with delack produces 3 packets of burst, so that
836 * it is safe "de facto". This will be the default - same as 838 * it is safe "de facto". This will be the default - same as
@@ -859,7 +861,7 @@ static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss,
859 861
860static inline void tcp_check_probe_timer(struct sock *sk) 862static inline void tcp_check_probe_timer(struct sock *sk)
861{ 863{
862 struct tcp_sock *tp = tcp_sk(sk); 864 const struct tcp_sock *tp = tcp_sk(sk);
863 const struct inet_connection_sock *icsk = inet_csk(sk); 865 const struct inet_connection_sock *icsk = inet_csk(sk);
864 866
865 if (!tp->packets_out && !icsk->icsk_pending) 867 if (!tp->packets_out && !icsk->icsk_pending)
@@ -1182,8 +1184,9 @@ struct tcp_md5sig_pool {
1182 1184
1183/* - functions */ 1185/* - functions */
1184extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 1186extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1185 struct sock *sk, struct request_sock *req, 1187 const struct sock *sk,
1186 struct sk_buff *skb); 1188 const struct request_sock *req,
1189 const struct sk_buff *skb);
1187extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk, 1190extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk,
1188 struct sock *addr_sk); 1191 struct sock *addr_sk);
1189extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, 1192extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey,
@@ -1200,17 +1203,17 @@ extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr);
1200#define tcp_twsk_md5_key(twsk) NULL 1203#define tcp_twsk_md5_key(twsk) NULL
1201#endif 1204#endif
1202 1205
1203extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *); 1206extern struct tcp_md5sig_pool __percpu *tcp_alloc_md5sig_pool(struct sock *);
1204extern void tcp_free_md5sig_pool(void); 1207extern void tcp_free_md5sig_pool(void);
1205 1208
1206extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void); 1209extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void);
1207extern void tcp_put_md5sig_pool(void); 1210extern void tcp_put_md5sig_pool(void);
1208 1211
1209extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, struct tcphdr *); 1212extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, const struct tcphdr *);
1210extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, struct sk_buff *, 1213extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, const struct sk_buff *,
1211 unsigned header_len); 1214 unsigned header_len);
1212extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, 1215extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp,
1213 struct tcp_md5sig_key *key); 1216 const struct tcp_md5sig_key *key);
1214 1217
1215/* write queue abstraction */ 1218/* write queue abstraction */
1216static inline void tcp_write_queue_purge(struct sock *sk) 1219static inline void tcp_write_queue_purge(struct sock *sk)
@@ -1223,22 +1226,24 @@ static inline void tcp_write_queue_purge(struct sock *sk)
1223 tcp_clear_all_retrans_hints(tcp_sk(sk)); 1226 tcp_clear_all_retrans_hints(tcp_sk(sk));
1224} 1227}
1225 1228
1226static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) 1229static inline struct sk_buff *tcp_write_queue_head(const struct sock *sk)
1227{ 1230{
1228 return skb_peek(&sk->sk_write_queue); 1231 return skb_peek(&sk->sk_write_queue);
1229} 1232}
1230 1233
1231static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk) 1234static inline struct sk_buff *tcp_write_queue_tail(const struct sock *sk)
1232{ 1235{
1233 return skb_peek_tail(&sk->sk_write_queue); 1236 return skb_peek_tail(&sk->sk_write_queue);
1234} 1237}
1235 1238
1236static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb) 1239static inline struct sk_buff *tcp_write_queue_next(const struct sock *sk,
1240 const struct sk_buff *skb)
1237{ 1241{
1238 return skb_queue_next(&sk->sk_write_queue, skb); 1242 return skb_queue_next(&sk->sk_write_queue, skb);
1239} 1243}
1240 1244
1241static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_buff *skb) 1245static inline struct sk_buff *tcp_write_queue_prev(const struct sock *sk,
1246 const struct sk_buff *skb)
1242{ 1247{
1243 return skb_queue_prev(&sk->sk_write_queue, skb); 1248 return skb_queue_prev(&sk->sk_write_queue, skb);
1244} 1249}
@@ -1252,7 +1257,7 @@ static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_bu
1252#define tcp_for_write_queue_from_safe(skb, tmp, sk) \ 1257#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
1253 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) 1258 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp)
1254 1259
1255static inline struct sk_buff *tcp_send_head(struct sock *sk) 1260static inline struct sk_buff *tcp_send_head(const struct sock *sk)
1256{ 1261{
1257 return sk->sk_send_head; 1262 return sk->sk_send_head;
1258} 1263}
@@ -1263,7 +1268,7 @@ static inline bool tcp_skb_is_last(const struct sock *sk,
1263 return skb_queue_is_last(&sk->sk_write_queue, skb); 1268 return skb_queue_is_last(&sk->sk_write_queue, skb);
1264} 1269}
1265 1270
1266static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) 1271static inline void tcp_advance_send_head(struct sock *sk, const struct sk_buff *skb)
1267{ 1272{
1268 if (tcp_skb_is_last(sk, skb)) 1273 if (tcp_skb_is_last(sk, skb))
1269 sk->sk_send_head = NULL; 1274 sk->sk_send_head = NULL;
@@ -1443,9 +1448,9 @@ struct tcp_sock_af_ops {
1443 struct sock *addr_sk); 1448 struct sock *addr_sk);
1444 int (*calc_md5_hash) (char *location, 1449 int (*calc_md5_hash) (char *location,
1445 struct tcp_md5sig_key *md5, 1450 struct tcp_md5sig_key *md5,
1446 struct sock *sk, 1451 const struct sock *sk,
1447 struct request_sock *req, 1452 const struct request_sock *req,
1448 struct sk_buff *skb); 1453 const struct sk_buff *skb);
1449 int (*md5_add) (struct sock *sk, 1454 int (*md5_add) (struct sock *sk,
1450 struct sock *addr_sk, 1455 struct sock *addr_sk,
1451 u8 *newkey, 1456 u8 *newkey,
@@ -1462,9 +1467,9 @@ struct tcp_request_sock_ops {
1462 struct request_sock *req); 1467 struct request_sock *req);
1463 int (*calc_md5_hash) (char *location, 1468 int (*calc_md5_hash) (char *location,
1464 struct tcp_md5sig_key *md5, 1469 struct tcp_md5sig_key *md5,
1465 struct sock *sk, 1470 const struct sock *sk,
1466 struct request_sock *req, 1471 const struct request_sock *req,
1467 struct sk_buff *skb); 1472 const struct sk_buff *skb);
1468#endif 1473#endif
1469}; 1474};
1470 1475