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

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