netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, tom.zanussi@linux.intel.com,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 16/24] net, diet: Make TCP fastopen optional
Date: Mon,  5 May 2014 15:26:05 -0700	[thread overview]
Message-ID: <1399328773-6531-17-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1399328773-6531-1-git-send-email-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

Make TCP fast open a config option. It's not really needed
on small systems. By itself it saves about 3k text,
but the main advantage is that CONFIG_INET doesn't
pull in AES and the crypto subsystem anymore, which
is worth far more savings.

   text	   data	    bss	    dec	    hex	filename
6954762	1404960	 765952	9125674	 8b3f2a	vmlinux-with-fastopen
6951618	1400608	 765952	9118178	 8b21e2	vmlinux-wo-fastopen

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 include/linux/tcp.h        | 14 ++++++++++++--
 include/net/request_sock.h |  5 +++++
 include/net/tcp.h          |  9 +++++++++
 net/Kconfig                |  4 ++--
 net/core/request_sock.c    |  2 ++
 net/ipv4/Kconfig           |  4 ++++
 net/ipv4/Makefile          |  3 ++-
 net/ipv4/sysctl_net_ipv4.c |  4 ++++
 net/ipv4/tcp.c             |  4 ++++
 net/ipv4/tcp_ipv4.c        | 18 ++++++++++++++++++
 10 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 2399468..e0825e2 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -359,6 +359,9 @@ static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
 	return (struct tcp_timewait_sock *)sk;
 }
 
+extern void tcp_sock_destruct(struct sock *sk);
+
+#ifdef CONFIG_TCP_FASTOPEN
 static inline bool tcp_passive_fastopen(const struct sock *sk)
 {
 	return (sk->sk_state == TCP_SYN_RECV &&
@@ -370,8 +373,6 @@ static inline bool fastopen_cookie_present(struct tcp_fastopen_cookie *foc)
 	return foc->len != -1;
 }
 
-extern void tcp_sock_destruct(struct sock *sk);
-
 static inline int fastopen_init_queue(struct sock *sk, int backlog)
 {
 	struct request_sock_queue *queue =
@@ -391,4 +392,13 @@ static inline int fastopen_init_queue(struct sock *sk, int backlog)
 	return 0;
 }
 
+#else
+static inline bool tcp_passive_fastopen(const struct sock *sk)
+{ return false; }
+static inline bool fastopen_cookie_present(struct tcp_fastopen_cookie *foc)
+{ return false; }
+static inline int fastopen_init_queue(struct sock *sk, int backlog)
+{ return 0; }
+#endif
+
 #endif	/* _LINUX_TCP_H */
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 7f830ff..ad1f97a 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -168,8 +168,13 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
 
 void __reqsk_queue_destroy(struct request_sock_queue *queue);
 void reqsk_queue_destroy(struct request_sock_queue *queue);
+#ifdef CONFIG_TCP_FASTOPEN
 void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
 			   bool reset);
+#else
+static inline void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
+			   bool reset) {}
+#endif
 
 static inline struct request_sock *
 	reqsk_queue_yank_acceptq(struct request_sock_queue *queue)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index ac9f6bd..1a5e91b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -251,7 +251,11 @@ extern int sysctl_tcp_retries1;
 extern int sysctl_tcp_retries2;
 extern int sysctl_tcp_orphan_retries;
 extern int sysctl_tcp_syncookies;
+#ifdef CONFIG_TCP_FASTOPEN
 extern int sysctl_tcp_fastopen;
+#else
+#define sysctl_tcp_fastopen 0
+#endif
 extern int sysctl_tcp_retrans_collapse;
 extern int sysctl_tcp_stdurg;
 extern int sysctl_tcp_rfc1337;
@@ -1333,7 +1337,12 @@ struct tcp_fastopen_request {
 	size_t				size;
 	int				copied;	/* queued in tcp_connect() */
 };
+
+#ifdef CONFIG_TCP_FASTOPEN
 void tcp_free_fastopen_req(struct tcp_sock *tp);
+#else
+static inline void tcp_free_fastopen_req(struct tcp_sock *tp) {}
+#endif
 
 extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
 int tcp_fastopen_reset_cipher(void *key, unsigned int len);
diff --git a/net/Kconfig b/net/Kconfig
index f5196ba..fe6e856 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -61,8 +61,8 @@ source "net/iucv/Kconfig"
 
 config INET
 	bool "TCP/IP networking"
-	select CRYPTO
-	select CRYPTO_AES
+	select CRYPTO if TCP_FASTOPEN
+	select CRYPTO_AES if TCP_FASTOPEN
 	---help---
 	  These are the protocols used on the Internet and on most local
 	  Ethernets. It is highly recommended to say Y here (this will enlarge
diff --git a/net/core/request_sock.c b/net/core/request_sock.c
index 467f326..80ad1dd 100644
--- a/net/core/request_sock.c
+++ b/net/core/request_sock.c
@@ -131,6 +131,7 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
 		kfree(lopt);
 }
 
+#ifdef CONFIG_TCP_FASTOPEN
 /*
  * This function is called to set a Fast Open socket's "fastopen_rsk" field
  * to NULL when a TFO socket no longer needs to access the request_sock.
@@ -222,3 +223,4 @@ out:
 	spin_unlock_bh(&fastopenq->lock);
 	sock_put(lsk);
 }
+#endif
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index c1f9899..df5c569 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -320,6 +320,10 @@ config NET_IPVTI
 	  the notion of a secure tunnel for IPSEC and then use routing protocol
 	  on top.
 
+config TCP_FASTOPEN
+	bool "Enable TCP fastopen"
+	default y
+
 config INET_AH
 	tristate "IP: AH transformation"
 	select XFRM_ALGO
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index eb129a4..addecef 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -7,7 +7,7 @@ obj-y     := route.o inetpeer.o protocol.o \
 	     ip_output.o ip_sockglue.o inet_hashtables.o \
 	     inet_timewait_sock.o inet_connection_sock.o \
 	     tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
-	     tcp_minisocks.o tcp_cong.o tcp_fastopen.o \
+	     tcp_minisocks.o tcp_cong.o \
 	     datagram.o raw.o udp.o udplite.o \
 	     arp.o icmp.o devinet.o af_inet.o \
 	     fib_frontend.o fib_semantics.o fib_trie.o \
@@ -55,6 +55,7 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
 obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
 obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
 obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
+obj-$(CONFIG_TCP_FASTOPEN) += tcp_fastopen.o
 obj-$(CONFIG_MEMCG_KMEM) += tcp_memcontrol.o
 obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
 
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index fe5823a..9a9f96c 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -200,6 +200,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
 	return ret;
 }
 
+#ifdef CONFIG_TCP_FASTOPEN
 static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
 				 void __user *buffer, size_t *lenp,
 				 loff_t *ppos)
@@ -246,6 +247,7 @@ bad_key:
 	kfree(tbl.data);
 	return ret;
 }
+#endif
 
 static struct ctl_table ipv4_table[] = {
 	{
@@ -388,6 +390,7 @@ static struct ctl_table ipv4_table[] = {
 		.proc_handler	= proc_dointvec
 	},
 #endif
+#ifdef CONFIG_TCP_FASTOPEN
 	{
 		.procname	= "tcp_fastopen",
 		.data		= &sysctl_tcp_fastopen,
@@ -401,6 +404,7 @@ static struct ctl_table ipv4_table[] = {
 		.maxlen		= ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
 		.proc_handler	= proc_tcp_fastopen_key,
 	},
+#endif
 	{
 		.procname	= "tcp_tw_recycle",
 		.data		= &tcp_death_row.sysctl_tw_recycle,
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3fd48421..ef14cb6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1036,6 +1036,7 @@ static inline int select_size(const struct sock *sk, bool sg)
 	return tmp;
 }
 
+#ifdef CONFIG_TCP_FASTOPEN
 void tcp_free_fastopen_req(struct tcp_sock *tp)
 {
 	if (tp->fastopen_req != NULL) {
@@ -1069,6 +1070,7 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
 	tcp_free_fastopen_req(tp);
 	return err;
 }
+#endif
 
 int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 		size_t size)
@@ -1084,6 +1086,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 	lock_sock(sk);
 
 	flags = msg->msg_flags;
+#ifdef CONFIG_TCP_FASTOPEN
 	if (flags & MSG_FASTOPEN) {
 		err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);
 		if (err == -EINPROGRESS && copied_syn > 0)
@@ -1092,6 +1095,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 			goto out_err;
 		offset = copied_syn;
 	}
+#endif
 
 	timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 438f3b9..fbddabb 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1260,6 +1260,7 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
 };
 #endif
 
+#ifdef CONFIG_TCP_FASTOPEN
 static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
 			       struct request_sock *req,
 			       struct tcp_fastopen_cookie *foc,
@@ -1440,6 +1441,23 @@ static int tcp_v4_conn_req_fastopen(struct sock *sk,
 	WARN_ON(req->sk == NULL);
 	return 0;
 }
+#else
+static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
+			       struct request_sock *req,
+			       struct tcp_fastopen_cookie *foc,
+			       struct tcp_fastopen_cookie *valid_foc)
+{
+	return false;
+}
+
+static int tcp_v4_conn_req_fastopen(struct sock *sk,
+				    struct sk_buff *skb,
+				    struct sk_buff *skb_synack,
+				    struct request_sock *req)
+{
+	return 0;
+}
+#endif
 
 int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
 {
-- 
1.9.0

  parent reply	other threads:[~2014-05-05 22:26 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-05 22:25 RFC: A reduced Linux network stack for small systems Andi Kleen
2014-05-05 22:25 ` [PATCH 01/24] net, diet: Reduce netdev name hash table for CONFIG_BASE_SMALL Andi Kleen
2014-05-06  3:03   ` David Miller
2014-05-05 22:25 ` [PATCH 02/24] net, diet: Reduce NAPI " Andi Kleen
2014-05-05 22:25 ` [PATCH 03/24] net, diet: Decrease ip defrag hash tables and max length with BASE_SMALL Andi Kleen
2014-05-05 22:25 ` [PATCH 04/24] net, diet: Make FIB hash tables smaller with CONFIG_BASE_SMALL Andi Kleen
2014-05-06  3:10   ` David Miller
2014-05-05 22:25 ` [PATCH 05/24] net, diet: Default to small TCP hash tables on small kernels Andi Kleen
2014-05-06  3:12   ` David Miller
2014-05-05 22:25 ` [PATCH 06/24] net, diet: Use small UDP " Andi Kleen
2014-05-06  3:11   ` David Miller
2014-05-06 14:26   ` Eric Dumazet
2014-05-06 18:23     ` Andi Kleen
2014-05-06 19:25       ` Eric Dumazet
2014-05-05 22:25 ` [PATCH 07/24] net, diet: Make ping sockets optional Andi Kleen
2014-05-06  3:04   ` David Miller
2014-05-05 22:25 ` [PATCH 08/24] net, diet: Make TCP metrics optional Andi Kleen
2014-05-05 23:18   ` Yuchung Cheng
2014-05-05 23:28     ` Andi Kleen
2014-05-06  3:12   ` David Miller
2014-05-06  3:21     ` Andi Kleen
2014-05-06  3:23       ` David Miller
2014-05-06  4:39         ` Tom Zanussi
2014-05-07 13:59           ` One Thousand Gnomes
2014-05-07 17:20             ` David Miller
2014-05-07 22:19               ` Tim Bird
2014-05-07 22:52                 ` David Miller
2014-05-06 15:57         ` josh
2014-05-06 15:59           ` David Miller
2014-05-06 16:41             ` josh
2014-05-06 17:12               ` Rick Jones
2014-05-06 18:09                 ` josh
2014-05-06 17:16               ` David Miller
2014-05-06 17:55                 ` josh
2014-05-06 18:33                   ` Cong Wang
2014-05-06 18:48                     ` Andi Kleen
2014-05-06 19:19                     ` Richard Cochran
2014-05-06 20:44                     ` David Miller
2014-05-06 21:08                       ` josh
2014-05-06 21:11                         ` David Miller
2014-05-06 22:50                           ` josh
2014-05-06 23:27                             ` Eric Dumazet
2014-06-14 20:33                     ` Pavel Machek
2014-06-23 10:17                     ` zhuyj
2014-05-06 19:14               ` Richard Cochran
2014-05-06 19:50                 ` Andi Kleen
2014-05-06 20:07                   ` Richard Cochran
2014-05-06 21:05                     ` Andi Kleen
2014-05-06 23:29                       ` Eric Dumazet
2014-05-07  4:33                         ` Andi Kleen
2014-05-06 20:46                   ` David Miller
2014-05-07  8:39               ` David Laight
2014-05-09  9:48             ` Pavel Machek
2014-05-06 16:39           ` Eric Dumazet
2014-05-06 16:45             ` josh
2014-05-06 17:03               ` Eric Dumazet
2014-05-06 17:30                 ` josh
2014-05-06 17:17               ` David Miller
2014-05-06 17:21                 ` josh
2014-05-06 17:25                   ` David Miller
2014-05-06 20:06                     ` Andi Kleen
2014-05-06 20:47                       ` David Miller
2014-05-06 20:11                     ` josh
2014-05-06 20:44                       ` Andi Kleen
2014-05-06 17:14             ` David Miller
2014-05-06 18:32             ` Andi Kleen
2014-05-06 18:58               ` Tom Herbert
2014-05-06 19:37                 ` josh
2014-05-06 19:57                 ` Andi Kleen
2014-05-06 20:17               ` Eric Dumazet
2014-05-06 20:27                 ` josh
2014-05-06 20:37                 ` Andi Kleen
2014-05-06 20:48                 ` David Miller
2014-05-07 13:35                 ` One Thousand Gnomes
2014-05-13 16:22                   ` Christer Weinigel
2014-05-09  7:38     ` Pavel Machek
2014-05-05 22:25 ` [PATCH 09/24] net, diet: Make ethtool optional Andi Kleen
2014-05-06  3:11   ` David Miller
2014-05-06  3:14     ` Andi Kleen
2014-05-06  3:22       ` David Miller
2014-05-05 22:25 ` [PATCH 10/24] net, diet: Make LPF filter optional Andi Kleen
2014-05-06  3:10   ` David Miller
2014-05-05 22:26 ` [PATCH 11/24] net, diet: Move rtnl_lock to separate file Andi Kleen
2014-05-05 22:26 ` [PATCH 12/24] net, diet: Make rtnetlink optional Andi Kleen
2014-05-06  3:08   ` David Miller
2014-05-06  3:11     ` Andi Kleen
2014-05-05 22:26 ` [PATCH 13/24] net, diet: Make GRO offload optional Andi Kleen
2014-05-06  3:01   ` David Miller
2014-05-06  3:03     ` Andi Kleen
2014-05-05 22:26 ` [PATCH 14/24] net, diet: Make MIB statistics collections depend on PROC_FS Andi Kleen
2014-05-06  3:05   ` David Miller
2014-05-05 22:26 ` [PATCH 15/24] net, diet: Make igmp and mcast ioctls depend on IP_MULTICAST Andi Kleen
2014-05-05 22:26 ` Andi Kleen [this message]
2014-05-06  3:06   ` [PATCH 16/24] net, diet: Make TCP fastopen optional David Miller
2014-05-05 22:26 ` [PATCH 17/24] net, diet: Make internal control sockets use UDP Andi Kleen
2014-05-05 22:26 ` [PATCH 18/24] net, diet: Make raw sockets optional Andi Kleen
2014-05-06  3:12   ` David Miller
2014-05-05 22:26 ` [PATCH 19/24] net, diet: Make RPS configurable Andi Kleen
2014-05-06  3:14   ` David Miller
2014-05-06  3:16     ` Andi Kleen
2014-05-06  8:32   ` Bjørn Mork
2014-05-05 22:26 ` [PATCH 20/24] net, diet: Make XPS configurable Andi Kleen
2014-05-05 22:26 ` [PATCH 21/24] net, diet: Make packet tpacket/mmap/fanout/rings optional Andi Kleen
2014-05-06  3:09   ` David Miller
2014-05-05 22:26 ` [PATCH 22/24] net, diet: Support simpler routing table Andi Kleen
2014-05-06  3:02   ` David Miller
2014-05-06  3:08     ` Andi Kleen
2014-05-06  3:21       ` David Miller
2014-05-05 22:26 ` [PATCH 23/24] net, diet: Add coccinelle script to convert drivers to ETHTOOL_OPS Andi Kleen
2014-05-06  9:27   ` Nicolas Palix
2014-05-06 15:05     ` David Miller
2014-05-07  0:18       ` Wilfried Klaebe
2014-05-05 22:26 ` [PATCH 24/24] net, diet: Convert all drivers to use SET_ETHTOOL_OPS Andi Kleen
2014-05-06  7:25 ` RFC: A reduced Linux network stack for small systems Richard Weinberger
2014-05-06 13:34   ` Tom Zanussi
2014-05-06 15:20     ` Alexei Starovoitov
2014-05-06 15:34       ` Tom Zanussi
2014-05-06 17:20         ` Alexei Starovoitov
2014-05-06 20:00           ` Andi Kleen
2014-05-06 21:05             ` Alexei Starovoitov
2014-05-09  7:39           ` Pavel Machek
2014-05-09  7:38       ` Pavel Machek
2014-05-06  9:18 ` David Laight
2014-05-07 13:20   ` One Thousand Gnomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399328773-6531-17-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom.zanussi@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).