tcp-fastopen.patch 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. diff -Nur linux-3.15.1.orig/include/linux/tcp.h linux-3.15.1/include/linux/tcp.h
  2. --- linux-3.15.1.orig/include/linux/tcp.h 2014-06-16 22:44:27.000000000 +0200
  3. +++ linux-3.15.1/include/linux/tcp.h 2014-06-28 10:10:20.616857903 +0200
  4. @@ -359,6 +359,9 @@
  5. return (struct tcp_timewait_sock *)sk;
  6. }
  7. +extern void tcp_sock_destruct(struct sock *sk);
  8. +
  9. +#ifdef CONFIG_TCP_FASTOPEN
  10. static inline bool tcp_passive_fastopen(const struct sock *sk)
  11. {
  12. return (sk->sk_state == TCP_SYN_RECV &&
  13. @@ -370,8 +373,6 @@
  14. return foc->len != -1;
  15. }
  16. -extern void tcp_sock_destruct(struct sock *sk);
  17. -
  18. static inline int fastopen_init_queue(struct sock *sk, int backlog)
  19. {
  20. struct request_sock_queue *queue =
  21. @@ -391,4 +392,13 @@
  22. return 0;
  23. }
  24. +#else
  25. +static inline bool tcp_passive_fastopen(const struct sock *sk)
  26. +{ return false; }
  27. +static inline bool fastopen_cookie_present(struct tcp_fastopen_cookie *foc)
  28. +{ return false; }
  29. +static inline int fastopen_init_queue(struct sock *sk, int backlog)
  30. +{ return 0; }
  31. +#endif
  32. +
  33. #endif /* _LINUX_TCP_H */
  34. diff -Nur linux-3.15.1.orig/include/net/request_sock.h linux-3.15.1/include/net/request_sock.h
  35. --- linux-3.15.1.orig/include/net/request_sock.h 2014-06-16 22:44:27.000000000 +0200
  36. +++ linux-3.15.1/include/net/request_sock.h 2014-06-28 10:10:20.620857907 +0200
  37. @@ -168,8 +168,13 @@
  38. void __reqsk_queue_destroy(struct request_sock_queue *queue);
  39. void reqsk_queue_destroy(struct request_sock_queue *queue);
  40. +#ifdef CONFIG_TCP_FASTOPEN
  41. void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
  42. bool reset);
  43. +#else
  44. +static inline void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
  45. + bool reset) {}
  46. +#endif
  47. static inline struct request_sock *
  48. reqsk_queue_yank_acceptq(struct request_sock_queue *queue)
  49. diff -Nur linux-3.15.1.orig/include/net/tcp.h linux-3.15.1/include/net/tcp.h
  50. --- linux-3.15.1.orig/include/net/tcp.h 2014-06-16 22:44:27.000000000 +0200
  51. +++ linux-3.15.1/include/net/tcp.h 2014-06-28 10:10:20.620857907 +0200
  52. @@ -251,7 +251,11 @@
  53. extern int sysctl_tcp_retries2;
  54. extern int sysctl_tcp_orphan_retries;
  55. extern int sysctl_tcp_syncookies;
  56. +#ifdef CONFIG_TCP_FASTOPEN
  57. extern int sysctl_tcp_fastopen;
  58. +#else
  59. +#define sysctl_tcp_fastopen 0
  60. +#endif
  61. extern int sysctl_tcp_retrans_collapse;
  62. extern int sysctl_tcp_stdurg;
  63. extern int sysctl_tcp_rfc1337;
  64. @@ -1308,7 +1312,12 @@
  65. size_t size;
  66. int copied; /* queued in tcp_connect() */
  67. };
  68. +
  69. +#ifdef CONFIG_TCP_FASTOPEN
  70. void tcp_free_fastopen_req(struct tcp_sock *tp);
  71. +#else
  72. +static inline void tcp_free_fastopen_req(struct tcp_sock *tp) {}
  73. +#endif
  74. extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
  75. int tcp_fastopen_reset_cipher(void *key, unsigned int len);
  76. diff -Nur linux-3.15.1.orig/net/core/request_sock.c linux-3.15.1/net/core/request_sock.c
  77. --- linux-3.15.1.orig/net/core/request_sock.c 2014-06-16 22:44:27.000000000 +0200
  78. +++ linux-3.15.1/net/core/request_sock.c 2014-06-28 10:10:20.624857911 +0200
  79. @@ -131,6 +131,7 @@
  80. kfree(lopt);
  81. }
  82. +#ifdef CONFIG_TCP_FASTOPEN
  83. /*
  84. * This function is called to set a Fast Open socket's "fastopen_rsk" field
  85. * to NULL when a TFO socket no longer needs to access the request_sock.
  86. @@ -222,3 +223,4 @@
  87. spin_unlock_bh(&fastopenq->lock);
  88. sock_put(lsk);
  89. }
  90. +#endif
  91. diff -Nur linux-3.15.1.orig/net/ipv4/Kconfig linux-3.15.1/net/ipv4/Kconfig
  92. --- linux-3.15.1.orig/net/ipv4/Kconfig 2014-06-16 22:44:27.000000000 +0200
  93. +++ linux-3.15.1/net/ipv4/Kconfig 2014-06-28 10:10:20.624857911 +0200
  94. @@ -307,6 +307,10 @@
  95. the notion of a secure tunnel for IPSEC and then use routing protocol
  96. on top.
  97. +config TCP_FASTOPEN
  98. + bool "Enable TCP fastopen"
  99. + default n
  100. +
  101. config INET_AH
  102. tristate "IP: AH transformation"
  103. select XFRM_ALGO
  104. diff -Nur linux-3.15.1.orig/net/ipv4/Makefile linux-3.15.1/net/ipv4/Makefile
  105. --- linux-3.15.1.orig/net/ipv4/Makefile 2014-06-16 22:44:27.000000000 +0200
  106. +++ linux-3.15.1/net/ipv4/Makefile 2014-06-28 10:10:20.624857911 +0200
  107. @@ -7,7 +7,7 @@
  108. ip_output.o ip_sockglue.o inet_hashtables.o \
  109. inet_timewait_sock.o inet_connection_sock.o \
  110. tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
  111. - tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \
  112. + tcp_minisocks.o tcp_cong.o tcp_metrics.o \
  113. tcp_offload.o datagram.o raw.o udp.o udplite.o \
  114. udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \
  115. fib_frontend.o fib_semantics.o fib_trie.o \
  116. @@ -51,6 +51,7 @@
  117. obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
  118. obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o
  119. obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
  120. +obj-$(CONFIG_TCP_FASTOPEN) += tcp_fastopen.o
  121. obj-$(CONFIG_MEMCG_KMEM) += tcp_memcontrol.o
  122. obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
  123. diff -Nur linux-3.15.1.orig/net/ipv4/sysctl_net_ipv4.c linux-3.15.1/net/ipv4/sysctl_net_ipv4.c
  124. --- linux-3.15.1.orig/net/ipv4/sysctl_net_ipv4.c 2014-06-16 22:44:27.000000000 +0200
  125. +++ linux-3.15.1/net/ipv4/sysctl_net_ipv4.c 2014-06-28 10:10:20.624857911 +0200
  126. @@ -200,6 +200,7 @@
  127. return ret;
  128. }
  129. +#ifdef CONFIG_TCP_FASTOPEN
  130. static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
  131. void __user *buffer, size_t *lenp,
  132. loff_t *ppos)
  133. @@ -246,6 +247,7 @@
  134. kfree(tbl.data);
  135. return ret;
  136. }
  137. +#endif
  138. static struct ctl_table ipv4_table[] = {
  139. {
  140. @@ -388,6 +390,7 @@
  141. .proc_handler = proc_dointvec
  142. },
  143. #endif
  144. +#ifdef CONFIG_TCP_FASTOPEN
  145. {
  146. .procname = "tcp_fastopen",
  147. .data = &sysctl_tcp_fastopen,
  148. @@ -401,6 +404,7 @@
  149. .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
  150. .proc_handler = proc_tcp_fastopen_key,
  151. },
  152. +#endif
  153. {
  154. .procname = "tcp_tw_recycle",
  155. .data = &tcp_death_row.sysctl_tw_recycle,
  156. diff -Nur linux-3.15.1.orig/net/ipv4/tcp.c linux-3.15.1/net/ipv4/tcp.c
  157. --- linux-3.15.1.orig/net/ipv4/tcp.c 2014-06-16 22:44:27.000000000 +0200
  158. +++ linux-3.15.1/net/ipv4/tcp.c 2014-06-28 10:10:20.624857911 +0200
  159. @@ -1036,6 +1036,7 @@
  160. return tmp;
  161. }
  162. +#ifdef CONFIG_TCP_FASTOPEN
  163. void tcp_free_fastopen_req(struct tcp_sock *tp)
  164. {
  165. if (tp->fastopen_req != NULL) {
  166. @@ -1069,6 +1070,7 @@
  167. tcp_free_fastopen_req(tp);
  168. return err;
  169. }
  170. +#endif
  171. int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
  172. size_t size)
  173. @@ -1084,6 +1086,7 @@
  174. lock_sock(sk);
  175. flags = msg->msg_flags;
  176. +#ifdef CONFIG_TCP_FASTOPEN
  177. if (flags & MSG_FASTOPEN) {
  178. err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);
  179. if (err == -EINPROGRESS && copied_syn > 0)
  180. @@ -1092,6 +1095,7 @@
  181. goto out_err;
  182. offset = copied_syn;
  183. }
  184. +#endif
  185. timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
  186. diff -Nur linux-3.15.1.orig/net/ipv4/tcp_ipv4.c linux-3.15.1/net/ipv4/tcp_ipv4.c
  187. --- linux-3.15.1.orig/net/ipv4/tcp_ipv4.c 2014-06-16 22:44:27.000000000 +0200
  188. +++ linux-3.15.1/net/ipv4/tcp_ipv4.c 2014-06-28 10:10:20.624857911 +0200
  189. @@ -1260,6 +1260,7 @@
  190. };
  191. #endif
  192. +#ifdef CONFIG_TCP_FASTOPEN
  193. static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
  194. struct request_sock *req,
  195. struct tcp_fastopen_cookie *foc,
  196. @@ -1440,6 +1441,23 @@
  197. WARN_ON(req->sk == NULL);
  198. return 0;
  199. }
  200. +#else
  201. +static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
  202. + struct request_sock *req,
  203. + struct tcp_fastopen_cookie *foc,
  204. + struct tcp_fastopen_cookie *valid_foc)
  205. +{
  206. + return false;
  207. +}
  208. +
  209. +static int tcp_v4_conn_req_fastopen(struct sock *sk,
  210. + struct sk_buff *skb,
  211. + struct sk_buff *skb_synack,
  212. + struct request_sock *req)
  213. +{
  214. + return 0;
  215. +}
  216. +#endif
  217. int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
  218. {
  219. diff -Nur linux-3.15.1.orig/net/Kconfig linux-3.15.1/net/Kconfig
  220. --- linux-3.15.1.orig/net/Kconfig 2014-06-16 22:44:27.000000000 +0200
  221. +++ linux-3.15.1/net/Kconfig 2014-06-28 10:10:20.628857913 +0200
  222. @@ -53,8 +53,8 @@
  223. config INET
  224. bool "TCP/IP networking"
  225. - select CRYPTO
  226. - select CRYPTO_AES
  227. + select CRYPTO if TCP_FASTOPEN
  228. + select CRYPTO_AES if TCP_FASTOPEN
  229. ---help---
  230. These are the protocols used on the Internet and on most local
  231. Ethernets. It is highly recommended to say Y here (this will enlarge