Blame SOURCES/0182-tcp-add-window-scaling-support.patch

6b3c76
From 8e86a32160008b34796f597016cc335680bb3486 Mon Sep 17 00:00:00 2001
a85e8e
From: Josef Bacik <jbacik@fb.com>
a85e8e
Date: Wed, 12 Aug 2015 08:57:55 -0700
6b3c76
Subject: [PATCH 182/261] tcp: add window scaling support
a85e8e
a85e8e
Sometimes we have to provision boxes across regions, such as California to
a85e8e
Sweden.  The http server has a 10 minute timeout, so if we can't get our 250mb
a85e8e
image transferred fast enough our provisioning fails, which is not ideal.  So
a85e8e
add tcp window scaling on open connections and set the window size to 1mb.  With
a85e8e
this change we're able to get higher sustained transfers between regions and can
a85e8e
transfer our image in well below 10 minutes.  Without this patch we'd time out
a85e8e
every time halfway through the transfer.  Thanks,
a85e8e
a85e8e
Signed-off-by: Josef Bacik <jbacik@fb.com>
a85e8e
---
a85e8e
 grub-core/net/tcp.c | 42 +++++++++++++++++++++++++++++-------------
a85e8e
 1 file changed, 29 insertions(+), 13 deletions(-)
a85e8e
a85e8e
diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c
6b3c76
index fa29a2afc..c22ef033d 100644
a85e8e
--- a/grub-core/net/tcp.c
a85e8e
+++ b/grub-core/net/tcp.c
a85e8e
@@ -106,6 +106,18 @@ struct tcphdr
a85e8e
   grub_uint16_t urgent;
a85e8e
 } GRUB_PACKED;
a85e8e
 
a85e8e
+struct tcp_scale_opt {
a85e8e
+  grub_uint8_t kind;
a85e8e
+  grub_uint8_t length;
a85e8e
+  grub_uint8_t scale;
a85e8e
+} GRUB_PACKED;
a85e8e
+
a85e8e
+struct tcp_synhdr {
a85e8e
+  struct tcphdr tcphdr;
a85e8e
+  struct tcp_scale_opt scale_opt;
a85e8e
+  grub_uint8_t padding;
a85e8e
+};
a85e8e
+
a85e8e
 struct tcp_pseudohdr
a85e8e
 {
a85e8e
   grub_uint32_t src;
a85e8e
@@ -555,7 +567,7 @@ grub_net_tcp_open (char *server,
a85e8e
   grub_net_tcp_socket_t socket;
a85e8e
   static grub_uint16_t in_port = 21550;
a85e8e
   struct grub_net_buff *nb;
a85e8e
-  struct tcphdr *tcph;
a85e8e
+  struct tcp_synhdr *tcph;
a85e8e
   int i;
a85e8e
   grub_uint8_t *nbd;
a85e8e
   grub_net_link_level_address_t ll_target_addr;
a85e8e
@@ -617,20 +629,24 @@ grub_net_tcp_open (char *server,
a85e8e
     }
a85e8e
 
a85e8e
   tcph = (void *) nb->data;
a85e8e
+  grub_memset(tcph, 0, sizeof (*tcph));
a85e8e
   socket->my_start_seq = grub_get_time_ms ();
a85e8e
   socket->my_cur_seq = socket->my_start_seq + 1;
a85e8e
-  socket->my_window = 8192;
a85e8e
-  tcph->seqnr = grub_cpu_to_be32 (socket->my_start_seq);
a85e8e
-  tcph->ack = grub_cpu_to_be32_compile_time (0);
a85e8e
-  tcph->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_SYN);
a85e8e
-  tcph->window = grub_cpu_to_be16 (socket->my_window);
a85e8e
-  tcph->urgent = 0;
a85e8e
-  tcph->src = grub_cpu_to_be16 (socket->in_port);
a85e8e
-  tcph->dst = grub_cpu_to_be16 (socket->out_port);
a85e8e
-  tcph->checksum = 0;
a85e8e
-  tcph->checksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_TCP,
a85e8e
-						   &socket->inf->address,
a85e8e
-						   &socket->out_nla);
a85e8e
+  socket->my_window = 32768;
a85e8e
+  tcph->tcphdr.seqnr = grub_cpu_to_be32 (socket->my_start_seq);
a85e8e
+  tcph->tcphdr.ack = grub_cpu_to_be32_compile_time (0);
a85e8e
+  tcph->tcphdr.flags = grub_cpu_to_be16_compile_time ((6 << 12) | TCP_SYN);
a85e8e
+  tcph->tcphdr.window = grub_cpu_to_be16 (socket->my_window);
a85e8e
+  tcph->tcphdr.urgent = 0;
a85e8e
+  tcph->tcphdr.src = grub_cpu_to_be16 (socket->in_port);
a85e8e
+  tcph->tcphdr.dst = grub_cpu_to_be16 (socket->out_port);
a85e8e
+  tcph->tcphdr.checksum = 0;
a85e8e
+  tcph->scale_opt.kind = 3;
a85e8e
+  tcph->scale_opt.length = 3;
a85e8e
+  tcph->scale_opt.scale = 5;
a85e8e
+  tcph->tcphdr.checksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_TCP,
a85e8e
+							  &socket->inf->address,
a85e8e
+							  &socket->out_nla);
a85e8e
 
a85e8e
   tcp_socket_register (socket);
a85e8e
 
6b3c76
-- 
6b3c76
2.13.5
6b3c76