grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tcp: add mss option support


From: Josef Bacik
Subject: [PATCH] tcp: add mss option support
Date: Wed, 24 Feb 2016 14:11:36 -0500

We were continuing to see transfer rates drop between datacenters that would
result in timeouts, so I added the mss option and suddenly we went from ~200
kb/s to ~100mb/s.  So seems like I probably should have started there rather
than all these other options but whatever, now things are super awesome.

Signed-off-by: Josef Bacik <address@hidden>
---
 grub-core/net/tcp.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c
index 6902c10..2d1706e 100644
--- a/grub-core/net/tcp.c
+++ b/grub-core/net/tcp.c
@@ -111,6 +111,7 @@ struct tcphdr
 
 enum
   {
+    TCP_MSS_OPT = 2,
     TCP_SCALE_OPT = 3,
     TCP_TIMESTAMP_OPT = 8,
   };
@@ -134,6 +135,12 @@ struct tcp_timestamp_opt
   grub_uint32_t tsecr;
 } GRUB_PACKED;
 
+struct tcp_mss_opt
+{
+  struct tcp_opt_hdr opt;
+  grub_uint16_t mss;
+} GRUB_PACKED;
+
 struct tcp_pseudohdr
 {
   grub_uint32_t src;
@@ -620,6 +627,7 @@ grub_net_tcp_open (char *server,
   struct tcphdr *tcph;
   struct tcp_scale_opt *scale;
   struct tcp_timestamp_opt *timestamp;
+  struct tcp_mss_opt *mss;
   int i;
   grub_uint8_t *nbd;
   grub_net_link_level_address_t ll_target_addr;
@@ -659,7 +667,7 @@ grub_net_tcp_open (char *server,
   socket->hook_data = hook_data;
 
   headersize = ALIGN_UP (sizeof (*tcph) + sizeof (*scale) +
-                        sizeof (*timestamp), 4);
+                        sizeof (*timestamp) + sizeof (*mss), 4);
   nb = grub_netbuff_alloc (headersize + 128);
   if (!nb)
     {
@@ -718,6 +726,11 @@ grub_net_tcp_open (char *server,
   timestamp->tsval = grub_cpu_to_be32 (grub_get_time_ms ());
   timestamp->tsecr = 0;
 
+  mss = (struct tcp_mss_opt *)(timestamp + 1);
+  mss->opt.kind = TCP_MSS_OPT;
+  mss->opt.length = sizeof (struct tcp_mss_opt);
+  mss->mss = grub_cpu_to_be16 (inf->card->mtu - 128 - sizeof (*tcph));
+
   tcph->checksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_TCP,
                                                   &socket->inf->address,
                                                   &socket->out_nla);
-- 
2.5.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]