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

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