2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* INET An implementation of the TCP/IP protocol suite for the LINUX
|
|
|
|
* operating system. INET is implemented using the BSD Socket
|
|
|
|
* interface as the means of communication with the user level.
|
|
|
|
*
|
|
|
|
* Definitions for the TCP protocol.
|
|
|
|
*
|
|
|
|
* Version: @(#)tcp.h 1.0.2 04/28/93
|
|
|
|
*
|
|
|
|
* Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_TCP_H
|
|
|
|
#define _LINUX_TCP_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/skbuff.h>
|
2016-09-20 11:39:10 +08:00
|
|
|
#include <linux/win_minmax.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <net/sock.h>
|
2005-08-10 11:10:42 +08:00
|
|
|
#include <net/inet_connection_sock.h>
|
2005-08-10 11:09:30 +08:00
|
|
|
#include <net/inet_timewait_sock.h>
|
2012-10-13 17:46:48 +08:00
|
|
|
#include <uapi/linux/tcp.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-04-11 12:04:22 +08:00
|
|
|
static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
|
|
|
|
{
|
2007-04-26 09:04:18 +08:00
|
|
|
return (struct tcphdr *)skb_transport_header(skb);
|
2007-04-11 12:04:22 +08:00
|
|
|
}
|
|
|
|
|
2016-02-11 00:50:37 +08:00
|
|
|
static inline unsigned int __tcp_hdrlen(const struct tcphdr *th)
|
|
|
|
{
|
|
|
|
return th->doff * 4;
|
|
|
|
}
|
|
|
|
|
2007-03-19 08:43:48 +08:00
|
|
|
static inline unsigned int tcp_hdrlen(const struct sk_buff *skb)
|
|
|
|
{
|
2016-02-11 00:50:37 +08:00
|
|
|
return __tcp_hdrlen(tcp_hdr(skb));
|
2007-03-19 08:43:48 +08:00
|
|
|
}
|
|
|
|
|
2012-12-07 22:14:14 +08:00
|
|
|
static inline struct tcphdr *inner_tcp_hdr(const struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return (struct tcphdr *)skb_inner_transport_header(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int inner_tcp_hdrlen(const struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return inner_tcp_hdr(skb)->doff * 4;
|
|
|
|
}
|
|
|
|
|
2007-03-19 08:43:48 +08:00
|
|
|
static inline unsigned int tcp_optlen(const struct sk_buff *skb)
|
|
|
|
{
|
2007-04-11 12:04:22 +08:00
|
|
|
return (tcp_hdr(skb)->doff - 5) * 4;
|
2007-03-19 08:43:48 +08:00
|
|
|
}
|
|
|
|
|
2012-07-19 14:43:05 +08:00
|
|
|
/* TCP Fast Open */
|
|
|
|
#define TCP_FASTOPEN_COOKIE_MIN 4 /* Min Fast Open Cookie size in bytes */
|
|
|
|
#define TCP_FASTOPEN_COOKIE_MAX 16 /* Max Fast Open Cookie size in bytes */
|
2012-08-31 20:29:11 +08:00
|
|
|
#define TCP_FASTOPEN_COOKIE_SIZE 8 /* the size employed by this impl. */
|
2012-07-19 14:43:05 +08:00
|
|
|
|
|
|
|
/* TCP Fast Open Cookie as stored in memory */
|
|
|
|
struct tcp_fastopen_cookie {
|
|
|
|
s8 len;
|
|
|
|
u8 val[TCP_FASTOPEN_COOKIE_MAX];
|
2015-04-07 05:37:26 +08:00
|
|
|
bool exp; /* In RFC6994 experimental option format */
|
2012-07-19 14:43:05 +08:00
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* This defines a selective acknowledgement block. */
|
2006-09-28 09:32:28 +08:00
|
|
|
struct tcp_sack_block_wire {
|
|
|
|
__be32 start_seq;
|
|
|
|
__be32 end_seq;
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct tcp_sack_block {
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 start_seq;
|
|
|
|
u32 end_seq;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2011-12-20 21:23:24 +08:00
|
|
|
/*These are used to set the sack_ok field in struct tcp_options_received */
|
|
|
|
#define TCP_SACK_SEEN (1 << 0) /*1 = peer is SACK capable, */
|
|
|
|
#define TCP_FACK_ENABLED (1 << 1) /*1 = FACK is enabled locally*/
|
|
|
|
#define TCP_DSACK_SEEN (1 << 2) /*1 = DSACK was received from peer*/
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct tcp_options_received {
|
|
|
|
/* PAWS/RTTM data */
|
|
|
|
long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 ts_recent; /* Time stamp to echo next */
|
|
|
|
u32 rcv_tsval; /* Time stamp value */
|
|
|
|
u32 rcv_tsecr; /* Time stamp echo reply */
|
|
|
|
u16 saw_tstamp : 1, /* Saw TIMESTAMP on last packet */
|
2005-04-17 06:20:36 +08:00
|
|
|
tstamp_ok : 1, /* TIMESTAMP seen on SYN packet */
|
|
|
|
dsack : 1, /* D-SACK is scheduled */
|
|
|
|
wscale_ok : 1, /* Wscale seen on SYN packet */
|
|
|
|
sack_ok : 4, /* SACK seen on SYN packet */
|
|
|
|
snd_wscale : 4, /* Window scaling received from sender */
|
|
|
|
rcv_wscale : 4; /* Window scaling to send to receiver */
|
2006-11-28 11:12:38 +08:00
|
|
|
u8 num_sacks; /* Number of SACK blocks */
|
TCPCT part 1d: define TCP cookie option, extend existing struct's
Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration). There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.
This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):
http://thread.gmane.org/gmane.linux.network/102586
The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data. This is more flexible and
less subject to user configuration error. Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.
"Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html
"Re: what a new TCP header might look like", May 12, 1998.
ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail
These functions will also be used in subsequent patches that implement
additional features.
Requires:
TCPCT part 1a: add request_values parameter for sending SYNACK
TCPCT part 1b: generate Responder Cookie secret
TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
Signed-off-by: William.Allen.Simpson@gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-03 02:17:05 +08:00
|
|
|
u16 user_mss; /* mss requested by user in ioctl */
|
2006-11-28 11:12:38 +08:00
|
|
|
u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-12-03 02:14:19 +08:00
|
|
|
static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
|
|
|
|
{
|
TCPCT part 1d: define TCP cookie option, extend existing struct's
Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration). There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.
This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):
http://thread.gmane.org/gmane.linux.network/102586
The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data. This is more flexible and
less subject to user configuration error. Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.
"Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html
"Re: what a new TCP header might look like", May 12, 1998.
ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail
These functions will also be used in subsequent patches that implement
additional features.
Requires:
TCPCT part 1a: add request_values parameter for sending SYNACK
TCPCT part 1b: generate Responder Cookie secret
TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
Signed-off-by: William.Allen.Simpson@gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-03 02:17:05 +08:00
|
|
|
rx_opt->tstamp_ok = rx_opt->sack_ok = 0;
|
|
|
|
rx_opt->wscale_ok = rx_opt->snd_wscale = 0;
|
2009-12-03 02:14:19 +08:00
|
|
|
}
|
|
|
|
|
2008-07-19 15:07:02 +08:00
|
|
|
/* This is the max number of SACKS that we'll generate and process. It's safe
|
TCPCT part 1d: define TCP cookie option, extend existing struct's
Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration). There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.
This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):
http://thread.gmane.org/gmane.linux.network/102586
The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data. This is more flexible and
less subject to user configuration error. Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.
"Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html
"Re: what a new TCP header might look like", May 12, 1998.
ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail
These functions will also be used in subsequent patches that implement
additional features.
Requires:
TCPCT part 1a: add request_values parameter for sending SYNACK
TCPCT part 1b: generate Responder Cookie secret
TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
Signed-off-by: William.Allen.Simpson@gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-03 02:17:05 +08:00
|
|
|
* to increase this, although since:
|
2008-07-19 15:07:02 +08:00
|
|
|
* size = TCPOLEN_SACK_BASE_ALIGNED (4) + n * TCPOLEN_SACK_PERBLOCK (8)
|
|
|
|
* only four options will fit in a standard TCP header */
|
|
|
|
#define TCP_NUM_SACKS 4
|
|
|
|
|
TCPCT part 1d: define TCP cookie option, extend existing struct's
Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration). There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.
This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):
http://thread.gmane.org/gmane.linux.network/102586
The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data. This is more flexible and
less subject to user configuration error. Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.
"Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html
"Re: what a new TCP header might look like", May 12, 1998.
ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail
These functions will also be used in subsequent patches that implement
additional features.
Requires:
TCPCT part 1a: add request_values parameter for sending SYNACK
TCPCT part 1b: generate Responder Cookie secret
TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
Signed-off-by: William.Allen.Simpson@gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-03 02:17:05 +08:00
|
|
|
struct tcp_request_sock_ops;
|
|
|
|
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-19 13:46:52 +08:00
|
|
|
struct tcp_request_sock {
|
2006-11-15 11:07:45 +08:00
|
|
|
struct inet_request_sock req;
|
2009-09-02 03:25:03 +08:00
|
|
|
const struct tcp_request_sock_ops *af_specific;
|
2015-09-19 02:36:14 +08:00
|
|
|
struct skb_mstamp snt_synack; /* first SYNACK sent time */
|
2015-03-18 09:32:29 +08:00
|
|
|
bool tfo_listener;
|
2015-09-16 06:24:20 +08:00
|
|
|
u32 txhash;
|
TCPCT part 1d: define TCP cookie option, extend existing struct's
Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration). There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.
This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):
http://thread.gmane.org/gmane.linux.network/102586
The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data. This is more flexible and
less subject to user configuration error. Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.
"Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html
"Re: what a new TCP header might look like", May 12, 1998.
ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail
These functions will also be used in subsequent patches that implement
additional features.
Requires:
TCPCT part 1a: add request_values parameter for sending SYNACK
TCPCT part 1b: generate Responder Cookie secret
TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
Signed-off-by: William.Allen.Simpson@gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-03 02:17:05 +08:00
|
|
|
u32 rcv_isn;
|
|
|
|
u32 snt_isn;
|
2016-12-01 18:32:06 +08:00
|
|
|
u32 ts_off;
|
tcp: mitigate ACK loops for connections as tcp_request_sock
In the SYN_RECV state, where the TCP connection is represented by
tcp_request_sock, we now rate-limit SYNACKs in response to a client's
retransmitted SYNs: we do not send a SYNACK in response to client SYN
if it has been less than sysctl_tcp_invalid_ratelimit (default 500ms)
since we last sent a SYNACK in response to a client's retransmitted
SYN.
This allows the vast majority of legitimate client connections to
proceed unimpeded, even for the most aggressive platforms, iOS and
MacOS, which actually retransmit SYNs 1-second intervals for several
times in a row. They use SYN RTO timeouts following the progression:
1,1,1,1,1,2,4,8,16,32.
Reported-by: Avery Fay <avery@mixpanel.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-02-07 05:04:39 +08:00
|
|
|
u32 last_oow_ack_time; /* last SYNACK */
|
2012-08-31 20:29:11 +08:00
|
|
|
u32 rcv_nxt; /* the ack # by SYNACK. For
|
|
|
|
* FastOpen it's the seq#
|
|
|
|
* after data-in-SYN.
|
|
|
|
*/
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-19 13:46:52 +08:00
|
|
|
};
|
|
|
|
|
2005-06-19 13:47:21 +08:00
|
|
|
static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-19 13:46:52 +08:00
|
|
|
{
|
|
|
|
return (struct tcp_request_sock *)req;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct tcp_sock {
|
2005-08-10 11:10:42 +08:00
|
|
|
/* inet_connection_sock has to be the first member of tcp_sock */
|
|
|
|
struct inet_connection_sock inet_conn;
|
2006-11-28 10:48:32 +08:00
|
|
|
u16 tcp_header_len; /* Bytes of tcp header to send */
|
tcp: refine TSO autosizing
Commit 95bd09eb2750 ("tcp: TSO packets automatic sizing") tried to
control TSO size, but did this at the wrong place (sendmsg() time)
At sendmsg() time, we might have a pessimistic view of flow rate,
and we end up building very small skbs (with 2 MSS per skb).
This is bad because :
- It sends small TSO packets even in Slow Start where rate quickly
increases.
- It tends to make socket write queue very big, increasing tcp_ack()
processing time, but also increasing memory needs, not necessarily
accounted for, as fast clones overhead is currently ignored.
- Lower GRO efficiency and more ACK packets.
Servers with a lot of small lived connections suffer from this.
Lets instead fill skbs as much as possible (64KB of payload), but split
them at xmit time, when we have a precise idea of the flow rate.
skb split is actually quite efficient.
Patch looks bigger than necessary, because TCP Small Queue decision now
has to take place after the eventual split.
As Neal suggested, introduce a new tcp_tso_autosize() helper, so that
tcp_tso_should_defer() can be synchronized on same goal.
Rename tp->xmit_size_goal_segs to tp->gso_segs, as this variable
contains number of mss that we can put in GSO packet, and is not
related to the autosizing goal anymore.
Tested:
40 ms rtt link
nstat >/dev/null
netperf -H remote -l -2000000 -- -s 1000000
nstat | egrep "IpInReceives|IpOutRequests|TcpOutSegs|IpExtOutOctets"
Before patch :
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/s
87380 2000000 2000000 0.36 44.22
IpInReceives 600 0.0
IpOutRequests 599 0.0
TcpOutSegs 1397 0.0
IpExtOutOctets 2033249 0.0
After patch :
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 2000000 2000000 0.36 44.27
IpInReceives 221 0.0
IpOutRequests 232 0.0
TcpOutSegs 1397 0.0
IpExtOutOctets 2013953 0.0
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-12-08 04:22:18 +08:00
|
|
|
u16 gso_segs; /* Max number of segs per GSO packet */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Header prediction flags
|
|
|
|
* 0x5?10 << 16 + snd_wnd in net byte order
|
|
|
|
*/
|
2006-09-28 09:32:46 +08:00
|
|
|
__be32 pred_flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RFC793 variables by their proper names. This means you can
|
|
|
|
* read the code and the spec side by side (and laugh ...)
|
|
|
|
* See RFC793 and RFC1122. The RFC writes these in capitals.
|
|
|
|
*/
|
2015-04-29 06:28:18 +08:00
|
|
|
u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
|
|
|
|
* sum(delta(rcv_nxt)), or how many bytes
|
|
|
|
* were acked.
|
|
|
|
*/
|
2015-05-21 07:35:41 +08:00
|
|
|
u32 segs_in; /* RFC4898 tcpEStatsPerfSegsIn
|
|
|
|
* total number of segments in.
|
|
|
|
*/
|
2016-03-15 01:52:15 +08:00
|
|
|
u32 data_segs_in; /* RFC4898 tcpEStatsPerfDataSegsIn
|
|
|
|
* total number of data segments in.
|
|
|
|
*/
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 rcv_nxt; /* What we want to receive next */
|
2007-02-22 19:20:44 +08:00
|
|
|
u32 copied_seq; /* Head of yet unread data */
|
|
|
|
u32 rcv_wup; /* rcv_nxt on last window update sent */
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 snd_nxt; /* Next sequence we send */
|
2015-05-21 07:35:41 +08:00
|
|
|
u32 segs_out; /* RFC4898 tcpEStatsPerfSegsOut
|
|
|
|
* The total number of segments sent.
|
|
|
|
*/
|
2016-03-15 01:52:15 +08:00
|
|
|
u32 data_segs_out; /* RFC4898 tcpEStatsPerfDataSegsOut
|
|
|
|
* total number of data segments sent.
|
|
|
|
*/
|
2015-04-29 06:28:17 +08:00
|
|
|
u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
|
|
|
|
* sum(delta(snd_una)), or how many bytes
|
|
|
|
* were acked.
|
|
|
|
*/
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 snd_una; /* First byte we want an ack for */
|
|
|
|
u32 snd_sml; /* Last byte of the most recently transmitted small packet */
|
|
|
|
u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
|
|
|
|
u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
|
2015-02-07 05:04:40 +08:00
|
|
|
u32 last_oow_ack_time; /* timestamp of last out-of-window ACK */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-02-11 13:50:17 +08:00
|
|
|
u32 tsoffset; /* timestamp offset */
|
|
|
|
|
tcp: TCP Small Queues
This introduce TSQ (TCP Small Queues)
TSQ goal is to reduce number of TCP packets in xmit queues (qdisc &
device queues), to reduce RTT and cwnd bias, part of the bufferbloat
problem.
sk->sk_wmem_alloc not allowed to grow above a given limit,
allowing no more than ~128KB [1] per tcp socket in qdisc/dev layers at a
given time.
TSO packets are sized/capped to half the limit, so that we have two
TSO packets in flight, allowing better bandwidth use.
As a side effect, setting the limit to 40000 automatically reduces the
standard gso max limit (65536) to 40000/2 : It can help to reduce
latencies of high prio packets, having smaller TSO packets.
This means we divert sock_wfree() to a tcp_wfree() handler, to
queue/send following frames when skb_orphan() [2] is called for the
already queued skbs.
Results on my dev machines (tg3/ixgbe nics) are really impressive,
using standard pfifo_fast, and with or without TSO/GSO.
Without reduction of nominal bandwidth, we have reduction of buffering
per bulk sender :
< 1ms on Gbit (instead of 50ms with TSO)
< 8ms on 100Mbit (instead of 132 ms)
I no longer have 4 MBytes backlogged in qdisc by a single netperf
session, and both side socket autotuning no longer use 4 Mbytes.
As skb destructor cannot restart xmit itself ( as qdisc lock might be
taken at this point ), we delegate the work to a tasklet. We use one
tasklest per cpu for performance reasons.
If tasklet finds a socket owned by the user, it sets TSQ_OWNED flag.
This flag is tested in a new protocol method called from release_sock(),
to eventually send new segments.
[1] New /proc/sys/net/ipv4/tcp_limit_output_bytes tunable
[2] skb_orphan() is usually called at TX completion time,
but some drivers call it in their start_xmit() handler.
These drivers should at least use BQL, or else a single TCP
session can still fill the whole NIC TX ring, since TSQ will
have no effect.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Dave Taht <dave.taht@bufferbloat.net>
Cc: Tom Herbert <therbert@google.com>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Nandita Dukkipati <nanditad@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-07-11 13:50:31 +08:00
|
|
|
struct list_head tsq_node; /* anchor in tsq_tasklet.head list */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Data for direct copy to user */
|
|
|
|
struct {
|
|
|
|
struct sk_buff_head prequeue;
|
|
|
|
struct task_struct *task;
|
2014-11-25 02:26:06 +08:00
|
|
|
struct msghdr *msg;
|
2005-04-17 06:20:36 +08:00
|
|
|
int memory;
|
|
|
|
int len;
|
|
|
|
} ucopy;
|
|
|
|
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 snd_wl1; /* Sequence for window update */
|
|
|
|
u32 snd_wnd; /* The window we expect to receive */
|
|
|
|
u32 max_window; /* Maximal window ever seen from peer */
|
|
|
|
u32 mss_cache; /* Cached effective mss, not including SACKS */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 window_clamp; /* Maximal window to advertise */
|
|
|
|
u32 rcv_ssthresh; /* Current window clamp */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-10-17 12:57:46 +08:00
|
|
|
/* Information of the most recently (s)acked skb */
|
|
|
|
struct tcp_rack {
|
|
|
|
struct skb_mstamp mstamp; /* (Re)sent time of the skb */
|
|
|
|
u8 advanced; /* mstamp advanced since last lost marking */
|
|
|
|
u8 reord; /* reordering detected */
|
|
|
|
} rack;
|
tcp: Reorganize tcp_sock to fill 64-bit holes & improve locality
I tried to group recovery related fields nearby (non-CA_Open related
variables, to be more accurate) so that one to three cachelines would
not be necessary in CA_Open. These are now contiguously deployed:
struct sk_buff_head out_of_order_queue; /* 1968 80 */
/* --- cacheline 32 boundary (2048 bytes) --- */
struct tcp_sack_block duplicate_sack[1]; /* 2048 8 */
struct tcp_sack_block selective_acks[4]; /* 2056 32 */
struct tcp_sack_block recv_sack_cache[4]; /* 2088 32 */
/* --- cacheline 33 boundary (2112 bytes) was 8 bytes ago --- */
struct sk_buff * highest_sack; /* 2120 8 */
int lost_cnt_hint; /* 2128 4 */
int retransmit_cnt_hint; /* 2132 4 */
u32 lost_retrans_low; /* 2136 4 */
u8 reordering; /* 2140 1 */
u8 keepalive_probes; /* 2141 1 */
/* XXX 2 bytes hole, try to pack */
u32 prior_ssthresh; /* 2144 4 */
u32 high_seq; /* 2148 4 */
u32 retrans_stamp; /* 2152 4 */
u32 undo_marker; /* 2156 4 */
int undo_retrans; /* 2160 4 */
u32 total_retrans; /* 2164 4 */
...and they're then followed by URG slowpath & keepalive related
variables.
Head of the out_of_order_queue always needed for empty checks, if
that's empty (and TCP is in CA_Open), following ~200 bytes (in 64-bit)
shouldn't be necessary for anything. If only OFO queue exists but TCP
is in CA_Open, selective_acks (and possibly duplicate_sack) are
necessary besides the out_of_order_queue but the rest of the block
again shouldn't be (ie., the other direction had losses).
As the cacheline boundaries depend on many factors in the preceeding
stuff, trying to align considering them doesn't make too much sense.
Commented one ordering hazard.
There are number of low utilized u8/16s that could be combined get 2
bytes less in total so that the hole could be made to vanish (includes
at least ecn_flags, urg_data, urg_mode, frto_counter, nonagle).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-29 18:25:23 +08:00
|
|
|
u16 advmss; /* Advertised MSS */
|
2016-11-28 15:07:13 +08:00
|
|
|
u32 chrono_start; /* Start time in jiffies of a TCP chrono */
|
|
|
|
u32 chrono_stat[3]; /* Time in jiffies for chrono_stat stats */
|
|
|
|
u8 chrono_type:2, /* current chronograph type */
|
|
|
|
rate_app_limited:1, /* rate_{delivered,interval_us} limited? */
|
|
|
|
unused:5;
|
2010-02-18 10:47:01 +08:00
|
|
|
u8 nonagle : 4,/* Disable Nagle algorithm? */
|
|
|
|
thin_lto : 1,/* Use linear timeouts for thin streams */
|
2010-02-18 12:48:19 +08:00
|
|
|
thin_dupack : 1,/* Fast retransmit on first dupack */
|
2013-03-20 21:33:00 +08:00
|
|
|
repair : 1,
|
|
|
|
frto : 1;/* F-RTO (RFC5682) activated in CA_Loss */
|
2012-04-19 11:40:39 +08:00
|
|
|
u8 repair_queue;
|
2012-05-02 21:30:04 +08:00
|
|
|
u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */
|
2012-07-19 14:43:11 +08:00
|
|
|
syn_data:1, /* SYN includes data */
|
2012-10-19 23:14:44 +08:00
|
|
|
syn_fastopen:1, /* SYN includes Fast Open option */
|
2015-04-07 05:37:27 +08:00
|
|
|
syn_fastopen_exp:1,/* SYN includes Fast Open exp. option */
|
2014-05-22 22:41:08 +08:00
|
|
|
syn_data_acked:1,/* data in SYN is acked by SYN-ACK */
|
2015-05-04 12:34:46 +08:00
|
|
|
save_syn:1, /* Save headers of SYN packet */
|
2014-05-22 22:41:08 +08:00
|
|
|
is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */
|
2013-03-11 18:00:44 +08:00
|
|
|
u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* RTT measurement */
|
2014-02-27 06:02:48 +08:00
|
|
|
u32 srtt_us; /* smoothed round trip time << 3 in usecs */
|
|
|
|
u32 mdev_us; /* medium deviation */
|
|
|
|
u32 mdev_max_us; /* maximal mdev for the last rtt period */
|
|
|
|
u32 rttvar_us; /* smoothed mdev_max */
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 rtt_seq; /* sequence number to update rttvar */
|
2016-09-20 11:39:10 +08:00
|
|
|
struct minmax rtt_min;
|
2006-11-28 11:12:38 +08:00
|
|
|
|
|
|
|
u32 packets_out; /* Packets which are "in flight" */
|
|
|
|
u32 retrans_out; /* Retransmitted packets out */
|
2014-05-22 22:41:08 +08:00
|
|
|
u32 max_packets_out; /* max packets_out in last window */
|
|
|
|
u32 max_packets_seq; /* right edge of max_packets_out flight */
|
tcp: Reorganize tcp_sock to fill 64-bit holes & improve locality
I tried to group recovery related fields nearby (non-CA_Open related
variables, to be more accurate) so that one to three cachelines would
not be necessary in CA_Open. These are now contiguously deployed:
struct sk_buff_head out_of_order_queue; /* 1968 80 */
/* --- cacheline 32 boundary (2048 bytes) --- */
struct tcp_sack_block duplicate_sack[1]; /* 2048 8 */
struct tcp_sack_block selective_acks[4]; /* 2056 32 */
struct tcp_sack_block recv_sack_cache[4]; /* 2088 32 */
/* --- cacheline 33 boundary (2112 bytes) was 8 bytes ago --- */
struct sk_buff * highest_sack; /* 2120 8 */
int lost_cnt_hint; /* 2128 4 */
int retransmit_cnt_hint; /* 2132 4 */
u32 lost_retrans_low; /* 2136 4 */
u8 reordering; /* 2140 1 */
u8 keepalive_probes; /* 2141 1 */
/* XXX 2 bytes hole, try to pack */
u32 prior_ssthresh; /* 2144 4 */
u32 high_seq; /* 2148 4 */
u32 retrans_stamp; /* 2152 4 */
u32 undo_marker; /* 2156 4 */
int undo_retrans; /* 2160 4 */
u32 total_retrans; /* 2164 4 */
...and they're then followed by URG slowpath & keepalive related
variables.
Head of the out_of_order_queue always needed for empty checks, if
that's empty (and TCP is in CA_Open), following ~200 bytes (in 64-bit)
shouldn't be necessary for anything. If only OFO queue exists but TCP
is in CA_Open, selective_acks (and possibly duplicate_sack) are
necessary besides the out_of_order_queue but the rest of the block
again shouldn't be (ie., the other direction had losses).
As the cacheline boundaries depend on many factors in the preceeding
stuff, trying to align considering them doesn't make too much sense.
Commented one ordering hazard.
There are number of low utilized u8/16s that could be combined get 2
bytes less in total so that the hole could be made to vanish (includes
at least ecn_flags, urg_data, urg_mode, frto_counter, nonagle).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-29 18:25:23 +08:00
|
|
|
|
|
|
|
u16 urg_data; /* Saved octet of OOB data and control flags */
|
|
|
|
u8 ecn_flags; /* ECN status bits. */
|
2014-10-28 12:45:24 +08:00
|
|
|
u8 keepalive_probes; /* num of allowed keep alive probes */
|
|
|
|
u32 reordering; /* Packet reordering metric. */
|
2008-10-08 05:43:06 +08:00
|
|
|
u32 snd_up; /* Urgent pointer */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Options received (usually on last packet, some only on SYN packets).
|
|
|
|
*/
|
|
|
|
struct tcp_options_received rx_opt;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Slow start and congestion control (see also Nagle, and Karn & Partridge)
|
|
|
|
*/
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 snd_ssthresh; /* Slow start size threshold */
|
|
|
|
u32 snd_cwnd; /* Sending congestion window */
|
2007-10-16 03:59:43 +08:00
|
|
|
u32 snd_cwnd_cnt; /* Linear increase counter */
|
2007-02-23 14:52:59 +08:00
|
|
|
u32 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 snd_cwnd_used;
|
|
|
|
u32 snd_cwnd_stamp;
|
2011-08-22 04:21:57 +08:00
|
|
|
u32 prior_cwnd; /* Congestion window at start of Recovery. */
|
|
|
|
u32 prr_delivered; /* Number of newly delivered packets to
|
|
|
|
* receiver in Recovery. */
|
|
|
|
u32 prr_out; /* Total number of pkts sent during Recovery. */
|
2016-02-03 02:33:06 +08:00
|
|
|
u32 delivered; /* Total data packets delivered incl. rexmits */
|
2016-09-20 11:39:13 +08:00
|
|
|
u32 lost; /* Total data packets lost incl. rexmits */
|
2016-09-20 11:39:15 +08:00
|
|
|
u32 app_limited; /* limited until "delivered" reaches this val */
|
tcp: track data delivery rate for a TCP connection
This patch generates data delivery rate (throughput) samples on a
per-ACK basis. These rate samples can be used by congestion control
modules, and specifically will be used by TCP BBR in later patches in
this series.
Key state:
tp->delivered: Tracks the total number of data packets (original or not)
delivered so far. This is an already-existing field.
tp->delivered_mstamp: the last time tp->delivered was updated.
Algorithm:
A rate sample is calculated as (d1 - d0)/(t1 - t0) on a per-ACK basis:
d1: the current tp->delivered after processing the ACK
t1: the current time after processing the ACK
d0: the prior tp->delivered when the acked skb was transmitted
t0: the prior tp->delivered_mstamp when the acked skb was transmitted
When an skb is transmitted, we snapshot d0 and t0 in its control
block in tcp_rate_skb_sent().
When an ACK arrives, it may SACK and ACK some skbs. For each SACKed
or ACKed skb, tcp_rate_skb_delivered() updates the rate_sample struct
to reflect the latest (d0, t0).
Finally, tcp_rate_gen() generates a rate sample by storing
(d1 - d0) in rs->delivered and (t1 - t0) in rs->interval_us.
One caveat: if an skb was sent with no packets in flight, then
tp->delivered_mstamp may be either invalid (if the connection is
starting) or outdated (if the connection was idle). In that case,
we'll re-stamp tp->delivered_mstamp.
At first glance it seems t0 should always be the time when an skb was
transmitted, but actually this could over-estimate the rate due to
phase mismatch between transmit and ACK events. To track the delivery
rate, we ensure that if packets are in flight then t0 and and t1 are
times at which packets were marked delivered.
If the initial and final RTTs are different then one may be corrupted
by some sort of noise. The noise we see most often is sending gaps
caused by delayed, compressed, or stretched acks. This either affects
both RTTs equally or artificially reduces the final RTT. We approach
this by recording the info we need to compute the initial RTT
(duration of the "send phase" of the window) when we recorded the
associated inflight. Then, for a filter to avoid bandwidth
overestimates, we generalize the per-sample bandwidth computation
from:
bw = delivered / ack_phase_rtt
to the following:
bw = delivered / max(send_phase_rtt, ack_phase_rtt)
In large-scale experiments, this filtering approach incorporating
send_phase_rtt is effective at avoiding bandwidth overestimates due to
ACK compression or stretched ACKs.
Signed-off-by: Van Jacobson <vanj@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Nandita Dukkipati <nanditad@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-20 11:39:14 +08:00
|
|
|
struct skb_mstamp first_tx_mstamp; /* start of window send phase */
|
|
|
|
struct skb_mstamp delivered_mstamp; /* time we reached "delivered" */
|
2016-09-20 11:39:16 +08:00
|
|
|
u32 rate_delivered; /* saved rate sample: packets delivered */
|
|
|
|
u32 rate_interval_us; /* saved rate sample: time elapsed */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 rcv_wnd; /* Current receiver window */
|
|
|
|
u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
|
tcp: TCP_NOTSENT_LOWAT socket option
Idea of this patch is to add optional limitation of number of
unsent bytes in TCP sockets, to reduce usage of kernel memory.
TCP receiver might announce a big window, and TCP sender autotuning
might allow a large amount of bytes in write queue, but this has little
performance impact if a large part of this buffering is wasted :
Write queue needs to be large only to deal with large BDP, not
necessarily to cope with scheduling delays (incoming ACKS make room
for the application to queue more bytes)
For most workloads, using a value of 128 KB or less is OK to give
applications enough time to react to POLLOUT events in time
(or being awaken in a blocking sendmsg())
This patch adds two ways to set the limit :
1) Per socket option TCP_NOTSENT_LOWAT
2) A sysctl (/proc/sys/net/ipv4/tcp_notsent_lowat) for sockets
not using TCP_NOTSENT_LOWAT socket option (or setting a zero value)
Default value being UINT_MAX (0xFFFFFFFF), meaning this has no effect.
This changes poll()/select()/epoll() to report POLLOUT
only if number of unsent bytes is below tp->nosent_lowat
Note this might increase number of sendmsg()/sendfile() calls
when using non blocking sockets,
and increase number of context switches for blocking sockets.
Note this is not related to SO_SNDLOWAT (as SO_SNDLOWAT is
defined as :
Specify the minimum number of bytes in the buffer until
the socket layer will pass the data to the protocol)
Tested:
netperf sessions, and watching /proc/net/protocols "memory" column for TCP
With 200 concurrent netperf -t TCP_STREAM sessions, amount of kernel memory
used by TCP buffers shrinks by ~55 % (20567 pages instead of 45458)
lpq83:~# echo -1 >/proc/sys/net/ipv4/tcp_notsent_lowat
lpq83:~# (super_netperf 200 -t TCP_STREAM -H remote -l 90 &); sleep 60 ; grep TCP /proc/net/protocols
TCPv6 1880 2 45458 no 208 yes ipv6 y y y y y y y y y y y y y n y y y y y
TCP 1696 508 45458 no 208 yes kernel y y y y y y y y y y y y y n y y y y y
lpq83:~# echo 131072 >/proc/sys/net/ipv4/tcp_notsent_lowat
lpq83:~# (super_netperf 200 -t TCP_STREAM -H remote -l 90 &); sleep 60 ; grep TCP /proc/net/protocols
TCPv6 1880 2 20567 no 208 yes ipv6 y y y y y y y y y y y y y n y y y y y
TCP 1696 508 20567 no 208 yes kernel y y y y y y y y y y y y y n y y y y y
Using 128KB has no bad effect on the throughput or cpu usage
of a single flow, although there is an increase of context switches.
A bonus is that we hold socket lock for a shorter amount
of time and should improve latencies of ACK processing.
lpq83:~# echo -1 >/proc/sys/net/ipv4/tcp_notsent_lowat
lpq83:~# perf stat -e context-switches ./netperf -H 7.7.7.84 -t omni -l 20 -c -i10,3
OMNI Send TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 7.7.7.84 () port 0 AF_INET : +/-2.500% @ 99% conf.
Local Remote Local Elapsed Throughput Throughput Local Local Remote Remote Local Remote Service
Send Socket Recv Socket Send Time Units CPU CPU CPU CPU Service Service Demand
Size Size Size (sec) Util Util Util Util Demand Demand Units
Final Final % Method % Method
1651584 6291456 16384 20.00 17447.90 10^6bits/s 3.13 S -1.00 U 0.353 -1.000 usec/KB
Performance counter stats for './netperf -H 7.7.7.84 -t omni -l 20 -c -i10,3':
412,514 context-switches
200.034645535 seconds time elapsed
lpq83:~# echo 131072 >/proc/sys/net/ipv4/tcp_notsent_lowat
lpq83:~# perf stat -e context-switches ./netperf -H 7.7.7.84 -t omni -l 20 -c -i10,3
OMNI Send TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 7.7.7.84 () port 0 AF_INET : +/-2.500% @ 99% conf.
Local Remote Local Elapsed Throughput Throughput Local Local Remote Remote Local Remote Service
Send Socket Recv Socket Send Time Units CPU CPU CPU CPU Service Service Demand
Size Size Size (sec) Util Util Util Util Demand Demand Units
Final Final % Method % Method
1593240 6291456 16384 20.00 17321.16 10^6bits/s 3.35 S -1.00 U 0.381 -1.000 usec/KB
Performance counter stats for './netperf -H 7.7.7.84 -t omni -l 20 -c -i10,3':
2,675,818 context-switches
200.029651391 seconds time elapsed
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Acked-By: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-07-23 11:27:07 +08:00
|
|
|
u32 notsent_lowat; /* TCP_NOTSENT_LOWAT */
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 pushed_seq; /* Last pushed seq, required to talk to windows */
|
tcp: Reorganize tcp_sock to fill 64-bit holes & improve locality
I tried to group recovery related fields nearby (non-CA_Open related
variables, to be more accurate) so that one to three cachelines would
not be necessary in CA_Open. These are now contiguously deployed:
struct sk_buff_head out_of_order_queue; /* 1968 80 */
/* --- cacheline 32 boundary (2048 bytes) --- */
struct tcp_sack_block duplicate_sack[1]; /* 2048 8 */
struct tcp_sack_block selective_acks[4]; /* 2056 32 */
struct tcp_sack_block recv_sack_cache[4]; /* 2088 32 */
/* --- cacheline 33 boundary (2112 bytes) was 8 bytes ago --- */
struct sk_buff * highest_sack; /* 2120 8 */
int lost_cnt_hint; /* 2128 4 */
int retransmit_cnt_hint; /* 2132 4 */
u32 lost_retrans_low; /* 2136 4 */
u8 reordering; /* 2140 1 */
u8 keepalive_probes; /* 2141 1 */
/* XXX 2 bytes hole, try to pack */
u32 prior_ssthresh; /* 2144 4 */
u32 high_seq; /* 2148 4 */
u32 retrans_stamp; /* 2152 4 */
u32 undo_marker; /* 2156 4 */
int undo_retrans; /* 2160 4 */
u32 total_retrans; /* 2164 4 */
...and they're then followed by URG slowpath & keepalive related
variables.
Head of the out_of_order_queue always needed for empty checks, if
that's empty (and TCP is in CA_Open), following ~200 bytes (in 64-bit)
shouldn't be necessary for anything. If only OFO queue exists but TCP
is in CA_Open, selective_acks (and possibly duplicate_sack) are
necessary besides the out_of_order_queue but the rest of the block
again shouldn't be (ie., the other direction had losses).
As the cacheline boundaries depend on many factors in the preceeding
stuff, trying to align considering them doesn't make too much sense.
Commented one ordering hazard.
There are number of low utilized u8/16s that could be combined get 2
bytes less in total so that the hole could be made to vanish (includes
at least ecn_flags, urg_data, urg_mode, frto_counter, nonagle).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-29 18:25:23 +08:00
|
|
|
u32 lost_out; /* Lost packets */
|
|
|
|
u32 sacked_out; /* SACK'd packets */
|
|
|
|
u32 fackets_out; /* FACK'd packets */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
tcp: Reorganize tcp_sock to fill 64-bit holes & improve locality
I tried to group recovery related fields nearby (non-CA_Open related
variables, to be more accurate) so that one to three cachelines would
not be necessary in CA_Open. These are now contiguously deployed:
struct sk_buff_head out_of_order_queue; /* 1968 80 */
/* --- cacheline 32 boundary (2048 bytes) --- */
struct tcp_sack_block duplicate_sack[1]; /* 2048 8 */
struct tcp_sack_block selective_acks[4]; /* 2056 32 */
struct tcp_sack_block recv_sack_cache[4]; /* 2088 32 */
/* --- cacheline 33 boundary (2112 bytes) was 8 bytes ago --- */
struct sk_buff * highest_sack; /* 2120 8 */
int lost_cnt_hint; /* 2128 4 */
int retransmit_cnt_hint; /* 2132 4 */
u32 lost_retrans_low; /* 2136 4 */
u8 reordering; /* 2140 1 */
u8 keepalive_probes; /* 2141 1 */
/* XXX 2 bytes hole, try to pack */
u32 prior_ssthresh; /* 2144 4 */
u32 high_seq; /* 2148 4 */
u32 retrans_stamp; /* 2152 4 */
u32 undo_marker; /* 2156 4 */
int undo_retrans; /* 2160 4 */
u32 total_retrans; /* 2164 4 */
...and they're then followed by URG slowpath & keepalive related
variables.
Head of the out_of_order_queue always needed for empty checks, if
that's empty (and TCP is in CA_Open), following ~200 bytes (in 64-bit)
shouldn't be necessary for anything. If only OFO queue exists but TCP
is in CA_Open, selective_acks (and possibly duplicate_sack) are
necessary besides the out_of_order_queue but the rest of the block
again shouldn't be (ie., the other direction had losses).
As the cacheline boundaries depend on many factors in the preceeding
stuff, trying to align considering them doesn't make too much sense.
Commented one ordering hazard.
There are number of low utilized u8/16s that could be combined get 2
bytes less in total so that the hole could be made to vanish (includes
at least ecn_flags, urg_data, urg_mode, frto_counter, nonagle).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-29 18:25:23 +08:00
|
|
|
/* from STCP, retrans queue hinting */
|
|
|
|
struct sk_buff* lost_skb_hint;
|
|
|
|
struct sk_buff *retransmit_skb_hint;
|
|
|
|
|
tcp: use an RB tree for ooo receive queue
Over the years, TCP BDP has increased by several orders of magnitude,
and some people are considering to reach the 2 Gbytes limit.
Even with current window scale limit of 14, ~1 Gbytes maps to ~740,000
MSS.
In presence of packet losses (or reorders), TCP stores incoming packets
into an out of order queue, and number of skbs sitting there waiting for
the missing packets to be received can be in the 10^5 range.
Most packets are appended to the tail of this queue, and when
packets can finally be transferred to receive queue, we scan the queue
from its head.
However, in presence of heavy losses, we might have to find an arbitrary
point in this queue, involving a linear scan for every incoming packet,
throwing away cpu caches.
This patch converts it to a RB tree, to get bounded latencies.
Yaogong wrote a preliminary patch about 2 years ago.
Eric did the rebase, added ofo_last_skb cache, polishing and tests.
Tested with network dropping between 1 and 10 % packets, with good
success (about 30 % increase of throughput in stress tests)
Next step would be to also use an RB tree for the write queue at sender
side ;)
Signed-off-by: Yaogong Wang <wygivan@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-By: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-08 05:49:28 +08:00
|
|
|
/* OOO segments go in this rbtree. Socket lock must be held. */
|
|
|
|
struct rb_root out_of_order_queue;
|
|
|
|
struct sk_buff *ooo_last_skb; /* cache rb_last(out_of_order_queue) */
|
tcp: Reorganize tcp_sock to fill 64-bit holes & improve locality
I tried to group recovery related fields nearby (non-CA_Open related
variables, to be more accurate) so that one to three cachelines would
not be necessary in CA_Open. These are now contiguously deployed:
struct sk_buff_head out_of_order_queue; /* 1968 80 */
/* --- cacheline 32 boundary (2048 bytes) --- */
struct tcp_sack_block duplicate_sack[1]; /* 2048 8 */
struct tcp_sack_block selective_acks[4]; /* 2056 32 */
struct tcp_sack_block recv_sack_cache[4]; /* 2088 32 */
/* --- cacheline 33 boundary (2112 bytes) was 8 bytes ago --- */
struct sk_buff * highest_sack; /* 2120 8 */
int lost_cnt_hint; /* 2128 4 */
int retransmit_cnt_hint; /* 2132 4 */
u32 lost_retrans_low; /* 2136 4 */
u8 reordering; /* 2140 1 */
u8 keepalive_probes; /* 2141 1 */
/* XXX 2 bytes hole, try to pack */
u32 prior_ssthresh; /* 2144 4 */
u32 high_seq; /* 2148 4 */
u32 retrans_stamp; /* 2152 4 */
u32 undo_marker; /* 2156 4 */
int undo_retrans; /* 2160 4 */
u32 total_retrans; /* 2164 4 */
...and they're then followed by URG slowpath & keepalive related
variables.
Head of the out_of_order_queue always needed for empty checks, if
that's empty (and TCP is in CA_Open), following ~200 bytes (in 64-bit)
shouldn't be necessary for anything. If only OFO queue exists but TCP
is in CA_Open, selective_acks (and possibly duplicate_sack) are
necessary besides the out_of_order_queue but the rest of the block
again shouldn't be (ie., the other direction had losses).
As the cacheline boundaries depend on many factors in the preceeding
stuff, trying to align considering them doesn't make too much sense.
Commented one ordering hazard.
There are number of low utilized u8/16s that could be combined get 2
bytes less in total so that the hole could be made to vanish (includes
at least ecn_flags, urg_data, urg_mode, frto_counter, nonagle).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-29 18:25:23 +08:00
|
|
|
|
2012-05-08 03:33:04 +08:00
|
|
|
/* SACKs data, these 2 need to be together (see tcp_options_write) */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
|
|
|
|
struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/
|
|
|
|
|
2007-11-16 11:49:47 +08:00
|
|
|
struct tcp_sack_block recv_sack_cache[4];
|
2005-11-11 09:14:59 +08:00
|
|
|
|
2012-02-28 06:52:52 +08:00
|
|
|
struct sk_buff *highest_sack; /* skb just after the highest
|
|
|
|
* skb with SACKed bit set
|
2007-11-16 11:41:46 +08:00
|
|
|
* (validity guaranteed only if
|
|
|
|
* sacked_out > 0)
|
|
|
|
*/
|
2007-03-25 12:03:23 +08:00
|
|
|
|
2005-11-11 09:14:59 +08:00
|
|
|
int lost_cnt_hint;
|
2008-09-21 12:20:20 +08:00
|
|
|
u32 retransmit_high; /* L-bits may be on up to this seqno */
|
2005-11-11 09:14:59 +08:00
|
|
|
|
2008-05-22 08:40:05 +08:00
|
|
|
u32 prior_ssthresh; /* ssthresh saved at recovery start */
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 high_seq; /* snd_nxt at onset of congestion */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 retrans_stamp; /* Timestamp of the last retransmit,
|
2005-04-17 06:20:36 +08:00
|
|
|
* also used in SYN-SENT to remember stamp of
|
|
|
|
* the first SYN. */
|
2014-08-23 05:15:22 +08:00
|
|
|
u32 undo_marker; /* snd_una upon a new recovery episode. */
|
2005-04-17 06:20:36 +08:00
|
|
|
int undo_retrans; /* number of undoable retransmissions. */
|
tcp: Reorganize tcp_sock to fill 64-bit holes & improve locality
I tried to group recovery related fields nearby (non-CA_Open related
variables, to be more accurate) so that one to three cachelines would
not be necessary in CA_Open. These are now contiguously deployed:
struct sk_buff_head out_of_order_queue; /* 1968 80 */
/* --- cacheline 32 boundary (2048 bytes) --- */
struct tcp_sack_block duplicate_sack[1]; /* 2048 8 */
struct tcp_sack_block selective_acks[4]; /* 2056 32 */
struct tcp_sack_block recv_sack_cache[4]; /* 2088 32 */
/* --- cacheline 33 boundary (2112 bytes) was 8 bytes ago --- */
struct sk_buff * highest_sack; /* 2120 8 */
int lost_cnt_hint; /* 2128 4 */
int retransmit_cnt_hint; /* 2132 4 */
u32 lost_retrans_low; /* 2136 4 */
u8 reordering; /* 2140 1 */
u8 keepalive_probes; /* 2141 1 */
/* XXX 2 bytes hole, try to pack */
u32 prior_ssthresh; /* 2144 4 */
u32 high_seq; /* 2148 4 */
u32 retrans_stamp; /* 2152 4 */
u32 undo_marker; /* 2156 4 */
int undo_retrans; /* 2160 4 */
u32 total_retrans; /* 2164 4 */
...and they're then followed by URG slowpath & keepalive related
variables.
Head of the out_of_order_queue always needed for empty checks, if
that's empty (and TCP is in CA_Open), following ~200 bytes (in 64-bit)
shouldn't be necessary for anything. If only OFO queue exists but TCP
is in CA_Open, selective_acks (and possibly duplicate_sack) are
necessary besides the out_of_order_queue but the rest of the block
again shouldn't be (ie., the other direction had losses).
As the cacheline boundaries depend on many factors in the preceeding
stuff, trying to align considering them doesn't make too much sense.
Commented one ordering hazard.
There are number of low utilized u8/16s that could be combined get 2
bytes less in total so that the hole could be made to vanish (includes
at least ecn_flags, urg_data, urg_mode, frto_counter, nonagle).
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-29 18:25:23 +08:00
|
|
|
u32 total_retrans; /* Total retransmits for entire connection */
|
|
|
|
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 urg_seq; /* Seq of received urgent pointer */
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int keepalive_time; /* time before keep alive takes place */
|
|
|
|
unsigned int keepalive_intvl; /* time interval between keep alive probes */
|
|
|
|
|
2009-04-19 17:43:48 +08:00
|
|
|
int linger2;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Receiver side RTT estimation */
|
|
|
|
struct {
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 rtt;
|
|
|
|
u32 seq;
|
|
|
|
u32 time;
|
2005-04-17 06:20:36 +08:00
|
|
|
} rcv_rtt_est;
|
|
|
|
|
|
|
|
/* Receiver queue space */
|
|
|
|
struct {
|
|
|
|
int space;
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 seq;
|
|
|
|
u32 time;
|
2005-04-17 06:20:36 +08:00
|
|
|
} rcvq_space;
|
2006-03-21 13:32:58 +08:00
|
|
|
|
|
|
|
/* TCP-specific MTU probe information. */
|
|
|
|
struct {
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 probe_seq_start;
|
|
|
|
u32 probe_seq_end;
|
2006-03-21 13:32:58 +08:00
|
|
|
} mtu_probe;
|
2012-07-23 15:48:52 +08:00
|
|
|
u32 mtu_info; /* We received an ICMP_FRAG_NEEDED / ICMPV6_PKT_TOOBIG
|
|
|
|
* while socket was owned by user.
|
|
|
|
*/
|
2006-11-15 11:07:45 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_TCP_MD5SIG
|
|
|
|
/* TCP AF-Specific parts; only used by MD5 Signature support so far */
|
2009-09-02 03:25:03 +08:00
|
|
|
const struct tcp_sock_af_ops *af_specific;
|
2006-11-15 11:07:45 +08:00
|
|
|
|
2009-09-02 03:25:03 +08:00
|
|
|
/* TCP MD5 Signature Option information */
|
2012-02-01 02:45:40 +08:00
|
|
|
struct tcp_md5sig_info __rcu *md5sig_info;
|
2006-11-15 11:07:45 +08:00
|
|
|
#endif
|
TCPCT part 1d: define TCP cookie option, extend existing struct's
Data structures are carefully composed to require minimal additions.
For example, the struct tcp_options_received cookie_plus variable fits
between existing 16-bit and 8-bit variables, requiring no additional
space (taking alignment into consideration). There are no additions to
tcp_request_sock, and only 1 pointer in tcp_sock.
This is a significantly revised implementation of an earlier (year-old)
patch that no longer applies cleanly, with permission of the original
author (Adam Langley):
http://thread.gmane.org/gmane.linux.network/102586
The principle difference is using a TCP option to carry the cookie nonce,
instead of a user configured offset in the data. This is more flexible and
less subject to user configuration error. Such a cookie option has been
suggested for many years, and is also useful without SYN data, allowing
several related concepts to use the same extension option.
"Re: SYN floods (was: does history repeat itself?)", September 9, 1996.
http://www.merit.net/mail.archives/nanog/1996-09/msg00235.html
"Re: what a new TCP header might look like", May 12, 1998.
ftp://ftp.isi.edu/end2end/end2end-interest-1998.mail
These functions will also be used in subsequent patches that implement
additional features.
Requires:
TCPCT part 1a: add request_values parameter for sending SYNACK
TCPCT part 1b: generate Responder Cookie secret
TCPCT part 1c: sysctl_tcp_cookie_size, socket option TCP_COOKIE_TRANSACTIONS
Signed-off-by: William.Allen.Simpson@gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-03 02:17:05 +08:00
|
|
|
|
2012-08-31 20:29:11 +08:00
|
|
|
/* TCP fastopen related information */
|
|
|
|
struct tcp_fastopen_request *fastopen_req;
|
|
|
|
/* fastopen_rsk points to request_sock that resulted in this big
|
|
|
|
* socket. Used to retransmit SYNACKs etc.
|
|
|
|
*/
|
|
|
|
struct request_sock *fastopen_rsk;
|
2015-05-04 12:34:46 +08:00
|
|
|
u32 *saved_syn;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2016-12-04 03:14:50 +08:00
|
|
|
enum tsq_enum {
|
tcp: TCP Small Queues
This introduce TSQ (TCP Small Queues)
TSQ goal is to reduce number of TCP packets in xmit queues (qdisc &
device queues), to reduce RTT and cwnd bias, part of the bufferbloat
problem.
sk->sk_wmem_alloc not allowed to grow above a given limit,
allowing no more than ~128KB [1] per tcp socket in qdisc/dev layers at a
given time.
TSO packets are sized/capped to half the limit, so that we have two
TSO packets in flight, allowing better bandwidth use.
As a side effect, setting the limit to 40000 automatically reduces the
standard gso max limit (65536) to 40000/2 : It can help to reduce
latencies of high prio packets, having smaller TSO packets.
This means we divert sock_wfree() to a tcp_wfree() handler, to
queue/send following frames when skb_orphan() [2] is called for the
already queued skbs.
Results on my dev machines (tg3/ixgbe nics) are really impressive,
using standard pfifo_fast, and with or without TSO/GSO.
Without reduction of nominal bandwidth, we have reduction of buffering
per bulk sender :
< 1ms on Gbit (instead of 50ms with TSO)
< 8ms on 100Mbit (instead of 132 ms)
I no longer have 4 MBytes backlogged in qdisc by a single netperf
session, and both side socket autotuning no longer use 4 Mbytes.
As skb destructor cannot restart xmit itself ( as qdisc lock might be
taken at this point ), we delegate the work to a tasklet. We use one
tasklest per cpu for performance reasons.
If tasklet finds a socket owned by the user, it sets TSQ_OWNED flag.
This flag is tested in a new protocol method called from release_sock(),
to eventually send new segments.
[1] New /proc/sys/net/ipv4/tcp_limit_output_bytes tunable
[2] skb_orphan() is usually called at TX completion time,
but some drivers call it in their start_xmit() handler.
These drivers should at least use BQL, or else a single TCP
session can still fill the whole NIC TX ring, since TSQ will
have no effect.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Dave Taht <dave.taht@bufferbloat.net>
Cc: Tom Herbert <therbert@google.com>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Nandita Dukkipati <nanditad@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-07-11 13:50:31 +08:00
|
|
|
TSQ_THROTTLED,
|
|
|
|
TSQ_QUEUED,
|
2012-07-20 13:45:50 +08:00
|
|
|
TCP_TSQ_DEFERRED, /* tcp_tasklet_func() found socket was owned */
|
|
|
|
TCP_WRITE_TIMER_DEFERRED, /* tcp_write_timer() found socket was owned */
|
|
|
|
TCP_DELACK_TIMER_DEFERRED, /* tcp_delack_timer() found socket was owned */
|
2012-07-23 15:48:52 +08:00
|
|
|
TCP_MTU_REDUCED_DEFERRED, /* tcp_v{4|6}_err() could not call
|
|
|
|
* tcp_v{4|6}_mtu_reduced()
|
|
|
|
*/
|
tcp: TCP Small Queues
This introduce TSQ (TCP Small Queues)
TSQ goal is to reduce number of TCP packets in xmit queues (qdisc &
device queues), to reduce RTT and cwnd bias, part of the bufferbloat
problem.
sk->sk_wmem_alloc not allowed to grow above a given limit,
allowing no more than ~128KB [1] per tcp socket in qdisc/dev layers at a
given time.
TSO packets are sized/capped to half the limit, so that we have two
TSO packets in flight, allowing better bandwidth use.
As a side effect, setting the limit to 40000 automatically reduces the
standard gso max limit (65536) to 40000/2 : It can help to reduce
latencies of high prio packets, having smaller TSO packets.
This means we divert sock_wfree() to a tcp_wfree() handler, to
queue/send following frames when skb_orphan() [2] is called for the
already queued skbs.
Results on my dev machines (tg3/ixgbe nics) are really impressive,
using standard pfifo_fast, and with or without TSO/GSO.
Without reduction of nominal bandwidth, we have reduction of buffering
per bulk sender :
< 1ms on Gbit (instead of 50ms with TSO)
< 8ms on 100Mbit (instead of 132 ms)
I no longer have 4 MBytes backlogged in qdisc by a single netperf
session, and both side socket autotuning no longer use 4 Mbytes.
As skb destructor cannot restart xmit itself ( as qdisc lock might be
taken at this point ), we delegate the work to a tasklet. We use one
tasklest per cpu for performance reasons.
If tasklet finds a socket owned by the user, it sets TSQ_OWNED flag.
This flag is tested in a new protocol method called from release_sock(),
to eventually send new segments.
[1] New /proc/sys/net/ipv4/tcp_limit_output_bytes tunable
[2] skb_orphan() is usually called at TX completion time,
but some drivers call it in their start_xmit() handler.
These drivers should at least use BQL, or else a single TCP
session can still fill the whole NIC TX ring, since TSQ will
have no effect.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Dave Taht <dave.taht@bufferbloat.net>
Cc: Tom Herbert <therbert@google.com>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Nandita Dukkipati <nanditad@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-07-11 13:50:31 +08:00
|
|
|
};
|
|
|
|
|
2016-12-04 03:14:50 +08:00
|
|
|
enum tsq_flags {
|
|
|
|
TSQF_THROTTLED = (1UL << TSQ_THROTTLED),
|
|
|
|
TSQF_QUEUED = (1UL << TSQ_QUEUED),
|
|
|
|
TCPF_TSQ_DEFERRED = (1UL << TCP_TSQ_DEFERRED),
|
|
|
|
TCPF_WRITE_TIMER_DEFERRED = (1UL << TCP_WRITE_TIMER_DEFERRED),
|
|
|
|
TCPF_DELACK_TIMER_DEFERRED = (1UL << TCP_DELACK_TIMER_DEFERRED),
|
|
|
|
TCPF_MTU_REDUCED_DEFERRED = (1UL << TCP_MTU_REDUCED_DEFERRED),
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline struct tcp_sock *tcp_sk(const struct sock *sk)
|
|
|
|
{
|
|
|
|
return (struct tcp_sock *)sk;
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:09:30 +08:00
|
|
|
struct tcp_timewait_sock {
|
|
|
|
struct inet_timewait_sock tw_sk;
|
2015-10-09 10:33:24 +08:00
|
|
|
#define tw_rcv_nxt tw_sk.__tw_common.skc_tw_rcv_nxt
|
|
|
|
#define tw_snd_nxt tw_sk.__tw_common.skc_tw_snd_nxt
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 tw_rcv_wnd;
|
2013-02-11 13:50:17 +08:00
|
|
|
u32 tw_ts_offset;
|
2006-11-28 11:12:38 +08:00
|
|
|
u32 tw_ts_recent;
|
2015-02-07 05:04:41 +08:00
|
|
|
|
|
|
|
/* The time we sent the last out-of-window ACK: */
|
|
|
|
u32 tw_last_oow_ack_time;
|
|
|
|
|
2005-08-10 11:09:30 +08:00
|
|
|
long tw_ts_recent_stamp;
|
2006-11-15 11:07:45 +08:00
|
|
|
#ifdef CONFIG_TCP_MD5SIG
|
2012-06-10 05:56:12 +08:00
|
|
|
struct tcp_md5sig_key *tw_md5_key;
|
2006-11-15 11:07:45 +08:00
|
|
|
#endif
|
2005-08-10 11:09:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
|
|
|
|
{
|
|
|
|
return (struct tcp_timewait_sock *)sk;
|
|
|
|
}
|
|
|
|
|
2012-08-31 20:29:11 +08:00
|
|
|
static inline bool tcp_passive_fastopen(const struct sock *sk)
|
|
|
|
{
|
|
|
|
return (sk->sk_state == TCP_SYN_RECV &&
|
|
|
|
tcp_sk(sk)->fastopen_rsk != NULL);
|
|
|
|
}
|
|
|
|
|
2015-09-29 22:42:52 +08:00
|
|
|
static inline void fastopen_queue_tune(struct sock *sk, int backlog)
|
2012-08-31 20:29:11 +08:00
|
|
|
{
|
2015-09-29 22:42:52 +08:00
|
|
|
struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
|
2015-10-21 04:17:40 +08:00
|
|
|
int somaxconn = READ_ONCE(sock_net(sk)->core.sysctl_somaxconn);
|
2015-09-29 22:42:52 +08:00
|
|
|
|
2015-10-21 04:17:40 +08:00
|
|
|
queue->fastopenq.max_qlen = min_t(unsigned int, backlog, somaxconn);
|
2012-08-31 20:29:11 +08:00
|
|
|
}
|
|
|
|
|
2015-11-06 03:07:13 +08:00
|
|
|
static inline void tcp_move_syn(struct tcp_sock *tp,
|
|
|
|
struct request_sock *req)
|
|
|
|
{
|
|
|
|
tp->saved_syn = req->saved_syn;
|
|
|
|
req->saved_syn = NULL;
|
|
|
|
}
|
|
|
|
|
2015-05-04 12:34:46 +08:00
|
|
|
static inline void tcp_saved_syn_free(struct tcp_sock *tp)
|
|
|
|
{
|
|
|
|
kfree(tp->saved_syn);
|
|
|
|
tp->saved_syn = NULL;
|
|
|
|
}
|
|
|
|
|
2016-11-28 15:07:18 +08:00
|
|
|
struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _LINUX_TCP_H */
|