From d158f723f98797382a6a0f8d274ff355935659aa Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Tue, 17 Apr 2018 05:59:23 +0200
Subject: GoBackend: default MTU is 1280

This sucks, but it works with mobile networks. Later we can do something
sophisticated like we do with wg-quick.c, but not now.
---
 .../main/java/com/wireguard/android/backend/GoBackend.java  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'app/src')

diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java
index 7b397f05..28ce7a5e 100644
--- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -72,7 +72,7 @@ public final class GoBackend implements Backend {
 
     private static native void wgTurnOff(int handle);
 
-    private static native int wgTurnOn(String ifName, int tunFd, String settings);
+    private static native int wgTurnOn(String ifName, int tunFd, int mtu, String settings);
 
     @Override
     public Config applyConfig(final Tunnel tunnel, final Config config) throws Exception {
@@ -244,12 +244,21 @@ public final class GoBackend implements Backend {
                 }
             }
 
+            int mtu = -1;
+            try {
+                mtu = Integer.parseInt(config.getInterface().getMtu(), 10);
+            } catch (Exception e) {
+            }
+            if (mtu < 0)
+                mtu = 1280;
+            builder.setMtu(mtu);
+
             builder.setBlocking(true);
             ParcelFileDescriptor tun = builder.establish();
             if (tun == null)
                 throw new Exception("Unable to create tun device");
 
-            currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), fmt.toString());
+            currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), mtu, fmt.toString());
             if (currentTunnelHandle < 0)
                 throw new Exception("Unable to turn tunnel on (wgTurnOn return " + currentTunnelHandle + ")");
 
-- 
cgit v1.2.3