From 8bf2a38f29f9d4b31fc9087f443949c3cf6996f2 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 24 May 2021 11:54:41 -0700 Subject: [PATCH] go.mod: update wireguard-go, taking control over iOS memory usage from our fork Our wireguard-go fork used different values from upstream for package device's memory limits on iOS. This was the last blocker to removing our fork. These values are now vars rather than consts for iOS. https://github.com/tailscale/wireguard-go/pull/54/commits/c27ff9b9f6f7849614e774be8a15c1266c415750 Adjust them on startup to our preferred values. Signed-off-by: Josh Bleecher Snyder --- go.mod | 2 +- go.sum | 2 ++ wgengine/mem_ios.go | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 wgengine/mem_ios.go diff --git a/go.mod b/go.mod index 92eb6c60c..0427c2a0c 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/peterbourgon/ff/v2 v2.0.0 github.com/pkg/errors v0.9.1 // indirect github.com/tailscale/depaware v0.0.0-20201214215404-77d1e9757027 - github.com/tailscale/wireguard-go v0.0.0-20210511223652-bbf7d6cfb6ac + github.com/tailscale/wireguard-go v0.0.0-20210522003738-46b531feb08a github.com/tcnksm/go-httpstat v0.2.0 github.com/toqueteos/webbrowser v1.2.0 go4.org/mem v0.0.0-20201119185036-c04c5a6ff174 diff --git a/go.sum b/go.sum index fbccac483..053b88532 100644 --- a/go.sum +++ b/go.sum @@ -133,6 +133,8 @@ github.com/tailscale/wireguard-go v0.0.0-20210510192616-d1aa5623121d h1:qJSz1zlp github.com/tailscale/wireguard-go v0.0.0-20210510192616-d1aa5623121d/go.mod h1:ys4yUmhKncXy1jWP34qUHKipRjl322VVhxoh1Rkfo7c= github.com/tailscale/wireguard-go v0.0.0-20210511223652-bbf7d6cfb6ac h1:QHlYXuUunb1hGlosIDNu8JV2oyjCuLTnFROrRDo5LzM= github.com/tailscale/wireguard-go v0.0.0-20210511223652-bbf7d6cfb6ac/go.mod h1:ys4yUmhKncXy1jWP34qUHKipRjl322VVhxoh1Rkfo7c= +github.com/tailscale/wireguard-go v0.0.0-20210522003738-46b531feb08a h1:ujoIjR8p8HEVy26RnOe6U5aJwaMYFrIa4cpGGeZF5oc= +github.com/tailscale/wireguard-go v0.0.0-20210522003738-46b531feb08a/go.mod h1:ys4yUmhKncXy1jWP34qUHKipRjl322VVhxoh1Rkfo7c= github.com/tcnksm/go-httpstat v0.2.0 h1:rP7T5e5U2HfmOBmZzGgGZjBQ5/GluWUylujl0tJ04I0= github.com/tcnksm/go-httpstat v0.2.0/go.mod h1:s3JVJFtQxtBEBC9dwcdTTXS9xFnM3SXAZwPG41aurT8= github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ= diff --git a/wgengine/mem_ios.go b/wgengine/mem_ios.go new file mode 100644 index 000000000..ba370104b --- /dev/null +++ b/wgengine/mem_ios.go @@ -0,0 +1,21 @@ +// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package wgengine + +import ( + "github.com/tailscale/wireguard-go/device" +) + +// iOS has a very restrictive memory limit on network extensions. +// Reduce the maximum amount of memory that wireguard-go can allocate +// to avoid getting killed. + +func init() { + device.QueueStagedSize = 64 + device.QueueOutboundSize = 64 + device.QueueInboundSize = 64 + device.QueueHandshakeSize = 64 + device.PreallocatedBuffersPerPool = 64 +}