aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tcp.h')
-rw-r--r--include/linux/tcp.h79
1 files changed, 68 insertions, 11 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 61723a7c21fe..a778ee024590 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -81,6 +81,12 @@ enum {
81 TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000) 81 TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000)
82}; 82};
83 83
84/*
85 * TCP general constants
86 */
87#define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */
88#define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */
89
84/* TCP socket options */ 90/* TCP socket options */
85#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */ 91#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */
86#define TCP_MAXSEG 2 /* Limit MSS */ 92#define TCP_MAXSEG 2 /* Limit MSS */
@@ -96,14 +102,17 @@ enum {
96#define TCP_QUICKACK 12 /* Block/reenable quick acks */ 102#define TCP_QUICKACK 12 /* Block/reenable quick acks */
97#define TCP_CONGESTION 13 /* Congestion control algorithm */ 103#define TCP_CONGESTION 13 /* Congestion control algorithm */
98#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ 104#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
105#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */
106#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/
107#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */
99 108
109/* for TCP_INFO socket option */
100#define TCPI_OPT_TIMESTAMPS 1 110#define TCPI_OPT_TIMESTAMPS 1
101#define TCPI_OPT_SACK 2 111#define TCPI_OPT_SACK 2
102#define TCPI_OPT_WSCALE 4 112#define TCPI_OPT_WSCALE 4
103#define TCPI_OPT_ECN 8 113#define TCPI_OPT_ECN 8
104 114
105enum tcp_ca_state 115enum tcp_ca_state {
106{
107 TCP_CA_Open = 0, 116 TCP_CA_Open = 0,
108#define TCPF_CA_Open (1<<TCP_CA_Open) 117#define TCPF_CA_Open (1<<TCP_CA_Open)
109 TCP_CA_Disorder = 1, 118 TCP_CA_Disorder = 1,
@@ -116,8 +125,7 @@ enum tcp_ca_state
116#define TCPF_CA_Loss (1<<TCP_CA_Loss) 125#define TCPF_CA_Loss (1<<TCP_CA_Loss)
117}; 126};
118 127
119struct tcp_info 128struct tcp_info {
120{
121 __u8 tcpi_state; 129 __u8 tcpi_state;
122 __u8 tcpi_ca_state; 130 __u8 tcpi_ca_state;
123 __u8 tcpi_retransmits; 131 __u8 tcpi_retransmits;
@@ -170,6 +178,30 @@ struct tcp_md5sig {
170 __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */ 178 __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */
171}; 179};
172 180
181/* for TCP_COOKIE_TRANSACTIONS (TCPCT) socket option */
182#define TCP_COOKIE_MIN 8 /* 64-bits */
183#define TCP_COOKIE_MAX 16 /* 128-bits */
184#define TCP_COOKIE_PAIR_SIZE (2*TCP_COOKIE_MAX)
185
186/* Flags for both getsockopt and setsockopt */
187#define TCP_COOKIE_IN_ALWAYS (1 << 0) /* Discard SYN without cookie */
188#define TCP_COOKIE_OUT_NEVER (1 << 1) /* Prohibit outgoing cookies,
189 * supercedes everything. */
190
191/* Flags for getsockopt */
192#define TCP_S_DATA_IN (1 << 2) /* Was data received? */
193#define TCP_S_DATA_OUT (1 << 3) /* Was data sent? */
194
195/* TCP_COOKIE_TRANSACTIONS data */
196struct tcp_cookie_transactions {
197 __u16 tcpct_flags; /* see above */
198 __u8 __tcpct_pad1; /* zero */
199 __u8 tcpct_cookie_desired; /* bytes */
200 __u16 tcpct_s_data_desired; /* bytes of variable data */
201 __u16 tcpct_used; /* bytes in value */
202 __u8 tcpct_value[TCP_MSS_DEFAULT];
203};
204
173#ifdef __KERNEL__ 205#ifdef __KERNEL__
174 206
175#include <linux/skbuff.h> 207#include <linux/skbuff.h>
@@ -217,26 +249,38 @@ struct tcp_options_received {
217 sack_ok : 4, /* SACK seen on SYN packet */ 249 sack_ok : 4, /* SACK seen on SYN packet */
218 snd_wscale : 4, /* Window scaling received from sender */ 250 snd_wscale : 4, /* Window scaling received from sender */
219 rcv_wscale : 4; /* Window scaling to send to receiver */ 251 rcv_wscale : 4; /* Window scaling to send to receiver */
220/* SACKs data */ 252 u8 cookie_plus:6, /* bytes in authenticator/cookie option */
253 cookie_out_never:1,
254 cookie_in_always:1;
221 u8 num_sacks; /* Number of SACK blocks */ 255 u8 num_sacks; /* Number of SACK blocks */
222 u16 user_mss; /* mss requested by user in ioctl */ 256 u16 user_mss; /* mss requested by user in ioctl */
223 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ 257 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
224}; 258};
225 259
260static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
261{
262 rx_opt->tstamp_ok = rx_opt->sack_ok = 0;
263 rx_opt->wscale_ok = rx_opt->snd_wscale = 0;
264 rx_opt->cookie_plus = 0;
265}
266
226/* This is the max number of SACKS that we'll generate and process. It's safe 267/* This is the max number of SACKS that we'll generate and process. It's safe
227 * to increse this, although since: 268 * to increase this, although since:
228 * size = TCPOLEN_SACK_BASE_ALIGNED (4) + n * TCPOLEN_SACK_PERBLOCK (8) 269 * size = TCPOLEN_SACK_BASE_ALIGNED (4) + n * TCPOLEN_SACK_PERBLOCK (8)
229 * only four options will fit in a standard TCP header */ 270 * only four options will fit in a standard TCP header */
230#define TCP_NUM_SACKS 4 271#define TCP_NUM_SACKS 4
231 272
273struct tcp_cookie_values;
274struct tcp_request_sock_ops;
275
232struct tcp_request_sock { 276struct tcp_request_sock {
233 struct inet_request_sock req; 277 struct inet_request_sock req;
234#ifdef CONFIG_TCP_MD5SIG 278#ifdef CONFIG_TCP_MD5SIG
235 /* Only used by TCP MD5 Signature so far. */ 279 /* Only used by TCP MD5 Signature so far. */
236 const struct tcp_request_sock_ops *af_specific; 280 const struct tcp_request_sock_ops *af_specific;
237#endif 281#endif
238 u32 rcv_isn; 282 u32 rcv_isn;
239 u32 snt_isn; 283 u32 snt_isn;
240}; 284};
241 285
242static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req) 286static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
@@ -298,7 +342,10 @@ struct tcp_sock {
298 u32 frto_highmark; /* snd_nxt when RTO occurred */ 342 u32 frto_highmark; /* snd_nxt when RTO occurred */
299 u16 advmss; /* Advertised MSS */ 343 u16 advmss; /* Advertised MSS */
300 u8 frto_counter; /* Number of new acks after RTO */ 344 u8 frto_counter; /* Number of new acks after RTO */
301 u8 nonagle; /* Disable Nagle algorithm? */ 345 u8 nonagle : 4,/* Disable Nagle algorithm? */
346 thin_lto : 1,/* Use linear timeouts for thin streams */
347 thin_dupack : 1,/* Fast retransmit on first dupack */
348 unused : 2;
302 349
303/* RTT measurement */ 350/* RTT measurement */
304 u32 srtt; /* smoothed round trip time << 3 */ 351 u32 srtt; /* smoothed round trip time << 3 */
@@ -406,6 +453,12 @@ struct tcp_sock {
406/* TCP MD5 Signature Option information */ 453/* TCP MD5 Signature Option information */
407 struct tcp_md5sig_info *md5sig_info; 454 struct tcp_md5sig_info *md5sig_info;
408#endif 455#endif
456
457 /* When the cookie options are generated and exchanged, then this
458 * object holds a reference to them (cookie_values->kref). Also
459 * contains related tcp_cookie_transactions fields.
460 */
461 struct tcp_cookie_values *cookie_values;
409}; 462};
410 463
411static inline struct tcp_sock *tcp_sk(const struct sock *sk) 464static inline struct tcp_sock *tcp_sk(const struct sock *sk)
@@ -424,6 +477,10 @@ struct tcp_timewait_sock {
424 u16 tw_md5_keylen; 477 u16 tw_md5_keylen;
425 u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN]; 478 u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN];
426#endif 479#endif
480 /* Few sockets in timewait have cookies; in that case, then this
481 * object holds a reference to them (tw_cookie_values->kref).
482 */
483 struct tcp_cookie_values *tw_cookie_values;
427}; 484};
428 485
429static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk) 486static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
@@ -431,6 +488,6 @@ static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
431 return (struct tcp_timewait_sock *)sk; 488 return (struct tcp_timewait_sock *)sk;
432} 489}
433 490
434#endif 491#endif /* __KERNEL__ */
435 492
436#endif /* _LINUX_TCP_H */ 493#endif /* _LINUX_TCP_H */