diff options
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 111 |
1 files changed, 99 insertions, 12 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 1827e7f217d1..5740b85bc5a0 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/dmaengine.h> | 30 | #include <linux/dmaengine.h> |
31 | #include <linux/crypto.h> | 31 | #include <linux/crypto.h> |
32 | #include <linux/cryptohash.h> | 32 | #include <linux/cryptohash.h> |
33 | #include <linux/kref.h> | ||
33 | 34 | ||
34 | #include <net/inet_connection_sock.h> | 35 | #include <net/inet_connection_sock.h> |
35 | #include <net/inet_timewait_sock.h> | 36 | #include <net/inet_timewait_sock.h> |
@@ -62,9 +63,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
62 | /* Minimal accepted MSS. It is (60+60+8) - (20+20). */ | 63 | /* Minimal accepted MSS. It is (60+60+8) - (20+20). */ |
63 | #define TCP_MIN_MSS 88U | 64 | #define TCP_MIN_MSS 88U |
64 | 65 | ||
65 | /* Minimal RCV_MSS. */ | ||
66 | #define TCP_MIN_RCVMSS 536U | ||
67 | |||
68 | /* The least MTU to use for probing */ | 66 | /* The least MTU to use for probing */ |
69 | #define TCP_BASE_MSS 512 | 67 | #define TCP_BASE_MSS 512 |
70 | 68 | ||
@@ -167,6 +165,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
167 | #define TCPOPT_SACK 5 /* SACK Block */ | 165 | #define TCPOPT_SACK 5 /* SACK Block */ |
168 | #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ | 166 | #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ |
169 | #define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */ | 167 | #define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */ |
168 | #define TCPOPT_COOKIE 253 /* Cookie extension (experimental) */ | ||
170 | 169 | ||
171 | /* | 170 | /* |
172 | * TCP option lengths | 171 | * TCP option lengths |
@@ -177,6 +176,10 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
177 | #define TCPOLEN_SACK_PERM 2 | 176 | #define TCPOLEN_SACK_PERM 2 |
178 | #define TCPOLEN_TIMESTAMP 10 | 177 | #define TCPOLEN_TIMESTAMP 10 |
179 | #define TCPOLEN_MD5SIG 18 | 178 | #define TCPOLEN_MD5SIG 18 |
179 | #define TCPOLEN_COOKIE_BASE 2 /* Cookie-less header extension */ | ||
180 | #define TCPOLEN_COOKIE_PAIR 3 /* Cookie pair header extension */ | ||
181 | #define TCPOLEN_COOKIE_MIN (TCPOLEN_COOKIE_BASE+TCP_COOKIE_MIN) | ||
182 | #define TCPOLEN_COOKIE_MAX (TCPOLEN_COOKIE_BASE+TCP_COOKIE_MAX) | ||
180 | 183 | ||
181 | /* But this is what stacks really send out. */ | 184 | /* But this is what stacks really send out. */ |
182 | #define TCPOLEN_TSTAMP_ALIGNED 12 | 185 | #define TCPOLEN_TSTAMP_ALIGNED 12 |
@@ -237,6 +240,7 @@ extern int sysctl_tcp_base_mss; | |||
237 | extern int sysctl_tcp_workaround_signed_windows; | 240 | extern int sysctl_tcp_workaround_signed_windows; |
238 | extern int sysctl_tcp_slow_start_after_idle; | 241 | extern int sysctl_tcp_slow_start_after_idle; |
239 | extern int sysctl_tcp_max_ssthresh; | 242 | extern int sysctl_tcp_max_ssthresh; |
243 | extern int sysctl_tcp_cookie_size; | ||
240 | 244 | ||
241 | extern atomic_t tcp_memory_allocated; | 245 | extern atomic_t tcp_memory_allocated; |
242 | extern struct percpu_counter tcp_sockets_allocated; | 246 | extern struct percpu_counter tcp_sockets_allocated; |
@@ -343,11 +347,6 @@ static inline void tcp_dec_quickack_mode(struct sock *sk, | |||
343 | 347 | ||
344 | extern void tcp_enter_quickack_mode(struct sock *sk); | 348 | extern void tcp_enter_quickack_mode(struct sock *sk); |
345 | 349 | ||
346 | static inline void tcp_clear_options(struct tcp_options_received *rx_opt) | ||
347 | { | ||
348 | rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; | ||
349 | } | ||
350 | |||
351 | #define TCP_ECN_OK 1 | 350 | #define TCP_ECN_OK 1 |
352 | #define TCP_ECN_QUEUE_CWR 2 | 351 | #define TCP_ECN_QUEUE_CWR 2 |
353 | #define TCP_ECN_DEMAND_CWR 4 | 352 | #define TCP_ECN_DEMAND_CWR 4 |
@@ -359,8 +358,7 @@ TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) | |||
359 | inet_rsk(req)->ecn_ok = 1; | 358 | inet_rsk(req)->ecn_ok = 1; |
360 | } | 359 | } |
361 | 360 | ||
362 | enum tcp_tw_status | 361 | enum tcp_tw_status { |
363 | { | ||
364 | TCP_TW_SUCCESS = 0, | 362 | TCP_TW_SUCCESS = 0, |
365 | TCP_TW_RST = 1, | 363 | TCP_TW_RST = 1, |
366 | TCP_TW_ACK = 2, | 364 | TCP_TW_ACK = 2, |
@@ -409,7 +407,9 @@ extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
409 | 407 | ||
410 | extern void tcp_parse_options(struct sk_buff *skb, | 408 | extern void tcp_parse_options(struct sk_buff *skb, |
411 | struct tcp_options_received *opt_rx, | 409 | struct tcp_options_received *opt_rx, |
412 | int estab); | 410 | u8 **hvpp, |
411 | int estab, | ||
412 | struct dst_entry *dst); | ||
413 | 413 | ||
414 | extern u8 *tcp_parse_md5sig_option(struct tcphdr *th); | 414 | extern u8 *tcp_parse_md5sig_option(struct tcphdr *th); |
415 | 415 | ||
@@ -443,7 +443,8 @@ extern int tcp_connect(struct sock *sk); | |||
443 | 443 | ||
444 | extern struct sk_buff * tcp_make_synack(struct sock *sk, | 444 | extern struct sk_buff * tcp_make_synack(struct sock *sk, |
445 | struct dst_entry *dst, | 445 | struct dst_entry *dst, |
446 | struct request_sock *req); | 446 | struct request_sock *req, |
447 | struct request_values *rvp); | ||
447 | 448 | ||
448 | extern int tcp_disconnect(struct sock *sk, int flags); | 449 | extern int tcp_disconnect(struct sock *sk, int flags); |
449 | 450 | ||
@@ -1228,6 +1229,7 @@ static inline void tcp_write_queue_purge(struct sock *sk) | |||
1228 | while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) | 1229 | while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) |
1229 | sk_wmem_free_skb(sk, skb); | 1230 | sk_wmem_free_skb(sk, skb); |
1230 | sk_mem_reclaim(sk); | 1231 | sk_mem_reclaim(sk); |
1232 | tcp_clear_all_retrans_hints(tcp_sk(sk)); | ||
1231 | } | 1233 | } |
1232 | 1234 | ||
1233 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) | 1235 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) |
@@ -1480,6 +1482,91 @@ struct tcp_request_sock_ops { | |||
1480 | #endif | 1482 | #endif |
1481 | }; | 1483 | }; |
1482 | 1484 | ||
1485 | /* Using SHA1 for now, define some constants. | ||
1486 | */ | ||
1487 | #define COOKIE_DIGEST_WORDS (SHA_DIGEST_WORDS) | ||
1488 | #define COOKIE_MESSAGE_WORDS (SHA_MESSAGE_BYTES / 4) | ||
1489 | #define COOKIE_WORKSPACE_WORDS (COOKIE_DIGEST_WORDS + COOKIE_MESSAGE_WORDS) | ||
1490 | |||
1491 | extern int tcp_cookie_generator(u32 *bakery); | ||
1492 | |||
1493 | /** | ||
1494 | * struct tcp_cookie_values - each socket needs extra space for the | ||
1495 | * cookies, together with (optional) space for any SYN data. | ||
1496 | * | ||
1497 | * A tcp_sock contains a pointer to the current value, and this is | ||
1498 | * cloned to the tcp_timewait_sock. | ||
1499 | * | ||
1500 | * @cookie_pair: variable data from the option exchange. | ||
1501 | * | ||
1502 | * @cookie_desired: user specified tcpct_cookie_desired. Zero | ||
1503 | * indicates default (sysctl_tcp_cookie_size). | ||
1504 | * After cookie sent, remembers size of cookie. | ||
1505 | * Range 0, TCP_COOKIE_MIN to TCP_COOKIE_MAX. | ||
1506 | * | ||
1507 | * @s_data_desired: user specified tcpct_s_data_desired. When the | ||
1508 | * constant payload is specified (@s_data_constant), | ||
1509 | * holds its length instead. | ||
1510 | * Range 0 to TCP_MSS_DESIRED. | ||
1511 | * | ||
1512 | * @s_data_payload: constant data that is to be included in the | ||
1513 | * payload of SYN or SYNACK segments when the | ||
1514 | * cookie option is present. | ||
1515 | */ | ||
1516 | struct tcp_cookie_values { | ||
1517 | struct kref kref; | ||
1518 | u8 cookie_pair[TCP_COOKIE_PAIR_SIZE]; | ||
1519 | u8 cookie_pair_size; | ||
1520 | u8 cookie_desired; | ||
1521 | u16 s_data_desired:11, | ||
1522 | s_data_constant:1, | ||
1523 | s_data_in:1, | ||
1524 | s_data_out:1, | ||
1525 | s_data_unused:2; | ||
1526 | u8 s_data_payload[0]; | ||
1527 | }; | ||
1528 | |||
1529 | static inline void tcp_cookie_values_release(struct kref *kref) | ||
1530 | { | ||
1531 | kfree(container_of(kref, struct tcp_cookie_values, kref)); | ||
1532 | } | ||
1533 | |||
1534 | /* The length of constant payload data. Note that s_data_desired is | ||
1535 | * overloaded, depending on s_data_constant: either the length of constant | ||
1536 | * data (returned here) or the limit on variable data. | ||
1537 | */ | ||
1538 | static inline int tcp_s_data_size(const struct tcp_sock *tp) | ||
1539 | { | ||
1540 | return (tp->cookie_values != NULL && tp->cookie_values->s_data_constant) | ||
1541 | ? tp->cookie_values->s_data_desired | ||
1542 | : 0; | ||
1543 | } | ||
1544 | |||
1545 | /** | ||
1546 | * struct tcp_extend_values - tcp_ipv?.c to tcp_output.c workspace. | ||
1547 | * | ||
1548 | * As tcp_request_sock has already been extended in other places, the | ||
1549 | * only remaining method is to pass stack values along as function | ||
1550 | * parameters. These parameters are not needed after sending SYNACK. | ||
1551 | * | ||
1552 | * @cookie_bakery: cryptographic secret and message workspace. | ||
1553 | * | ||
1554 | * @cookie_plus: bytes in authenticator/cookie option, copied from | ||
1555 | * struct tcp_options_received (above). | ||
1556 | */ | ||
1557 | struct tcp_extend_values { | ||
1558 | struct request_values rv; | ||
1559 | u32 cookie_bakery[COOKIE_WORKSPACE_WORDS]; | ||
1560 | u8 cookie_plus:6, | ||
1561 | cookie_out_never:1, | ||
1562 | cookie_in_always:1; | ||
1563 | }; | ||
1564 | |||
1565 | static inline struct tcp_extend_values *tcp_xv(struct request_values *rvp) | ||
1566 | { | ||
1567 | return (struct tcp_extend_values *)rvp; | ||
1568 | } | ||
1569 | |||
1483 | extern void tcp_v4_init(void); | 1570 | extern void tcp_v4_init(void); |
1484 | extern void tcp_init(void); | 1571 | extern void tcp_init(void); |
1485 | 1572 | ||